Skip to content

Cypress: New tools/functions #1113

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

Merged
merged 3 commits into from
Apr 20, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/e2e/fixtures/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@
"nestedOption3": "Opsjon 111",
"change": "Endre",
"view": "Se innhold",
"edit": "Rediger"
"edit": "Rediger",
"emptySummary": "Du har ikke lagt inn informasjon her"
}
36 changes: 12 additions & 24 deletions test/e2e/integration/app-frontend/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,40 +63,28 @@ describe('UI Components', () => {

it('is possible to navigate between pages using navigation bar', () => {
cy.goto('changename');
cy.get(appFrontend.navMenu)
cy.get(appFrontend.navMenuButtons).should('have.length', 2);
cy.navPage('form')
.should('have.attr', 'aria-current', 'page')
.and('have.css', 'background-color', 'rgb(2, 47, 81)');
cy.navPage('summary').should('have.css', 'background-color', 'rgba(0, 0, 0, 0)');
cy.navPage('summary').click();
cy.navPage('form').should('not.have.attr', 'aria-current', 'page');
cy.navPage('summary')
.should('have.attr', 'aria-current', 'page')
.and('have.css', 'background-color', 'rgb(2, 47, 81)');
cy.get(appFrontend.changeOfName.summaryNameChanges).should('be.visible');

.find('li > button')

.and('have.length', 2)
.then((navButtons) => {
cy.wrap(navButtons)
.first()
.should('have.attr', 'aria-current', 'page')
.and('have.css', 'background-color', 'rgb(2, 47, 81)');
cy.wrap(navButtons).last().should('have.css', 'background-color', 'rgba(0, 0, 0, 0)').click();
});
cy.get(`${appFrontend.navMenu} li:first-child > button`).should('not.have.attr', 'aria-current', 'page');
cy.get(appFrontend.navMenu)
.find('li > button')
.then((navButtons) => {
cy.wrap(navButtons).should('be.visible');
cy.wrap(navButtons)
.last()
.should('have.attr', 'aria-current', 'page')
.and('have.css', 'background-color', 'rgb(2, 47, 81)');
cy.get(appFrontend.changeOfName.summaryNameChanges).should('be.visible');
});
cy.viewport('samsung-s10');
cy.get(appFrontend.navMenu).should('not.exist');
cy.get('[data-testid="NavigationBar"]').find('button:contains("form")').should('not.exist');
cy.get('[data-testid="NavigationBar"]').find('button:contains("summary")').should('be.visible');
cy.viewport('macbook-16');
cy.interceptLayout('changename', (component) => {
cy.changeLayout((component) => {
if (component.type === 'NavigationBar') {
component.compact = true;
}
});
cy.reload();
cy.get(appFrontend.navMenu).should('not.exist');
cy.get('[data-testid="NavigationBar"]').find('button:contains("form")').should('not.exist');
cy.get('[data-testid="NavigationBar"]').find('button:contains("summary")').should('be.visible');
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/integration/app-frontend/dynamics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,25 @@ describe('Dynamics', () => {
cy.goto('changename');

// Make sure the summary page can be hidden
cy.get(appFrontend.navMenu).find('li > button').should('have.length', 2);
cy.get(appFrontend.navMenuButtons).should('have.length', 2);
cy.get(appFrontend.changeOfName.newFirstName).type('hideSummary');
cy.get(appFrontend.navMenu).find('li > button').should('have.length', 1);
cy.get(appFrontend.navMenuButtons).should('have.length', 1);

cy.get(appFrontend.changeOfName.newFirstName).clear();
cy.get(appFrontend.changeOfName.newLastName).should('be.visible');
cy.get(appFrontend.navMenu).find('li > button').should('have.length', 2);
cy.get(appFrontend.navMenuButtons).should('have.length', 2);

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

// But hiding the summary page should hide the input there, making the last name component show up again (since
// the value found in the component lookup is null now)
cy.get(appFrontend.changeOfName.newFirstName).type('hideSummary');
cy.get(appFrontend.changeOfName.newLastName).should('be.visible');
cy.get(appFrontend.navMenu).find('li > button').should('have.length', 1);
cy.get(appFrontend.navMenuButtons).should('have.length', 1);
});
});
5 changes: 1 addition & 4 deletions test/e2e/integration/app-frontend/mobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ describe('Mobile', () => {
cy.get(appFrontend.nextButton).click();
cy.get(appFrontend.group.sendersName).type('automation');
cy.get(appFrontend.navMenu).should('not.exist');
cy.get(appFrontend.group.navigationBarButton)

.and('have.attr', 'aria-expanded', 'false')
.click();
cy.get(appFrontend.group.navigationBarButton).should('have.attr', 'aria-expanded', 'false').click();
cy.get(appFrontend.group.navigationBarButton).should('have.attr', 'aria-expanded', 'true');
cy.get(appFrontend.navMenu).should('be.visible');
cy.get(appFrontend.navMenu).find('li > button').last().click();
Expand Down
Loading