Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #523

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
module.exports = {
env: {
browser: true,
es2021: true,
'cypress/globals': true
},
extends: [
'plugin:cypress/recommended',
'standard-with-typescript'
],
overrides: [
],
parserOptions: {
ecmaVersion: 'latest'
},
plugins: [
'cypress'
],
rules: {
semi: ['error', 'always'],
'space-before-function-paren': 'off',
'cypress/no-assigning-return-values': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/assertion-before-screenshot': 'warn',
'cypress/no-force': 'warn',
'cypress/no-async-tests': 'error',
'cypress/no-pause': 'error',
'max-len': ['error', 80, {
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignoreComments: true
}],
'arrow-parens': ['error', 'always'],
quotes: ['error', 'single', { allowTemplateLiterals: true }],
'no-console': ['error']
}
};
module.exports = {
env: {
browser: true,
es2021: true,
'cypress/globals': true
},
extends: [
'plugin:cypress/recommended',
'standard-with-typescript'
],
overrides: [
],
parserOptions: {
ecmaVersion: 'latest'
},
plugins: [
'cypress'
],
rules: {
semi: ['error', 'always'],
'space-before-function-paren': 'off',
'cypress/no-assigning-return-values': 'error',
'cypress/no-unnecessary-waiting': 'error',
'cypress/assertion-before-screenshot': 'warn',
'cypress/no-force': 'warn',
'cypress/no-async-tests': 'error',
'cypress/no-pause': 'error',
'max-len': ['error', 80, {
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignoreComments: true
}],
'arrow-parens': ['error', 'always'],
quotes: ['error', 'single', { allowTemplateLiterals: true }],
'no-console': ['error']
}
};
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mac OS DS_Store files.
.DS_Store
.favorites.json

# Ignore node_modules
node_modules
# Mac OS DS_Store files.
.DS_Store
.favorites.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that .favorites.json is a file that should be ignored. If it's not necessary to ignore this file, consider removing this line.

# Ignore node_modules
node_modules
6 changes: 3 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
42 changes: 21 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License

Copyright (c) 2022 Mate academy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
Copyright (c) 2022 Mate academy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 9 additions & 8 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { defineConfig } = require('cypress');

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
}
}
});
const { defineConfig } = require('cypress');

module.exports = defineConfig({
e2e: {
baseUrl: 'https://demoqa.com/automation-practice-form',
setupNodeEvents(on, config) {
}
Comment on lines +5 to +6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setupNodeEvents function is currently empty. If you need to handle specific Cypress events, you should add the appropriate event listeners here.

Comment on lines +5 to +6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setupNodeEvents function is currently empty. If you need to configure custom event listeners for your Cypress tests, consider adding them here. If no event configuration is needed, you can leave it as is.

}
});
70 changes: 59 additions & 11 deletions cypress/e2e/registration.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
/// <reference types='cypress' />

describe('Student Registration page', () => {
before(() => {

});

it('', () => {

});
});
/// <reference types='cypress' />

describe('Student Registration page', () => {
const firstName = 'John';
const lastName = 'Doe';
const email = '[email protected]';
const mobileNumber = '0966313444';
const currentAddress = 'Wilhelm-Kalle-Straße 18';

before(() => {
cy.visit('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.visit('') command is missing a URL. Ensure you provide the correct URL for the registration page to visit before running the tests.

});

it(`should fill all fields except "picture"`, () => {
// Fill in the form fields
cy.get('#firstName').type(firstName);
cy.get('#lastName').type(lastName);
cy.get('#userEmail').type(email);
cy.get('label[for="gender-radio-1"]').click();
cy.get('#userNumber').type(mobileNumber);
cy.get('.subjects-auto-complete__value-container')
.type('Math{enter}');
cy.get('#currentAddress').type(currentAddress);

// Select date of birth
cy.get('#dateOfBirthInput').click();
cy.get('.react-datepicker__month-select').select('February');
cy.get('.react-datepicker__year-select').select('1986');
cy.get('.react-datepicker__day--020').click();

// Select hobbies
cy.get('label[for="hobbies-checkbox-2"]').click();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test selects 'Music' as a hobby, but the assertion checks for 'Reading'. Ensure that the selected hobby matches the expected value in the assertion.


// Select state and city
cy.get('#state').click();
cy.get('#react-select-3-option-1').click();
cy.get('#city').click();
cy.get('#react-select-4-option-2').click();

// Submit the form
cy.get('#submit').click();

// Assert modal window content
cy.get('.modal-header').contains('Thanks for submitting the form');

cy.contains('tr', 'Student Name').should('contain.text', `${firstName} ${lastName}`);
cy.contains('tr', 'Student Email').should('contain.text', email);
cy.contains('tr', 'Gender').should('contain.text', 'Male');
cy.contains('tr', 'Mobile').should('contain.text', mobileNumber);
cy.contains('tr', 'Date of Birth')
.should('contain.text', '20 February,1986');
cy.contains('tr', 'Subjects').should('contain.text', 'Maths');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion for 'Subjects' should check for 'Math' instead of 'Maths' to match the input provided earlier.

cy.contains('tr', 'Hobbies').should('contain.text', 'Reading');
cy.contains('tr', 'Address')
.should('contain.text', currentAddress);
cy.contains('tr', 'State and City')
.should('contain.text', 'Uttar Pradesh Merrut');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion for 'State and City' should match the selected options. Ensure 'Uttar Pradesh Merrut' is correct based on the options selected in the test.

});
});
50 changes: 25 additions & 25 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'login' command is defined but lacks implementation. Provide the implementation details if this command is intended to be used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'login' command is defined but not implemented. Replace the ellipsis (...) with the actual implementation if this command is intended to be used.

//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'drag' command is defined but lacks implementation. Provide the implementation details if this command is intended to be used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'drag' command is defined but not implemented. Replace the ellipsis (...) with the actual implementation if this command is intended to be used.

//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'dismiss' command is defined but lacks implementation. Provide the implementation details if this command is intended to be used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'dismiss' command is defined but not implemented. Replace the ellipsis (...) with the actual implementation if this command is intended to be used.

//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'visit' command is overwritten but lacks implementation. Provide the implementation details if this command is intended to be used.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'visit' command is overwritten but not implemented. Replace the ellipsis (...) with the actual implementation if this command is intended to be used.

68 changes: 34 additions & 34 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.on('uncaught:exception', () => {
return false;
});

const app = window.top;
if (!app.document.head.querySelector('[data-hide-command-log-request]')) {
const style = app.document.createElement('style');
style.innerHTML =
'.command-name-request, .command-name-xhr { display: none }';
style.setAttribute('data-hide-command-log-request', '');

app.document.head.appendChild(style);
};
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.on('uncaught:exception', () => {
return false;
});
const app = window.top;
if (!app.document.head.querySelector('[data-hide-command-log-request]')) {
const style = app.document.createElement('style');
style.innerHTML =
'.command-name-request, .command-name-xhr { display: none }';
style.setAttribute('data-hide-command-log-request', '');
app.document.head.appendChild(style);
};
Loading