@faststore/ui 1.3.34 → 1.3.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.3.35 (2021-12-14)
7
+
8
+ **Note:** Version bump only for package @faststore/ui
9
+
10
+
11
+
12
+
13
+
6
14
  ## 1.3.34 (2021-12-11)
7
15
 
8
16
 
@@ -0,0 +1,17 @@
1
+ import type { AxeResults } from 'axe-core';
2
+ export declare const toHaveNoIncompletes: {
3
+ toHaveNoIncompletes: (results: AxeResults) => {
4
+ actual: import("axe-core").Result[];
5
+ message: () => string;
6
+ pass: boolean;
7
+ };
8
+ };
9
+ declare global {
10
+ namespace jest {
11
+ interface Matchers<R, T> {
12
+ toHaveNoIncompletes(): R;
13
+ }
14
+ }
15
+ interface Node {
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/ui",
3
- "version": "1.3.34",
3
+ "version": "1.3.35",
4
4
  "description": "A lightweight, framework agnostic component library for React",
5
5
  "author": "emersonlaurentino",
6
6
  "license": "MIT",
@@ -72,12 +72,15 @@
72
72
  "@testing-library/react": "^11.2.6",
73
73
  "@testing-library/react-hooks": "^7.0.2",
74
74
  "@testing-library/user-event": "^13.1.8",
75
+ "@types/axe-core": "^2.0.7",
75
76
  "@types/jest-axe": "^3.5.3",
76
77
  "@types/tabbable": "^3.1.1",
77
78
  "@types/testing-library__jest-dom": "^5.9.5",
78
- "@vtex/theme-b2c-tailwind": "^1.3.34",
79
+ "@vtex/theme-b2c-tailwind": "^1.3.35",
79
80
  "@vtex/tsconfig": "^0.5.0",
81
+ "chalk": "^5.0.0",
80
82
  "jest-axe": "^5.0.1",
83
+ "jest-matcher-utils": "^27.4.2",
81
84
  "react": "^17.0.2",
82
85
  "react-docgen-typescript-loader": "^3.7.2",
83
86
  "react-dom": "^17.0.2",
@@ -86,5 +89,5 @@
86
89
  "tsdx": "^0.14.1",
87
90
  "typescript": "^4.2.4"
88
91
  },
89
- "gitHead": "d2e39546bb40ff5b57b25725d670883f42b219db"
92
+ "gitHead": "2180e37bd61f31e0ded50f56e4834d89879fce9a"
90
93
  }
@@ -76,6 +76,14 @@ describe('Modal WAI-ARIA Specifications', () => {
76
76
  )
77
77
 
78
78
  expect(await axe(document.body)).toHaveNoViolations()
79
+ // This is disabled because the useTrapFocus use sentinel div elements
80
+ // with tabindex and aria-hidden true. This is intentionally, because
81
+ // these divs shouldn't be considered to accessibility API.
82
+ expect(
83
+ await axe(document.body, {
84
+ rules: { 'aria-hidden-focus': { enabled: false } },
85
+ })
86
+ ).toHaveNoIncompletes()
79
87
  })
80
88
 
81
89
  it('Focus first element', () => {
package/src/setupTests.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import '@testing-library/jest-dom/extend-expect'
2
2
  import { toHaveNoViolations } from 'jest-axe'
3
3
 
4
+ import { toHaveNoIncompletes } from './utils/toHaveNoIncomplete'
5
+
4
6
  expect.extend(toHaveNoViolations)
7
+ expect.extend(toHaveNoIncompletes)
@@ -0,0 +1,76 @@
1
+ import type { AxeResults } from 'axe-core'
2
+ import { printReceived, matcherHint } from 'jest-matcher-utils'
3
+ import chalk from 'chalk'
4
+
5
+ // This code is based on jest-axe library.
6
+ // https://github.com/nickcolley/jest-axe
7
+ export const toHaveNoIncompletes = {
8
+ toHaveNoIncompletes: (results: AxeResults) => {
9
+ if (typeof results.incomplete === 'undefined') {
10
+ throw new Error('No incompletes found in aXe results object')
11
+ }
12
+
13
+ const reporter = (incompletes: AxeResults['incomplete']) => {
14
+ if (incompletes.length === 0) {
15
+ return []
16
+ }
17
+
18
+ const lineBreak = '\n\n'
19
+ const horizontalLine = '\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
20
+
21
+ return incompletes
22
+ .map((incomplete) => {
23
+ const errorBody = incomplete.nodes
24
+ .map((node) => {
25
+ const selector = node.target.join(', ')
26
+ const expectedText = `Expected the HTML found at $('${selector}') to have no incompletes:${lineBreak}`
27
+
28
+ return `${
29
+ expectedText + chalk.grey(node.html) + lineBreak
30
+ }Received:${lineBreak}${printReceived(
31
+ `${incomplete.help} (${incomplete.id})`
32
+ )}${lineBreak}${chalk.yellow(node.failureSummary)}${lineBreak}${
33
+ incomplete.helpUrl
34
+ ? `You can find more information on this issue here: \n${chalk.blue(
35
+ incomplete.helpUrl
36
+ )}`
37
+ : ''
38
+ }`
39
+ })
40
+ .join(lineBreak)
41
+
42
+ return errorBody
43
+ })
44
+ .join(lineBreak + horizontalLine + lineBreak)
45
+ }
46
+
47
+ const { incomplete: incompletes } = results
48
+ const formatedIncompletes = reporter(incompletes)
49
+ const pass = formatedIncompletes.length === 0
50
+
51
+ const message = () => {
52
+ if (pass) {
53
+ return ''
54
+ }
55
+
56
+ return (
57
+ `${matcherHint('.toHaveNoIncompletes')}\n\n` + `${formatedIncompletes}`
58
+ )
59
+ }
60
+
61
+ return { actual: incompletes, message, pass }
62
+ },
63
+ }
64
+
65
+ declare global {
66
+ // eslint-disable-next-line
67
+ namespace jest {
68
+ interface Matchers<R, T> {
69
+ toHaveNoIncompletes(): R
70
+ }
71
+ }
72
+
73
+ // axe-core depends on a global Node
74
+ // eslint-disable-next-line
75
+ interface Node {}
76
+ }