Skip to content

Commit bd4b170

Browse files
committed
test(ui-progress): migrate old Progress tests
Closes: INSTUI-4354
1 parent 732a151 commit bd4b170

File tree

9 files changed

+55
-152
lines changed

9 files changed

+55
-152
lines changed

package-lock.json

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ui-progress/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@
3535
"prop-types": "^15.8.1"
3636
},
3737
"devDependencies": {
38+
"@instructure/ui-axe-check": "10.6.0",
3839
"@instructure/ui-babel-preset": "10.6.0",
39-
"@instructure/ui-test-locator": "10.6.0",
4040
"@instructure/ui-test-utils": "10.6.0",
41-
"@instructure/ui-themes": "10.6.0"
41+
"@instructure/ui-themes": "10.6.0",
42+
"@testing-library/jest-dom": "^6.4.6",
43+
"@testing-library/react": "^16.0.1",
44+
"vitest": "^2.1.1"
4245
},
4346
"peerDependencies": {
4447
"react": ">=16.8 <=18"

packages/ui-progress/src/ProgressBar/ProgressBarLocator.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/ui-progress/src/ProgressBar/__tests__/ProgressBar.test.tsx renamed to packages/ui-progress/src/ProgressBar/__new-tests__/ProgressBar.test.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,60 +23,64 @@
2323
*/
2424

2525
import React from 'react'
26-
import { expect, mount } from '@instructure/ui-test-utils'
26+
import { render } from '@testing-library/react'
2727

28+
import '@testing-library/jest-dom'
29+
import { runAxeCheck } from '@instructure/ui-axe-check'
2830
import { ProgressBar } from '../index'
29-
import { ProgressBarLocator } from '../ProgressBarLocator'
3031

31-
describe('<ProgressBar />', async () => {
32+
describe('<ProgressBar />', () => {
3233
it('should render', async () => {
33-
await mount(
34+
const { container } = render(
3435
<ProgressBar
3536
screenReaderLabel="Chapters read"
3637
valueMax={60}
3738
valueNow={30}
3839
/>
3940
)
40-
expect(await ProgressBarLocator.find()).to.exist()
41+
const progress = container.querySelector('progress')
42+
43+
expect(progress).toBeInTheDocument()
4144
})
4245

4346
it('should render a progress element with correct aria attributes', async () => {
44-
await mount(
47+
const { container } = render(
4548
<ProgressBar
4649
screenReaderLabel="Chapters read"
4750
valueMax={60}
4851
valueNow={30}
4952
/>
5053
)
54+
const progress = container.querySelector('progress')
5155

52-
const componentRoot = await ProgressBarLocator.find()
53-
const progress = await componentRoot.find('progress')
54-
55-
expect(progress).to.exist()
56-
expect(progress.getAttribute('value')).to.equal('30')
56+
expect(progress).toHaveAttribute('value', '30')
5757
})
5858

5959
it('should format the displayed text', async () => {
60-
await mount(
60+
const current = 30
61+
const max = 60
62+
const { container } = render(
6163
<ProgressBar
6264
screenReaderLabel="Chapters read"
63-
valueMax={60}
64-
valueNow={30}
65+
valueMax={max}
66+
valueNow={current}
6567
renderValue={({ valueNow, valueMax }) => `${valueNow} of ${valueMax}`}
6668
/>
6769
)
68-
expect(await ProgressBarLocator.find(':contains(30 of 60)')).to.exist()
70+
const progress = container.querySelector('[class$="-progressBar"]')
71+
72+
expect(progress).toHaveTextContent(`${current} of ${max}`)
6973
})
7074

7175
it('should meet a11y standards', async () => {
72-
await mount(
76+
const { container } = render(
7377
<ProgressBar
7478
screenReaderLabel="Chapters read"
7579
valueMax={60}
7680
valueNow={30}
7781
/>
7882
)
79-
const progress = await ProgressBarLocator.find()
80-
expect(await progress.accessible()).to.be.true()
83+
const axeCheck = await runAxeCheck(container)
84+
expect(axeCheck).toBe(true)
8185
})
8286
})

packages/ui-progress/src/ProgressBar/locator.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/ui-progress/src/ProgressCircle/ProgressCircleLocator.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/ui-progress/src/ProgressCircle/__tests__/ProgressCircle.test.tsx renamed to packages/ui-progress/src/ProgressCircle/__new-tests__/ProgressCircle.test.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,60 +23,64 @@
2323
*/
2424

2525
import React from 'react'
26-
import { expect, mount } from '@instructure/ui-test-utils'
26+
import { render } from '@testing-library/react'
2727

28+
import '@testing-library/jest-dom'
29+
import { runAxeCheck } from '@instructure/ui-axe-check'
2830
import { ProgressCircle } from '../index'
29-
import { ProgressCircleLocator } from '../ProgressCircleLocator'
3031

31-
describe('<ProgressCircle />', async () => {
32+
describe('<ProgressCircle />', () => {
3233
it('should render', async () => {
33-
await mount(
34+
const { container } = render(
3435
<ProgressCircle
3536
screenReaderLabel="Chapters read"
3637
valueMax={60}
3738
valueNow={30}
3839
/>
3940
)
40-
expect(await ProgressCircleLocator.find()).to.exist()
41+
const progress = container.querySelector('progress')
42+
43+
expect(progress).toBeInTheDocument()
4144
})
4245

4346
it('should render a progress element with correct aria attributes', async () => {
44-
await mount(
47+
const { container } = render(
4548
<ProgressCircle
4649
screenReaderLabel="Chapters read"
4750
valueMax={60}
4851
valueNow={30}
4952
/>
5053
)
54+
const progress = container.querySelector('progress')
5155

52-
const componentRoot = await ProgressCircleLocator.find()
53-
const progress = await componentRoot.find('progress')
54-
55-
expect(progress).to.exist()
56-
expect(progress.getAttribute('value')).to.equal('30')
56+
expect(progress).toHaveAttribute('value', '30')
5757
})
5858

5959
it('should format the displayed text', async () => {
60-
await mount(
60+
const current = 30
61+
const max = 60
62+
const { container } = render(
6163
<ProgressCircle
6264
screenReaderLabel="Chapters read"
63-
valueMax={60}
64-
valueNow={30}
65+
valueMax={max}
66+
valueNow={current}
6567
renderValue={({ valueNow, valueMax }) => `${valueNow} of ${valueMax}`}
6668
/>
6769
)
68-
expect(await ProgressCircleLocator.find(':contains(30 of 60)')).to.exist()
70+
const progress = container.querySelector('[class$="-progressCircle"]')
71+
72+
expect(progress).toHaveTextContent(`${current} of ${max}`)
6973
})
7074

7175
it('should meet a11y standards', async () => {
72-
await mount(
76+
const { container } = render(
7377
<ProgressCircle
7478
screenReaderLabel="Chapters read"
7579
valueMax={60}
7680
valueNow={30}
7781
/>
7882
)
79-
const progress = await ProgressCircleLocator.find()
80-
expect(await progress.accessible()).to.be.true()
83+
const axeCheck = await runAxeCheck(container)
84+
expect(axeCheck).toBe(true)
8185
})
8286
})

packages/ui-progress/src/ProgressCircle/locator.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/ui-progress/tsconfig.build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
{ "path": "../emotion/tsconfig.build.json" },
1212
{ "path": "../shared-types/tsconfig.build.json" },
1313
{ "path": "../ui-a11y-content/tsconfig.build.json" },
14+
{ "path": "../ui-axe-check/tsconfig.build.json" },
1415
{ "path": "../ui-color-utils/tsconfig.build.json" },
1516
{ "path": "../ui-react-utils/tsconfig.build.json" },
1617
{ "path": "../ui-testable/tsconfig.build.json" },

0 commit comments

Comments
 (0)