Skip to content

Commit 60fab12

Browse files
committed
Add missing a11y tests
And improve the existing ones, by checking the theme before making the a11y check.
1 parent ed08d43 commit 60fab12

File tree

1 file changed

+55
-25
lines changed

1 file changed

+55
-25
lines changed

cypress/e2e/gui/EngageSphere.cy.js

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,67 @@ describe('EngageSphere Frontend - empty state', options, () => {
167167
})
168168

169169
describe('EngageSphere Frontend - A11y', options, () => {
170-
beforeEach(() => {
171-
cy.visit('/')
172-
cy.injectAxe()
173-
})
170+
context('With customers', () => {
171+
beforeEach(() => {
172+
cy.visit('/')
173+
cy.injectAxe()
174+
cy.get('[data-theme="light"]').should('exist')
175+
})
174176

175-
context('Customers table', () => {
176-
it('finds no a11y issues in light mode', () => {
177-
cy.checkA11y()
177+
context('Customers table', () => {
178+
it('finds no a11y issues in light mode', () => {
179+
cy.checkA11y()
180+
})
181+
182+
it('finds no a11y issues in dark mode', () => {
183+
cy.get('#theme-toggle-button').click()
184+
cy.get('[data-theme="dark"]').should('exist')
185+
cy.checkA11y()
186+
})
178187
})
179188

180-
it('finds no a11y issues in dark mode', () => {
181-
cy.get('#theme-toggle-button').click()
182-
cy.checkA11y()
189+
context('Customer details', () => {
190+
beforeEach(() => {
191+
cy.get('tbody tr').first().click()
192+
})
193+
194+
it('finds no a11y issues in light mode', () => {
195+
cy.checkA11y()
196+
})
197+
198+
it('finds no a11y issues in dark mode', () => {
199+
cy.get('#theme-toggle-button').click()
200+
cy.get('[data-theme="dark"]').should('exist')
201+
cy.checkA11y()
202+
})
203+
204+
context('Show address', () => {
205+
it('finds no a11y issues in light mode', () => {
206+
cy.contains('button', 'Show address').click()
207+
cy.checkA11y()
208+
})
209+
210+
it('finds no a11y issues in dark mode', () => {
211+
cy.get('#theme-toggle-button').click()
212+
cy.get('[data-theme="dark"]').should('exist')
213+
cy.contains('button', 'Show address').click()
214+
cy.checkA11y()
215+
})
216+
})
183217
})
184218
})
185219

186-
context('Customer details', () => {
220+
context('Without customers (empty state)', () => {
187221
beforeEach(() => {
188-
cy.get('tbody tr').first().click()
222+
cy.intercept(
223+
'GET',
224+
`${Cypress.env('API_URL')}/customers**`,
225+
{ body: null }
226+
).as('getEmptyCustomers')
227+
cy.visit('/')
228+
cy.wait('@getEmptyCustomers')
229+
cy.injectAxe()
230+
cy.get('[data-theme="light"]').should('exist')
189231
})
190232

191233
it('finds no a11y issues in light mode', () => {
@@ -194,21 +236,9 @@ describe('EngageSphere Frontend - A11y', options, () => {
194236

195237
it('finds no a11y issues in dark mode', () => {
196238
cy.get('#theme-toggle-button').click()
239+
cy.get('[data-theme="dark"]').should('exist')
197240
cy.checkA11y()
198241
})
199-
200-
context('Show address', () => {
201-
it('finds no a11y issues in light mode', () => {
202-
cy.contains('button', 'Show address').click()
203-
cy.checkA11y()
204-
})
205-
206-
it('finds no a11y issues in dark mode', () => {
207-
cy.get('#theme-toggle-button').click()
208-
cy.contains('button', 'Show address').click()
209-
cy.checkA11y()
210-
})
211-
})
212242
})
213243
})
214244

0 commit comments

Comments
 (0)