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

Upgrading eslint-plugin-cypress #1082

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"dotenv": "16.0.3",
"eslint": "8.38.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-cypress": "2.13.2",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-no-relative-import-paths": "1.5.2",
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/integration/app-frontend/calculate-page-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ describe('Calculate Page Order', () => {

cy.get(appFrontend.navMenu).find('li > button').eq(1).click();
cy.get(appFrontend.group.row(0).editBtn).click();
cy.get(appFrontend.group.newValue).clear().type('2');
cy.get(appFrontend.group.newValue).clear();
cy.get(appFrontend.group.newValue).type('2');

cy.get(appFrontend.nextButton).click();
cy.wait('@getPageOrder');
Expand All @@ -61,7 +62,8 @@ describe('Calculate Page Order', () => {

// Clicking previous here is expected to not have any effect, because the triggered action is rejected when
// the 'repeating' page is supposed to be hidden by the change. Clicking too fast leads to a failure...
cy.get(appFrontend.group.sendersName).clear().type('hideRepeating');
cy.get(appFrontend.group.sendersName).clear();
cy.get(appFrontend.group.sendersName).type('hideRepeating');
cy.get(appFrontend.prevButton).click();

// ...but clicking 'previous' after this point will have updated the components to know that the previous page
Expand Down
19 changes: 13 additions & 6 deletions test/e2e/integration/app-frontend/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ describe('UI Components', () => {

it('address component fetches post place from zip code', () => {
cy.goto('changename');
cy.get(appFrontend.changeOfName.address.street_name).type('Sesame Street 1A').blur();
cy.get(appFrontend.changeOfName.address.zip_code).type('0174').blur();
cy.get(appFrontend.changeOfName.address.street_name).type('Sesame Street 1A');
cy.get(appFrontend.changeOfName.address.street_name).blur();
cy.get(appFrontend.changeOfName.address.zip_code).type('0174');
cy.get(appFrontend.changeOfName.address.zip_code).blur();
cy.get(appFrontend.changeOfName.address.post_place).should('have.value', 'OSLO');
});

Expand All @@ -119,12 +121,15 @@ describe('UI Components', () => {
}
});
cy.goto('changename');
cy.get(appFrontend.changeOfName.newFirstName).type('Per').blur();
cy.get(appFrontend.changeOfName.newLastName).type('Hansen').blur();
cy.get(appFrontend.changeOfName.newFirstName).type('Per');
cy.get(appFrontend.changeOfName.newFirstName).blur();
cy.get(appFrontend.changeOfName.newLastName).type('Hansen');
cy.get(appFrontend.changeOfName.newLastName).blur();
cy.get(appFrontend.changeOfName.confirmChangeName).find('label').click();
cy.get(appFrontend.changeOfName.reasons).should('be.visible');

cy.get(appFrontend.changeOfName.newMiddleName).type('checkbox_readOnly').blur();
cy.get(appFrontend.changeOfName.newMiddleName).type('checkbox_readOnly');
cy.get(appFrontend.changeOfName.newMiddleName).blur();

cy.get(appFrontend.changeOfName.confirmChangeName).find('label').click(); // No effect

Expand All @@ -133,7 +138,9 @@ describe('UI Components', () => {

cy.get(appFrontend.changeOfName.reasons).findByText('Gårdsbruk').click();

cy.get(appFrontend.changeOfName.newMiddleName).clear().type('radio_readOnly').blur();
cy.get(appFrontend.changeOfName.newMiddleName).clear();
cy.get(appFrontend.changeOfName.newMiddleName).type('radio_readOnly');
cy.get(appFrontend.changeOfName.newMiddleName).blur();
cy.get(appFrontend.changeOfName.confirmChangeName).find('label').click();
cy.get(appFrontend.changeOfName.reasons).should('not.exist');
cy.get(appFrontend.changeOfName.confirmChangeName).find('label').click();
Expand Down
26 changes: 10 additions & 16 deletions test/e2e/integration/app-frontend/dynamics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@ const appFrontend = new AppFrontend();
describe('Dynamics', () => {
it('Show and hide confirm name change checkbox on changing firstname', () => {
cy.goto('changename');
cy.get(appFrontend.changeOfName.newFirstName)

.type('test')
.then(() => {
cy.get(appFrontend.changeOfName.newMiddleName).focus();
cy.get(appFrontend.changeOfName.confirmChangeName).should('be.visible');
});
cy.get(appFrontend.changeOfName.newFirstName)
.clear()
.then(() => {
cy.get(appFrontend.changeOfName.newMiddleName).focus();
cy.get(appFrontend.changeOfName.confirmChangeName).should('not.exist');
});
cy.get(appFrontend.changeOfName.newFirstName).type('test');
cy.get(appFrontend.changeOfName.newMiddleName).focus();
cy.get(appFrontend.changeOfName.confirmChangeName).should('be.visible');
cy.get(appFrontend.changeOfName.newFirstName).clear();
cy.get(appFrontend.changeOfName.newMiddleName).focus();
cy.get(appFrontend.changeOfName.confirmChangeName).should('not.exist');
});

it('Show and hide name change reasons radio buttons', () => {
cy.goto('changename');
cy.get(appFrontend.changeOfName.newFirstName).type('test').blur();
cy.get(appFrontend.changeOfName.newLastName).type('test').blur();
cy.get(appFrontend.changeOfName.newFirstName).type('test');
cy.get(appFrontend.changeOfName.newLastName).type('test');
cy.get(appFrontend.changeOfName.confirmChangeName).find('input').dsCheck();
cy.get(appFrontend.changeOfName.reasons).should('be.visible');
});
Expand Down Expand Up @@ -85,7 +78,8 @@ describe('Dynamics', () => {

// Typing 1234 into the field should hide the last name component
cy.get(appFrontend.navMenu).find('li > button').last().click();
cy.get('#testInputOnSummary').clear().type('1234');
cy.get('#testInputOnSummary').clear();
cy.get('#testInputOnSummary').type('1234');
cy.get(appFrontend.navMenu).find('li > button').first().click();
cy.get(appFrontend.changeOfName.newLastName).should('not.exist');

Expand Down
18 changes: 6 additions & 12 deletions test/e2e/integration/app-frontend/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ describe('Formatting', () => {
.siblings()
.parent()
.should('have.css', 'border-bottom', '1px dashed rgb(148, 148, 148)');
cy.get(appFrontend.changeOfName.mobilenummer)

.type('44444444')
.should('have.value', '+47 444 44 444');
cy.get(appFrontend.changeOfName.mobilenummer).type('44444444');
cy.get(appFrontend.changeOfName.mobilenummer).should('have.value', '+47 444 44 444');
cy.gotoAndComplete('changename');
cy.get(appFrontend.backButton).should('be.visible');
cy.intercept('**/api/layoutsettings/group').as('getLayoutGroup');
Expand All @@ -22,13 +20,9 @@ describe('Formatting', () => {
cy.get(appFrontend.nextButton).click();
cy.get(appFrontend.group.showGroupToContinue).find('input').dsCheck();
cy.get(appFrontend.group.addNewItem).click();
cy.get(appFrontend.group.currentValue)
.type('1')
.should('have.value', 'NOK 1')
.and('have.css', 'text-align', 'right');
cy.get(appFrontend.group.newValue)
.type('-2')
.should('not.contain.value', '-')
.and('have.css', 'text-align', 'right');
cy.get(appFrontend.group.currentValue).type('1');
cy.get(appFrontend.group.currentValue).should('have.value', 'NOK 1').and('have.css', 'text-align', 'right');
cy.get(appFrontend.group.newValue).type('-2');
cy.get(appFrontend.group.newValue).should('not.contain.value', '-').and('have.css', 'text-align', 'right');
});
});
38 changes: 22 additions & 16 deletions test/e2e/integration/app-frontend/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('Group', () => {
init();
cy.get(appFrontend.group.showGroupToContinue).find('input').dsCheck();
cy.get(appFrontend.group.addNewItem).click();
cy.get(appFrontend.group.currentValue).type('1337').blur();
cy.get(appFrontend.group.currentValue).type('1337');
// DataProcessingHandler.cs for frontend-test changes 1337 to 1338.
cy.get(appFrontend.group.currentValue).should('have.value', 'NOK 1 338');
cy.get(appFrontend.group.newValueLabel).should('contain.text', '2. Endre verdi 1338 til');
Expand All @@ -106,25 +106,28 @@ describe('Group', () => {
init();
cy.get(appFrontend.group.showGroupToContinue).find('input').dsCheck();
cy.get(appFrontend.group.addNewItem).click();
cy.get(appFrontend.group.currentValue).type('1').blur();
cy.get(appFrontend.group.newValue).type('0').blur();
cy.get(appFrontend.group.currentValue).type('1');
cy.get(appFrontend.group.newValue).type('0');
cy.get(appFrontend.fieldValidationError.replace('field', 'newValue')).should('have.text', texts.zeroIsNotValid);
cy.get(appFrontend.group.newValue).clear().type('1').blur();
cy.get(appFrontend.group.newValue).clear();
cy.get(appFrontend.group.newValue).type('1');
cy.get(appFrontend.fieldValidationError.replace('field', 'newValue')).should('not.exist');
cy.get(appFrontend.group.mainGroup).siblings(appFrontend.group.tableErrors).should('not.exist');
cy.get(appFrontend.group.mainGroup).find(appFrontend.group.editContainer).find(appFrontend.group.next).click();
cy.get(appFrontend.group.addNewItem).should('not.exist');
cy.get(appFrontend.group.comments).type('test').blur();
cy.get(appFrontend.group.comments).type('test');
cy.get(appFrontend.group.comments).blur();
cy.get(appFrontend.fieldValidationError.replace('field', 'comments')).should(
'have.text',
texts.testIsNotValidValue,
);
cy.get(appFrontend.group.comments).clear().type('automation').blur();
cy.get(appFrontend.group.comments).clear();
cy.get(appFrontend.group.comments).type('automation');
cy.get(appFrontend.fieldValidationError.replace('field', 'comments')).should('not.exist');
cy.get(appFrontend.group.subGroup).siblings(appFrontend.group.tableErrors).should('not.exist');
cy.get(appFrontend.group.mainGroup).siblings(appFrontend.group.tableErrors).should('not.exist');
cy.get(appFrontend.group.saveSubGroup).click().should('not.exist');
cy.get(appFrontend.group.saveMainGroup).click().should('not.exist');
cy.get(appFrontend.group.saveSubGroup).clickAndGone();
cy.get(appFrontend.group.saveMainGroup).clickAndGone();
});

[Triggers.Validation, Triggers.ValidateRow].forEach((trigger) => {
Expand All @@ -147,12 +150,12 @@ describe('Group', () => {
cy.get(appFrontend.group.showGroupToContinue).find('input').dsCheck();

cy.get(appFrontend.group.addNewItem).click();
cy.get(appFrontend.group.currentValue).type('123').blur();
cy.get(appFrontend.group.newValue).type('1').blur();
cy.get(appFrontend.group.currentValue).type('123');
cy.get(appFrontend.group.newValue).type('1');
cy.get(appFrontend.group.saveMainGroup).click();

cy.get(appFrontend.group.addNewItem).click();
cy.get(appFrontend.group.currentValue).type('123').blur();
cy.get(appFrontend.group.currentValue).type('123');

cy.get(appFrontend.group.row(0).editBtn).click();
cy.get(appFrontend.group.saveMainGroup).click();
Expand Down Expand Up @@ -192,8 +195,8 @@ describe('Group', () => {
cy.get(appFrontend.group.showGroupToContinue).find('input').dsCheck();
cy.get(appFrontend.group.secondGroup_add).click();
cy.get(appFrontend.group.secondGroup_add_to_reference_group).click();
cy.get(appFrontend.group.secondGroup_currentValue).type('1').blur();
cy.get(appFrontend.group.secondGroup_newValue).type('2').blur();
cy.get(appFrontend.group.secondGroup_currentValue).type('1');
cy.get(appFrontend.group.secondGroup_newValue).type('2');
cy.get(appFrontend.group.secondGroup_save).click();
cy.get(appFrontend.group.secondGroup_save_and_close).click();
cy.get(appFrontend.group.secondGroup_table).find('tbody').find('tr').its('length').should('eq', 1);
Expand Down Expand Up @@ -255,13 +258,16 @@ describe('Group', () => {

cy.get(appFrontend.group.row(0).editBtn).should('have.text', 'Se innhold');
cy.get(appFrontend.group.row(0).deleteBtn).should('not.exist');
cy.get(appFrontend.group.row(0).editBtn).click().should('have.text', 'Lukk');
cy.get(appFrontend.group.saveMainGroup).should('have.text', 'Lukk').click().should('not.exist');
cy.get(appFrontend.group.row(0).editBtn).click();
cy.get(appFrontend.group.row(0).editBtn).should('have.text', 'Lukk');
cy.get(appFrontend.group.saveMainGroup).should('have.text', 'Lukk');
cy.get(appFrontend.group.saveMainGroup).clickAndGone();

// The 'liten' row differs, as it should not have a save button on the bottom
cy.get(appFrontend.group.row(1).editBtn).should('have.text', 'Se innhold');
cy.get(appFrontend.group.row(1).deleteBtn).should('not.exist');
cy.get(appFrontend.group.row(1).editBtn).click().should('have.text', 'Lukk');
cy.get(appFrontend.group.row(1).editBtn).click();
cy.get(appFrontend.group.row(1).editBtn).should('have.text', 'Lukk');
cy.get(appFrontend.group.saveMainGroup).should('not.exist');
});

Expand Down
6 changes: 4 additions & 2 deletions test/e2e/integration/app-frontend/hide-row-in-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ it('should be possible to hide rows when "Endre fra" is greater or equals to', (
cy.get(appFrontend.nextButton).click();
cy.get(appFrontend.group.showGroupToContinue).find('input').dsCheck();
cy.get(appFrontend.group.edit).should('be.visible');
cy.get(appFrontend.group.hideRepeatingGroupRow).clear().type('1');
cy.get(appFrontend.group.hideRepeatingGroupRow).clear();
cy.get(appFrontend.group.hideRepeatingGroupRow).type('1');
cy.get(appFrontend.group.edit).should('not.exist');
cy.get(appFrontend.group.hideRepeatingGroupRow).clear().type('1000000');
cy.get(appFrontend.group.hideRepeatingGroupRow).clear();
cy.get(appFrontend.group.hideRepeatingGroupRow).type('1000000');
cy.get(appFrontend.group.edit).should('exist');
});
32 changes: 13 additions & 19 deletions test/e2e/integration/app-frontend/list-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ describe('List component', () => {
.parent('td')
.parent('tr')
.should('not.have.class', dataListPage.selectedRowClass);
cy.get(dataListPage.tableBody).contains('Caroline').parent('td').parent('tr').click();
cy.get(dataListPage.tableBody)
.contains('Caroline')
.parent('td')
.parent('tr')
.click()
.should('have.class', dataListPage.selectedRowClass);
cy.get(dataListPage.tableBody).contains('Kåre').parent('td').parent('tr').click();
cy.get(dataListPage.tableBody)
.contains('Kåre')
.parent('td')
.parent('tr')
.click()
.get(dataListPage.tableBody)
.contains('Caroline')
.parent('td')
Expand All @@ -60,33 +60,27 @@ describe('List component', () => {

it('When selecting number of rows to show this is updated correctly', () => {
cy.goto('datalist');
cy.get(dataListPage.listComponent).get(dataListPage.selectComponent).select('10').should('have.value', 10);
cy.get(dataListPage.listComponent)
.get(dataListPage.selectComponent)
.select('10')
.get(dataListPage.tableBody)
.find('tr')
.its('length')
.should('eq', 10);
cy.get(dataListPage.listComponent).get(dataListPage.selectComponent).select('10');
cy.get(dataListPage.listComponent).get(dataListPage.selectComponent).should('have.value', 10);
cy.get(dataListPage.listComponent).get(dataListPage.tableBody).find('tr').its('length').should('eq', 10);
});

it('When navigation between pages the expected data is shown in the first table row', () => {
cy.goto('datalist');
cy.get(dataListPage.navigateNextButton).should('not.be.disabled');
cy.get(dataListPage.tableBody).first().first().contains('Caroline');
cy.get(dataListPage.navigateNextButton).click().get(dataListPage.tableBody).first().first().contains('Hans');
cy.get(dataListPage.navigatePreviousButton)
.click()
.get(dataListPage.tableBody)
.first()
.first()
.contains('Caroline');
cy.get(dataListPage.navigateNextButton).click();
cy.get(dataListPage.navigateNextButton).get(dataListPage.tableBody).first().first().contains('Hans');
cy.get(dataListPage.navigatePreviousButton).click();
cy.get(dataListPage.navigatePreviousButton).get(dataListPage.tableBody).first().first().contains('Caroline');
});

it('Sorting works as expected', () => {
cy.goto('datalist');
cy.get(dataListPage.sortButton).click().get(dataListPage.tableBody).first().first().contains('Hans');
cy.get(dataListPage.sortButton).click().get(dataListPage.tableBody).first().first().contains('Petter');
cy.get(dataListPage.sortButton).click();
cy.get(dataListPage.sortButton).get(dataListPage.tableBody).first().first().contains('Hans');
cy.get(dataListPage.sortButton).click();
cy.get(dataListPage.sortButton).get(dataListPage.tableBody).first().first().contains('Petter');
});
it('Search works with list as intended', () => {
cy.goto('datalist');
Expand Down
17 changes: 9 additions & 8 deletions test/e2e/integration/app-frontend/multipart-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,35 +145,36 @@ describe('Multipart save', () => {
expectSave(`${groupKey}[${index}].${subGroupKey}[0].source`, 'altinn', null);
cy.get(appFrontend.group.mainGroup).find(appFrontend.group.back).click();

cy.get(appFrontend.group.currentValue).type(oldValue).blur();
cy.get(appFrontend.group.currentValue).type(oldValue);
expectSave(`${groupKey}[${index}].${currentValueKey}`, oldValue, null);

cy.get(appFrontend.group.newValue).type(newValue).blur();
cy.get(appFrontend.group.newValue).type(newValue);
expectSave(`${groupKey}[${index}].${newValueKey}`, newValue, null);

cy.get(appFrontend.group.mainGroup).find(appFrontend.group.next).click();
cy.get(appFrontend.group.comments).type(comment).blur();
cy.get(appFrontend.group.comments).type(comment);
expectSave(`${groupKey}[${index}].${subGroupKey}[0].${commentKey}`, comment, null);

cy.get(appFrontend.group.saveSubGroup).click().should('not.exist');
cy.get(appFrontend.group.saveMainGroup).click().should('not.exist');
cy.get(appFrontend.group.saveSubGroup).clickAndGone();
cy.get(appFrontend.group.saveMainGroup).clickAndGone();
}

// Add some rows to the group
addRow(0, '1', '2', 'first comment');
addRow(1, '1234', '5678', 'second comment');

cy.get(appFrontend.group.row(0).editBtn).click();
cy.get(appFrontend.group.newValue).type('2').blur();
cy.get(appFrontend.group.newValue).type('2');
expectSave(`${groupKey}[0].${newValueKey}`, '22', '2');
cy.get(appFrontend.group.newValue).clear().type('2').blur();
cy.get(appFrontend.group.newValue).clear();
cy.get(appFrontend.group.newValue).type('2');
expectSave(`${groupKey}[0].${newValueKey}`, '2', '22');

cy.get(appFrontend.group.editContainer).find(appFrontend.group.next).click();
cy.get(appFrontend.group.addNewItemSubGroup).click();
expectSave(`${groupKey}[0].${subGroupKey}[1].source`, 'altinn', null);

cy.get(appFrontend.group.comments).type('third comment in first row').blur();
cy.get(appFrontend.group.comments).type('third comment in first row');
expectSave(`${groupKey}[0].${subGroupKey}[1].${commentKey}`, 'third comment in first row', null);

cy.get(appFrontend.group.row(0).nestedGroup.row(1).nestedDynamics).dsCheck();
Expand Down