Skip to content

Commit 17288ff

Browse files
test(Slug): add VRT, AVT tests (carbon-design-system#15238)
* test(Slug): add VRT, AVT tests * test(Slug): test form story --------- Co-authored-by: Andrea N. Cardona <[email protected]>
1 parent 41c1f75 commit 17288ff

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright IBM Corp. 2016, 2023
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
const { expect, test } = require('@playwright/test');
11+
const { visitStory } = require('../../test-utils/storybook');
12+
13+
test.describe('Slug @avt', () => {
14+
test('@avt-default-state', async ({ page }) => {
15+
await visitStory(page, {
16+
component: 'Slug',
17+
id: 'experimental-unstable-slug--default',
18+
globals: {
19+
theme: 'white',
20+
},
21+
});
22+
await expect(page).toHaveNoACViolations('Slug');
23+
});
24+
25+
test('@avt-advanced-states open state', async ({ page }) => {
26+
await visitStory(page, {
27+
component: 'Slug',
28+
id: 'experimental-unstable-slug--default',
29+
globals: {
30+
theme: 'white',
31+
},
32+
});
33+
await page.keyboard.press('Tab');
34+
await page.keyboard.press('Tab');
35+
await page.keyboard.press('Tab');
36+
await page.keyboard.press('Enter');
37+
await expect(page).toHaveNoACViolations('Slug-open');
38+
});
39+
40+
test('@avt-advanced-states ai form', async ({ page }) => {
41+
await visitStory(page, {
42+
component: 'Slug',
43+
id: 'components-form--ai-form',
44+
globals: {
45+
theme: 'white',
46+
},
47+
});
48+
await expect(page).toHaveNoACViolations('Slug-form');
49+
});
50+
});

e2e/components/Slug/Slug-test.e2e.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright IBM Corp. 2016, 2023
3+
*
4+
* This source code is licensed under the Apache-2.0 license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
const { test } = require('@playwright/test'); // eslint-disable-line
11+
const { themes } = require('../../test-utils/env');
12+
const { snapshotStory } = require('../../test-utils/storybook'); // eslint-disable-line
13+
14+
test.describe('Slug', () => {
15+
themes.forEach((theme) => {
16+
test.describe(theme, () => {
17+
test('default @vrt', async ({ page }) => {
18+
await snapshotStory(page, {
19+
component: 'Slug',
20+
id: 'experimental-unstable-slug--default',
21+
theme,
22+
});
23+
});
24+
25+
test('slug inside form @vrt', async ({ page }) => {
26+
await snapshotStory(page, {
27+
component: 'Slug',
28+
id: 'components-form--ai-form',
29+
theme,
30+
});
31+
});
32+
});
33+
});
34+
});

packages/react/src/components/Slug/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ export const Slug = React.forwardRef(function Slug(
125125
}
126126
};
127127

128-
const ariaLabel = `${aiText} - ${slugLabel}`;
128+
const ariaLabel = !aiTextLabel
129+
? `${aiText} - ${slugLabel}`
130+
: `${aiText} - ${aiTextLabel}`;
129131

130132
return (
131133
<div className={slugClasses} ref={ref} id={id}>

0 commit comments

Comments
 (0)