@stackoverflow/stacks 2.0.9 → 2.1.0-rc.0
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/LICENSE.MD +1 -1
- package/README.md +7 -9
- package/dist/css/stacks.css +193 -206
- package/dist/css/stacks.min.css +1 -1
- package/dist/js/stacks.js +1 -1
- package/lib/components/activity-indicator/activity-indicator.a11y.test.ts +2 -3
- package/lib/components/activity-indicator/activity-indicator.visual.test.ts +2 -3
- package/lib/components/anchor/anchor.a11y.test.ts +2 -4
- package/lib/components/anchor/anchor.visual.test.ts +2 -4
- package/lib/components/avatar/avatar.a11y.test.ts +2 -3
- package/lib/components/avatar/avatar.visual.test.ts +2 -3
- package/lib/components/award-bling/award-bling.a11y.test.ts +2 -4
- package/lib/components/award-bling/award-bling.visual.test.ts +2 -4
- package/lib/components/badge/badge.a11y.test.ts +7 -16
- package/lib/components/badge/badge.visual.test.ts +8 -21
- package/lib/components/banner/banner.a11y.test.ts +2 -3
- package/lib/components/banner/banner.visual.test.ts +2 -3
- package/lib/components/block-link/block-link.a11y.test.ts +4 -9
- package/lib/components/block-link/block-link.less +7 -10
- package/lib/components/block-link/block-link.visual.test.ts +4 -9
- package/lib/components/breadcrumbs/breadcrumbs.a11y.test.ts +2 -3
- package/lib/components/breadcrumbs/breadcrumbs.visual.test.ts +2 -3
- package/lib/components/button/button.a11y.test.ts +2 -3
- package/lib/components/button/button.less +70 -35
- package/lib/components/button/button.visual.test.ts +2 -3
- package/lib/components/card/card.a11y.test.ts +2 -3
- package/lib/components/card/card.visual.test.ts +3 -6
- package/lib/components/check-control/check-control.a11y.test.ts +2 -4
- package/lib/components/check-control/check-control.visual.test.ts +2 -4
- package/lib/components/check-group/check-group.a11y.test.ts +2 -4
- package/lib/components/check-group/check-group.visual.test.ts +2 -4
- package/lib/components/checkbox_radio/checkbox_radio.a11y.test.ts +2 -4
- package/lib/components/checkbox_radio/checkbox_radio.less +1 -13
- package/lib/components/checkbox_radio/checkbox_radio.visual.test.ts +2 -4
- package/lib/components/code-block/code-block.a11y.test.ts +2 -4
- package/lib/components/code-block/code-block.visual.test.ts +2 -4
- package/lib/components/description/description.a11y.test.ts +2 -4
- package/lib/components/description/description.visual.test.ts +2 -4
- package/lib/components/empty-state/empty-state.a11y.test.ts +2 -3
- package/lib/components/empty-state/empty-state.visual.test.ts +2 -3
- package/lib/components/expandable/expandable.a11y.test.ts +2 -3
- package/lib/components/expandable/expandable.visual.test.ts +2 -3
- package/lib/components/input-fill/input-fill.a11y.test.ts +2 -3
- package/lib/components/input-fill/input-fill.visual.test.ts +2 -3
- package/lib/components/input-message/input-message.a11y.test.ts +2 -3
- package/lib/components/input-message/input-message.visual.test.ts +2 -3
- package/lib/components/input_textarea/input_textarea.a11y.test.ts +4 -7
- package/lib/components/input_textarea/input_textarea.less +2 -20
- package/lib/components/input_textarea/input_textarea.visual.test.ts +4 -7
- package/lib/components/label/label.a11y.test.ts +2 -3
- package/lib/components/label/label.visual.test.ts +2 -3
- package/lib/components/link/link.a11y.test.ts +2 -3
- package/lib/components/link/link.visual.test.ts +2 -3
- package/lib/components/link-preview/link-preview.a11y.test.ts +2 -3
- package/lib/components/link-preview/link-preview.visual.test.ts +3 -3
- package/lib/components/menu/menu.a11y.test.ts +2 -3
- package/lib/components/menu/menu.visual.test.ts +2 -3
- package/lib/components/modal/modal.a11y.test.ts +2 -3
- package/lib/components/modal/modal.visual.test.ts +2 -3
- package/lib/components/navigation/navigation.a11y.test.ts +2 -3
- package/lib/components/navigation/navigation.less +3 -1
- package/lib/components/navigation/navigation.visual.test.ts +3 -6
- package/lib/components/notice/notice.a11y.test.ts +2 -3
- package/lib/components/notice/notice.visual.test.ts +2 -3
- package/lib/components/page-title/page-title.a11y.test.ts +2 -3
- package/lib/components/page-title/page-title.visual.test.ts +2 -3
- package/lib/components/pagination/pagination.a11y.test.ts +2 -3
- package/lib/components/pagination/pagination.less +9 -0
- package/lib/components/pagination/pagination.visual.test.ts +2 -3
- package/lib/components/progress-bar/progress-bar.a11y.test.ts +7 -18
- package/lib/components/progress-bar/progress-bar.visual.test.ts +7 -18
- package/lib/components/select/select.less +1 -15
- package/lib/components/spinner/spinner.a11y.test.ts +2 -3
- package/lib/components/spinner/spinner.visual.test.ts +4 -7
- package/lib/components/table/table.a11y.test.ts +3 -4
- package/lib/components/table/table.visual.test.ts +2 -3
- package/lib/components/tag/tag.a11y.test.ts +2 -3
- package/lib/components/tag/tag.less +27 -21
- package/lib/components/tag/tag.visual.test.ts +3 -6
- package/lib/components/toast/toast.a11y.test.ts +2 -3
- package/lib/components/toast/toast.visual.test.ts +2 -3
- package/lib/components/toggle-switch/toggle-switch.a11y.test.ts +3 -6
- package/lib/components/toggle-switch/toggle-switch.less +5 -16
- package/lib/components/toggle-switch/toggle-switch.visual.test.ts +3 -7
- package/lib/components/topbar/topbar.less +61 -39
- package/lib/components/topbar/topbar.visual.test.ts +188 -0
- package/lib/components/uploader/uploader.less +1 -1
- package/lib/exports/__snapshots__/color-mixins.less.test.ts.snap +2 -0
- package/lib/exports/__snapshots__/color.less.test.ts.snap +12 -0
- package/lib/exports/color-sets.less +17 -7
- package/lib/exports/mixins.less +33 -0
- package/lib/input-utils.less +0 -3
- package/lib/test/a11y-test-utils.ts +94 -0
- package/lib/test/assertions.ts +10 -3
- package/lib/test/test-utils.ts +152 -300
- package/lib/test/visual-test-utils.ts +58 -0
- package/package.json +7 -8
- package/lib/components/popover/tooltip.visual.test.ts +0 -31
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { html, fixture } from "@open-wc/testing";
|
|
2
|
+
import { visualDiff } from "@web/test-runner-visual-regression";
|
|
3
|
+
import { screen } from "@testing-library/dom";
|
|
4
|
+
import { generateTestVariations, type TestVariationArgs } from "./test-utils";
|
|
5
|
+
|
|
6
|
+
type VisualTestArgs = TestVariationArgs;
|
|
7
|
+
|
|
8
|
+
const scheduleVisualTest = ({
|
|
9
|
+
element,
|
|
10
|
+
testid,
|
|
11
|
+
theme,
|
|
12
|
+
}: {
|
|
13
|
+
element: ReturnType<typeof html>;
|
|
14
|
+
testid: string;
|
|
15
|
+
theme: string[];
|
|
16
|
+
}) => {
|
|
17
|
+
it(`visual: ${testid} should not introduce visual regressions`, async () => {
|
|
18
|
+
document.body.className = "";
|
|
19
|
+
|
|
20
|
+
if (theme?.length) {
|
|
21
|
+
const prefixedThemes = theme.map((t) => `theme-${t}`);
|
|
22
|
+
document.body.classList.add(...prefixedThemes);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let retryAttempts = 3;
|
|
26
|
+
|
|
27
|
+
do {
|
|
28
|
+
await fixture(element);
|
|
29
|
+
const el = screen.getByTestId(testid);
|
|
30
|
+
try {
|
|
31
|
+
await visualDiff(el, testid);
|
|
32
|
+
return;
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const e = error as Error;
|
|
35
|
+
// if the error is not a visual diff failure, retry
|
|
36
|
+
// this is to prevent flaky tests due to snapshot capturing
|
|
37
|
+
if (
|
|
38
|
+
retryAttempts > 0 &&
|
|
39
|
+
!e.message.includes("Visual diff failed.")
|
|
40
|
+
) {
|
|
41
|
+
retryAttempts--;
|
|
42
|
+
continue;
|
|
43
|
+
} else {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
} finally {
|
|
47
|
+
el.remove();
|
|
48
|
+
}
|
|
49
|
+
} while (retryAttempts > 0);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const runVisualTests = (args: VisualTestArgs) => {
|
|
54
|
+
const testVariations = generateTestVariations(args);
|
|
55
|
+
testVariations.forEach(scheduleVisualTest);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { runVisualTests };
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/StackExchange/Stacks.git"
|
|
7
7
|
},
|
|
8
|
-
"version": "2.0.
|
|
8
|
+
"version": "2.1.0-rc.0",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"lib"
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"test:unit": "web-test-runner --group=unit",
|
|
28
28
|
"test:unit:watch": "web-test-runner --group=unit --watch",
|
|
29
29
|
"test:visual": "pwsh run-test-visual.ps1 npx web-test-runner --group=visual",
|
|
30
|
-
"test:visual:update": "pwsh run-test-visual.ps1 npx web-test-runner --group=visual --update-visual-baseline",
|
|
31
30
|
"test:less": "vitest run .less.test.ts",
|
|
32
31
|
"test:less:update": "npm run test:less -- -u",
|
|
33
32
|
"prepublishOnly": "npm run build",
|
|
@@ -55,8 +54,8 @@
|
|
|
55
54
|
"@types/cssbeautify": "^0.3.5",
|
|
56
55
|
"@types/less": "^3.0.6",
|
|
57
56
|
"@types/mocha": "^10.0.6",
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
59
|
-
"@typescript-eslint/parser": "^6.
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
58
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
60
59
|
"@web/dev-server-esbuild": "^1.0.1",
|
|
61
60
|
"@web/dev-server-rollup": "^0.6.1",
|
|
62
61
|
"@web/test-runner": "^0.18.0",
|
|
@@ -65,7 +64,7 @@
|
|
|
65
64
|
"apca-check": "^0.1.0",
|
|
66
65
|
"colorjs.io": "^0.4.5",
|
|
67
66
|
"concurrently": "^8.2.2",
|
|
68
|
-
"css-loader": "^6.
|
|
67
|
+
"css-loader": "^6.10.0",
|
|
69
68
|
"cssbeautify": "^0.3.1",
|
|
70
69
|
"cssnano": "^6.0.3",
|
|
71
70
|
"docsearch.js": "^2.6.3",
|
|
@@ -75,7 +74,7 @@
|
|
|
75
74
|
"eslint-config-prettier": "^9.1.0",
|
|
76
75
|
"eslint-plugin-no-unsanitized": "^4.0.2",
|
|
77
76
|
"jquery": "^3.7.1",
|
|
78
|
-
"less-loader": "^12.
|
|
77
|
+
"less-loader": "^12.2.0",
|
|
79
78
|
"list.js": "^2.3.1",
|
|
80
79
|
"markdown-it": "^14.0.0",
|
|
81
80
|
"mini-css-extract-plugin": "^2.7.7",
|
|
@@ -89,8 +88,8 @@
|
|
|
89
88
|
"terser-webpack-plugin": "^5.3.10",
|
|
90
89
|
"ts-loader": "^9.5.1",
|
|
91
90
|
"typescript": "^5.3.3",
|
|
92
|
-
"vitest": "^1.2.
|
|
93
|
-
"webpack": "^5.
|
|
91
|
+
"vitest": "^1.2.2",
|
|
92
|
+
"webpack": "^5.90.1",
|
|
94
93
|
"webpack-cli": "^5.1.4",
|
|
95
94
|
"webpack-merge": "^5.10.0"
|
|
96
95
|
},
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { html, fixture } from "@open-wc/testing";
|
|
2
|
-
import { screen } from "@testing-library/dom";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { visualDiff } from "@web/test-runner-visual-regression";
|
|
5
|
-
import "../../index";
|
|
6
|
-
|
|
7
|
-
const user = userEvent.setup();
|
|
8
|
-
|
|
9
|
-
describe("tooltip", () => {
|
|
10
|
-
it("should not introduce visual regressions", async () => {
|
|
11
|
-
const wrapper = await fixture(html`
|
|
12
|
-
<div style="height: 100px; width: 160px; display: inline-block;">
|
|
13
|
-
<button
|
|
14
|
-
class="s-btn s-btn__filled"
|
|
15
|
-
role="button"
|
|
16
|
-
data-controller="s-tooltip"
|
|
17
|
-
title="tooltip content"
|
|
18
|
-
data-s-tooltip-placement="bottom-start"
|
|
19
|
-
>
|
|
20
|
-
Hover tooltip popover
|
|
21
|
-
</button>
|
|
22
|
-
</div>
|
|
23
|
-
`);
|
|
24
|
-
|
|
25
|
-
const trigger = screen.getByRole("button");
|
|
26
|
-
await user.hover(trigger);
|
|
27
|
-
await screen.findByRole("tooltip");
|
|
28
|
-
|
|
29
|
-
await visualDiff(wrapper, "s-tooltip");
|
|
30
|
-
});
|
|
31
|
-
});
|