From bd2353fbe5549a05f9fecc2b61660ba301ba986f Mon Sep 17 00:00:00 2001 From: Nandor Date: Thu, 12 Oct 2023 13:15:20 +0200 Subject: [PATCH] test(ui-breadcrumb): migrate old Breadcrumb tests Closes: INSTUI-3865 --- package-lock.json | 6 ++---- packages/ui-breadcrumb/package.json | 3 +-- .../__new-tests__/Breadcrumb.test.tsx | 19 +++++++++++++++++++ packages/ui-breadcrumb/tsconfig.build.json | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index d515ead69d..194ff848e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53863,8 +53863,7 @@ "devDependencies": { "@instructure/ui-axe-check": "8.46.0", "@instructure/ui-babel-preset": "8.46.0", - "@instructure/ui-test-locator": "8.46.0", - "@instructure/ui-test-utils": "8.46.0", + "@instructure/ui-scripts": "^8.46.0", "@instructure/ui-themes": "8.46.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^14.0.0" @@ -59600,8 +59599,7 @@ "@instructure/ui-link": "8.46.0", "@instructure/ui-prop-types": "8.46.0", "@instructure/ui-react-utils": "8.46.0", - "@instructure/ui-test-locator": "8.46.0", - "@instructure/ui-test-utils": "8.46.0", + "@instructure/ui-scripts": "^8.46.0", "@instructure/ui-testable": "8.46.0", "@instructure/ui-themes": "8.46.0", "@instructure/ui-truncate-text": "8.46.0", diff --git a/packages/ui-breadcrumb/package.json b/packages/ui-breadcrumb/package.json index 11414cc4da..da3cf26a35 100644 --- a/packages/ui-breadcrumb/package.json +++ b/packages/ui-breadcrumb/package.json @@ -24,10 +24,9 @@ "license": "MIT", "devDependencies": { "@instructure/ui-babel-preset": "8.46.0", - "@instructure/ui-test-locator": "8.46.0", - "@instructure/ui-test-utils": "8.46.0", "@instructure/ui-themes": "8.46.0", "@instructure/ui-axe-check": "8.46.0", + "@instructure/ui-scripts": "^8.46.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^14.0.0" }, diff --git a/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx b/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx index f394259a1b..6601cf3fe4 100644 --- a/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx +++ b/packages/ui-breadcrumb/src/Breadcrumb/__new-tests__/Breadcrumb.test.tsx @@ -26,8 +26,11 @@ import React from 'react' import { render, screen } from '@testing-library/react' import '@testing-library/jest-dom/extend-expect' +// eslint-disable-next-line no-restricted-imports +import { generateA11yTests } from '@instructure/ui-scripts/lib/test/generateA11yTests' import { runAxeCheck } from '@instructure/ui-axe-check' import { Breadcrumb } from '../index' +import BreadcrumbExamples from '../__examples__/Breadcrumb.examples' const TEST_LABEL = 'You are here:' const TEST_TEXT_01 = 'Account' @@ -58,6 +61,22 @@ describe('', () => { expect(axeCheck).toBe(true) }) + describe('with generated examples', () => { + const generatedComponents = generateA11yTests( + Breadcrumb, + BreadcrumbExamples + ) + + it.each(generatedComponents)( + 'should be accessible with example: $description', + async ({ content }) => { + const { container } = render(content) + const axeCheck = await runAxeCheck(container) + expect(axeCheck).toBe(true) + } + ) + }) + it('should render the label as an aria-label attribute', () => { render( diff --git a/packages/ui-breadcrumb/tsconfig.build.json b/packages/ui-breadcrumb/tsconfig.build.json index 0f5a55a596..bead86a356 100644 --- a/packages/ui-breadcrumb/tsconfig.build.json +++ b/packages/ui-breadcrumb/tsconfig.build.json @@ -8,7 +8,6 @@ "include": ["src"], "references": [ { "path": "../ui-babel-preset/tsconfig.build.json" }, - { "path": "../ui-test-utils/tsconfig.build.json" }, { "path": "../ui-themes/tsconfig.build.json" }, { "path": "../emotion/tsconfig.build.json" }, { "path": "../shared-types/tsconfig.build.json" }, @@ -20,6 +19,7 @@ { "path": "../ui-truncate-text/tsconfig.build.json" }, { "path": "../ui-utils/tsconfig.build.json" }, { "path": "../ui-view/tsconfig.build.json" }, - { "path": "../ui-axe-check/tsconfig.build.json" } + { "path": "../ui-axe-check/tsconfig.build.json" }, + { "path": "../ui-scripts/tsconfig.build.json" } ] }