From 6f982962211f903be057c9b00031d840c14e7162 Mon Sep 17 00:00:00 2001 From: Neil MacDougall Date: Fri, 10 Jan 2025 11:13:04 +0000 Subject: [PATCH] Build out more tests to cover a11y --- cypress/e2e/po/pages/account-api-keys.po.ts | 4 + cypress/e2e/tests/accessibility/login.spec.ts | 25 ----- cypress/e2e/tests/accessibility/shell.spec.ts | 95 +++++++++++++++++++ 3 files changed, 99 insertions(+), 25 deletions(-) delete mode 100644 cypress/e2e/tests/accessibility/login.spec.ts create mode 100644 cypress/e2e/tests/accessibility/shell.spec.ts diff --git a/cypress/e2e/po/pages/account-api-keys.po.ts b/cypress/e2e/po/pages/account-api-keys.po.ts index 280073e19df..0c3ffd31440 100644 --- a/cypress/e2e/po/pages/account-api-keys.po.ts +++ b/cypress/e2e/po/pages/account-api-keys.po.ts @@ -56,6 +56,10 @@ export default class AccountPagePo extends PagePo { return this.applyButton().click(); } + cancel(): Cypress.Chainable { + return this.self().get('button[type="reset"]').click(); + } + currentPassword(): PasswordPo { return new PasswordPo('[data-testid="account__current_password"]'); } diff --git a/cypress/e2e/tests/accessibility/login.spec.ts b/cypress/e2e/tests/accessibility/login.spec.ts deleted file mode 100644 index d364bc46103..00000000000 --- a/cypress/e2e/tests/accessibility/login.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po'; - -describe('Login page a11y testing', { tags: ['@adminUser', '@accessibility'] }, () => { - it('wcag21aa test', () => { - const loginPage = new LoginPagePo(); - - loginPage.goTo(); - loginPage.waitForPage(); - cy.injectAxe(); - loginPage.username().set('test user'); - - cy.checkPageAccessibility(); - }); - - it('locale selector', () => { - const loginPage = new LoginPagePo(); - - loginPage.goTo(); - loginPage.waitForPage(); - cy.injectAxe(); - cy.get('[data-testid="locale-selector"]').click(); - cy.checkPageAccessibility(); - cy.checkElementAccessibility('#username', 'Username field checks'); - }); -}); diff --git a/cypress/e2e/tests/accessibility/shell.spec.ts b/cypress/e2e/tests/accessibility/shell.spec.ts new file mode 100644 index 00000000000..d84dc492564 --- /dev/null +++ b/cypress/e2e/tests/accessibility/shell.spec.ts @@ -0,0 +1,95 @@ +import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po'; +import HomePagePo from '@/cypress/e2e/po/pages/home.po'; +import AboutPagePo from '@/cypress/e2e/po/pages/about.po'; +import PreferencesPagePo from '@/cypress/e2e/po/pages/preferences.po'; +import UserMenuPo from '@/cypress/e2e/po/side-bars/user-menu.po'; +import AccountPagePo from '@/cypress/e2e/po/pages/account-api-keys.po'; +import CreateKeyPagePo from '@/cypress/e2e/po/pages/account-api-keys-create_key.po'; + +describe('Shell a11y testing', { tags: ['@adminUser', '@accessibility'] }, () => { + it('login page', () => { + const loginPage = new LoginPagePo(); + + loginPage.goTo(); + loginPage.waitForPage(); + cy.injectAxe(); + loginPage.username().set('test user'); + + cy.checkPageAccessibility(); + }); + + it('locale selector', () => { + const loginPage = new LoginPagePo(); + + loginPage.goTo(); + loginPage.waitForPage(); + cy.injectAxe(); + cy.get('[data-testid="locale-selector"]').click(); + cy.checkPageAccessibility(); + }); + + describe('Logged in', { testIsolation: 'off' }, () => { + const aboutPage = new AboutPagePo(); + const prefPage = new PreferencesPagePo(); + const userMenu = new UserMenuPo(); + + before(() => { + cy.login(); + }); + + it('home page', () => { + HomePagePo.goToAndWaitForGet(); + cy.injectAxe(); + + cy.checkPageAccessibility(); + }); + + it('about page', () => { + AboutPagePo.navTo(); + aboutPage.waitForPage(); + + cy.checkPageAccessibility(); + }); + + it('preferences page', () => { + userMenu.clickMenuItem('Preferences'); + userMenu.isClosed(); + prefPage.waitForPage(); + prefPage.checkIsCurrentPage(); + prefPage.title(); + cy.injectAxe(); + + cy.checkPageAccessibility(); + }); + + describe('account', () => { + const accountPage = new AccountPagePo(); + const createKeyPage = new CreateKeyPagePo(); + + it('account page', () => { + userMenu.clickMenuItem('Account & API Keys'); + accountPage.waitForPage(); + cy.injectAxe(); + accountPage.checkIsCurrentPage(); + + cy.checkPageAccessibility(); + }); + + it('change password dialog', () => { + accountPage.changePassword(); + + cy.checkElementAccessibility('.change-password-modal'); + + accountPage.cancel(); + }); + + it('create API key', () => { + accountPage.create(); + createKeyPage.waitForPage(); + createKeyPage.isCurrentPage(); + + cy.checkPageAccessibility(); + }); + }); + }); +});