Skip to content

Commit 3724492

Browse files
committed
2 parents 1d98cf1 + a184fc5 commit 3724492

28 files changed

Lines changed: 510 additions & 459 deletions

.github/workflows/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
browser: chrome
3535
headless: true
36-
spec: "cypress/integration/*"
36+
spec: "cypress/e2e/*"
3737
publish:
3838
needs: [build, tests]
3939
if: github.ref == 'refs/heads/master'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ cypress/videos
1212
cypress/fixtures
1313
cypress/screenshots
1414
*.tgz
15+
.vscode

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ _This project uses npm ≥ 8 and Node ≥ 18 - however any project using this pa
191191
6. To add error/warning styles and messages to your features, `@extend` one of the placeholders and `@include contentMessage()` from `src/_base.scss`.
192192
7. Add tests to your features in cypress folder (edit the element file or create a new one if needed)
193193
8. Run tests: `npm run test:ui` or `npm run test` (headless)
194-
- You can also run tests for a specific tag/attribute by doing `npm run test -- --spec cypress/integration/{file-to-test}`
194+
- You can also run tests for a specific tag/attribute by doing `npm run test -- --spec cypress/e2e/{file-to-test}`
195195
9. Add the feature to the [features.md](./features.md) & [codes.md](./codes.md) with a new error or warning code
196196

197197
---

cypress.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
projectId: '8purx7',
5+
// defaultCommandTimeout: 4000,
6+
retries: { openMode: 2, runMode: 1 },
7+
e2e: {
8+
setupNodeEvents(on, config) {
9+
// implement node event listeners here
10+
},
11+
},
12+
})

cypress.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe("[accesskey]", () => {
2-
before(() => {
3-
cy.visit("/test/index.html");
4-
});
2+
beforeEach(() => {
3+
cy.visit('/test/index.html')
4+
})
55

66
it('should show warning on elements with accesskey', () => {
77
cy.get("[accesskey]")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {
33
} from "../support/constants";
44

55
describe("[autoplay]", () => {
6-
before(() => {
7-
cy.visit("/test/index.html");
8-
});
6+
beforeEach(() => {
7+
cy.visit('/test/index.html')
8+
})
99

1010
it('should show warning outline on elements with autoplay', () => {
1111
cy.get("[autoplay]")

cypress/e2e/buttons_spec.cy.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { ERROR_BORDER_COLOR } from '../support/constants'
2+
3+
describe('<button>', () => {
4+
before(() => {
5+
cy.visit('/test/index.html')
6+
})
7+
beforeEach(() => {
8+
cy.visit('/test/index.html')
9+
})
10+
11+
it('should not have buttons with interactive content inside', () => {
12+
cy.visit('/test/index.html')
13+
14+
const noneElements = ['audio[controls]', 'embed', 'iframe', 'img[usemap]', 'input:not([type="hidden"])', 'object[usemap]', 'select', 'textarea', 'video[controls]']
15+
// removed "button" from afterElements because browser was correcting the issue
16+
const afterElements = ['details', 'label']
17+
const beforeElements = []
18+
19+
noneElements.forEach((el) => {
20+
cy.get(`button ${el}`).each((element) => {
21+
cy.get(element).should('have.css', 'border-color', 'rgb(255, 0, 0)')
22+
})
23+
})
24+
25+
afterElements.forEach((el) => {
26+
cy.get(`button ${el}`).each((element) => {
27+
if (element) {
28+
cy.get(element).after('content').should('eq', `ERROR (E0000): Ensure that <${el}> is not a child of <button>.`)
29+
}
30+
})
31+
})
32+
33+
beforeElements.forEach((el) => {
34+
cy.get(`button ${el}`).each((element) => {
35+
if (element) {
36+
cy.get(element).before('content').should('eq', `ERROR: Ensure that <${el}> is not a child of <button> as it is an invalid HTML.`)
37+
}
38+
})
39+
})
40+
})
41+
42+
it('should not have empty buttons', () => {
43+
cy.visit('/test/index.html')
44+
45+
cy.get('button:not( [aria-label] ):not( [aria-labelledby] ):empty').each((element) => {
46+
cy.get(element).after('content').should('eq', 'ERROR (E0001): Ensure that <button> has meaningful content or is labelled appropriately.')
47+
})
48+
})
49+
})
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe("[dir]", () => {
2-
before(() => {
3-
cy.visit("/test/index.html");
4-
});
2+
beforeEach(() => {
3+
cy.visit('/test/index.html')
4+
})
55

66
it('should show error on elements with wrong values for dir attribute', () => {
77
cy.get("[dir]:not([dir='rtl']):not([dir='ltr']):not([dir='auto'])")
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe("[handlers]", () => {
2-
before(() => {
3-
cy.visit("/test/index.html");
4-
});
2+
beforeEach(() => {
3+
cy.visit('/test/index.html')
4+
})
55

66
it('should show error if the iframe does not have a title', () => {
77
cy.get(`

0 commit comments

Comments
 (0)