@stackoverflow/stacks 2.4.0 → 2.5.1
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/dist/css/stacks.css +24 -65
- package/dist/css/stacks.min.css +1 -1
- package/lib/components/tag/tag.less +21 -68
- package/lib/exports/color-sets.less +4 -4
- package/package.json +10 -9
- package/lib/atomic/__snapshots__/color-new.less.test.ts.snap +0 -3015
- package/lib/atomic/__snapshots__/color.less.test.ts.snap +0 -3132
- package/lib/atomic/__snapshots__/misc.less.test.ts.snap +0 -893
- package/lib/atomic/__snapshots__/spacing.less.test.ts.snap +0 -1928
- package/lib/atomic/color.less.test.ts +0 -12
- package/lib/atomic/misc.less.test.ts +0 -12
- package/lib/atomic/spacing.less.test.ts +0 -12
- package/lib/components/activity-indicator/activity-indicator.a11y.test.ts +0 -13
- package/lib/components/activity-indicator/activity-indicator.visual.test.ts +0 -22
- package/lib/components/anchor/anchor.a11y.test.ts +0 -35
- package/lib/components/anchor/anchor.visual.test.ts +0 -47
- package/lib/components/avatar/avatar.a11y.test.ts +0 -35
- package/lib/components/avatar/avatar.visual.test.ts +0 -50
- package/lib/components/award-bling/award-bling.a11y.test.ts +0 -15
- package/lib/components/award-bling/award-bling.visual.test.ts +0 -24
- package/lib/components/badge/badge.a11y.test.ts +0 -143
- package/lib/components/badge/badge.visual.test.ts +0 -165
- package/lib/components/banner/banner.a11y.test.ts +0 -36
- package/lib/components/banner/banner.test.ts +0 -73
- package/lib/components/banner/banner.visual.test.ts +0 -36
- package/lib/components/block-link/block-link.a11y.test.ts +0 -57
- package/lib/components/block-link/block-link.visual.test.ts +0 -57
- package/lib/components/breadcrumbs/breadcrumbs.a11y.test.ts +0 -36
- package/lib/components/breadcrumbs/breadcrumbs.visual.test.ts +0 -36
- package/lib/components/button/button.a11y.test.ts +0 -21
- package/lib/components/button/button.test.setup.ts +0 -36
- package/lib/components/button/button.visual.test.ts +0 -18
- package/lib/components/button-group/button-group.a11y.test.ts +0 -12
- package/lib/components/button-group/button-group.test.setup.ts +0 -77
- package/lib/components/button-group/button-group.visual.test.ts +0 -7
- package/lib/components/card/card.a11y.test.ts +0 -12
- package/lib/components/card/card.visual.test.ts +0 -52
- package/lib/components/check-control/check-control.a11y.test.ts +0 -33
- package/lib/components/check-control/check-control.visual.test.ts +0 -36
- package/lib/components/check-group/check-group.a11y.test.ts +0 -49
- package/lib/components/check-group/check-group.visual.test.ts +0 -56
- package/lib/components/checkbox_radio/checkbox_radio.a11y.test.ts +0 -37
- package/lib/components/checkbox_radio/checkbox_radio.visual.test.ts +0 -33
- package/lib/components/code-block/code-block.a11y.test.ts +0 -27
- package/lib/components/code-block/code-block.visual.test.ts +0 -18
- package/lib/components/description/description.a11y.test.ts +0 -28
- package/lib/components/description/description.visual.test.ts +0 -28
- package/lib/components/empty-state/empty-state.a11y.test.ts +0 -16
- package/lib/components/empty-state/empty-state.visual.test.ts +0 -16
- package/lib/components/expandable/expandable.a11y.test.ts +0 -26
- package/lib/components/expandable/expandable.test.ts +0 -51
- package/lib/components/expandable/expandable.visual.test.ts +0 -26
- package/lib/components/input-fill/input-fill.a11y.test.ts +0 -21
- package/lib/components/input-fill/input-fill.visual.test.ts +0 -21
- package/lib/components/input-icon/input-icon.a11y.test.ts +0 -81
- package/lib/components/input-icon/input-icon.visual.test.ts +0 -92
- package/lib/components/input-message/input-message.a11y.test.ts +0 -57
- package/lib/components/input-message/input-message.visual.test.ts +0 -58
- package/lib/components/input_textarea/input_textarea.a11y.test.ts +0 -109
- package/lib/components/input_textarea/input_textarea.visual.test.ts +0 -95
- package/lib/components/label/label.a11y.test.ts +0 -47
- package/lib/components/label/label.visual.test.ts +0 -65
- package/lib/components/link/link.a11y.test.ts +0 -27
- package/lib/components/link/link.visual.test.ts +0 -31
- package/lib/components/link-preview/link-preview.a11y.test.ts +0 -47
- package/lib/components/link-preview/link-preview.visual.test.ts +0 -52
- package/lib/components/menu/menu.a11y.test.ts +0 -39
- package/lib/components/menu/menu.visual.test.ts +0 -39
- package/lib/components/modal/modal.a11y.test.ts +0 -41
- package/lib/components/modal/modal.test.ts +0 -155
- package/lib/components/modal/modal.visual.test.ts +0 -41
- package/lib/components/navigation/navigation.a11y.test.ts +0 -81
- package/lib/components/navigation/navigation.visual.test.ts +0 -98
- package/lib/components/notice/notice.a11y.test.ts +0 -16
- package/lib/components/notice/notice.visual.test.ts +0 -25
- package/lib/components/page-title/page-title.a11y.test.ts +0 -28
- package/lib/components/page-title/page-title.visual.test.ts +0 -58
- package/lib/components/pagination/pagination.a11y.test.ts +0 -21
- package/lib/components/pagination/pagination.visual.test.ts +0 -25
- package/lib/components/popover/tooltip.test.ts +0 -62
- package/lib/components/post-summary/post-summary.a11y.test.ts +0 -25
- package/lib/components/post-summary/post-summary.test.setup.ts +0 -435
- package/lib/components/post-summary/post-summary.visual.test.ts +0 -17
- package/lib/components/progress-bar/progress-bar.a11y.test.ts +0 -189
- package/lib/components/progress-bar/progress-bar.visual.test.ts +0 -188
- package/lib/components/select/select.a11y.test.ts +0 -72
- package/lib/components/select/select.visual.test.ts +0 -72
- package/lib/components/spinner/spinner.a11y.test.ts +0 -14
- package/lib/components/spinner/spinner.visual.test.ts +0 -40
- package/lib/components/table/table.a11y.test.ts +0 -112
- package/lib/components/table/table.test.ts +0 -366
- package/lib/components/table/table.visual.test.ts +0 -104
- package/lib/components/tag/tag.a11y.test.ts +0 -28
- package/lib/components/tag/tag.visual.test.ts +0 -43
- package/lib/components/toast/toast.a11y.test.ts +0 -29
- package/lib/components/toast/toast.test.ts +0 -64
- package/lib/components/toast/toast.visual.test.ts +0 -30
- package/lib/components/toggle-switch/toggle-switch.a11y.test.ts +0 -66
- package/lib/components/toggle-switch/toggle-switch.visual.test.ts +0 -70
- package/lib/components/topbar/topbar.visual.test.ts +0 -217
- package/lib/exports/__snapshots__/color-mixins.less.test.ts.snap +0 -558
- package/lib/exports/__snapshots__/color.less.test.ts.snap +0 -819
- package/lib/exports/color-mixins.less.test.ts +0 -150
- package/lib/exports/color.less.test.ts +0 -12
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import { assert, expect, fixture, html } from "@open-wc/testing";
|
|
2
|
-
import { screen } from "@testing-library/dom";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { buildIndex, getCellSlot, SortOrder } from "./table";
|
|
5
|
-
import "../../index";
|
|
6
|
-
import { AsLiterals } from "../../test/test-utils";
|
|
7
|
-
|
|
8
|
-
const user = userEvent.setup();
|
|
9
|
-
|
|
10
|
-
const iconData = [
|
|
11
|
-
{
|
|
12
|
-
direction: "asc",
|
|
13
|
-
classes: "iconArrowUpSm js-sorting-indicator-asc d-none",
|
|
14
|
-
pathD: "M3 9h8L7 5 3 9Z",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
direction: "desc",
|
|
18
|
-
classes: "iconArrowDownSm js-sorting-indicator-desc d-none",
|
|
19
|
-
pathD: "M3 5h8L7 9 3 5Z",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
direction: "none",
|
|
23
|
-
classes: "iconArrowUpDownSm js-sorting-indicator-none",
|
|
24
|
-
pathD: "m7 2 4 4H3l4-4Zm0 10 4-4H3l4 4Z",
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const sortDirectionIcons = (modifier: string) =>
|
|
29
|
-
iconData.map(
|
|
30
|
-
(icon) => html`
|
|
31
|
-
<svg
|
|
32
|
-
data-testid="test-sortable-${modifier}-svg-${icon.direction}"
|
|
33
|
-
aria-hidden="true"
|
|
34
|
-
class="svg-icon js-sorting-indicator ${icon.classes}"
|
|
35
|
-
width="14"
|
|
36
|
-
height="14"
|
|
37
|
-
viewBox="0 0 14 14"
|
|
38
|
-
>
|
|
39
|
-
<path d="${icon.pathD}"></path>
|
|
40
|
-
</svg>
|
|
41
|
-
`
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const getTh = (label: string, modifier: string, useButton: boolean) =>
|
|
45
|
-
useButton
|
|
46
|
-
? html`
|
|
47
|
-
<th
|
|
48
|
-
data-s-table-target="column"
|
|
49
|
-
data-testid="test-sortable-${modifier}-col"
|
|
50
|
-
>
|
|
51
|
-
<button
|
|
52
|
-
data-action="click->s-table#sort"
|
|
53
|
-
data-testid="test-sortable-${modifier}-btn"
|
|
54
|
-
>
|
|
55
|
-
${label} ${sortDirectionIcons(modifier)}
|
|
56
|
-
</button>
|
|
57
|
-
</th>
|
|
58
|
-
`
|
|
59
|
-
: html`
|
|
60
|
-
<th
|
|
61
|
-
data-s-table-target="column"
|
|
62
|
-
data-action="click->s-table#sort"
|
|
63
|
-
data-testid="test-sortable-${modifier}-col"
|
|
64
|
-
>
|
|
65
|
-
${label} ${sortDirectionIcons(modifier)}
|
|
66
|
-
</th>
|
|
67
|
-
`;
|
|
68
|
-
|
|
69
|
-
const mockSortableTable = (useButton: boolean) => {
|
|
70
|
-
return html`
|
|
71
|
-
<div class="s-table-container" data-testid="test-sortable-table">
|
|
72
|
-
<table class="s-table s-table__sortable" data-controller="s-table">
|
|
73
|
-
<thead>
|
|
74
|
-
<tr>
|
|
75
|
-
${getTh("Season", "season", useButton)}
|
|
76
|
-
${getTh("Month", "month", useButton)}
|
|
77
|
-
${getTh("Temperature", "temp", useButton)}
|
|
78
|
-
</tr>
|
|
79
|
-
</thead>
|
|
80
|
-
<tbody>
|
|
81
|
-
<tr>
|
|
82
|
-
<td>Winter</td>
|
|
83
|
-
<td data-s-table-sort-val="12">December</td>
|
|
84
|
-
<td>2</td>
|
|
85
|
-
</tr>
|
|
86
|
-
<tr>
|
|
87
|
-
<td>Spring</td>
|
|
88
|
-
<td data-s-table-sort-val="3">March</td>
|
|
89
|
-
<td>13</td>
|
|
90
|
-
</tr>
|
|
91
|
-
<tr>
|
|
92
|
-
<td>Summer</td>
|
|
93
|
-
<td data-s-table-sort-val="6">June</td>
|
|
94
|
-
<td>25</td>
|
|
95
|
-
</tr>
|
|
96
|
-
<tr>
|
|
97
|
-
<td>Fall</td>
|
|
98
|
-
<td data-s-table-sort-val="9">September</td>
|
|
99
|
-
<td>13</td>
|
|
100
|
-
</tr>
|
|
101
|
-
<tr data-s-table-sort-to="bottom" class="fw-bold">
|
|
102
|
-
<td colspan="2">Average temperature</td>
|
|
103
|
-
<td>13</td>
|
|
104
|
-
</tr>
|
|
105
|
-
</tbody>
|
|
106
|
-
</table>
|
|
107
|
-
</div>
|
|
108
|
-
`;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
describe("s-table", () => {
|
|
112
|
-
// Current, legacy markup
|
|
113
|
-
[true, false].forEach((useButton) => {
|
|
114
|
-
describe(`Column sorting indicators${
|
|
115
|
-
useButton ? "" : " (legacy markup)"
|
|
116
|
-
}`, () => {
|
|
117
|
-
const allColIds = [
|
|
118
|
-
"test-sortable-season-col",
|
|
119
|
-
"test-sortable-month-col",
|
|
120
|
-
"test-sortable-temp-col",
|
|
121
|
-
] as const;
|
|
122
|
-
type ColId = AsLiterals<typeof allColIds>;
|
|
123
|
-
|
|
124
|
-
const allSvgIds = [
|
|
125
|
-
"test-sortable-season-svg-asc",
|
|
126
|
-
"test-sortable-season-svg-desc",
|
|
127
|
-
"test-sortable-season-svg-none",
|
|
128
|
-
"test-sortable-month-svg-asc",
|
|
129
|
-
"test-sortable-month-svg-desc",
|
|
130
|
-
"test-sortable-month-svg-none",
|
|
131
|
-
"test-sortable-temp-svg-asc",
|
|
132
|
-
"test-sortable-temp-svg-desc",
|
|
133
|
-
"test-sortable-temp-svg-none",
|
|
134
|
-
] as const;
|
|
135
|
-
type SvgId = AsLiterals<typeof allSvgIds>;
|
|
136
|
-
|
|
137
|
-
const expectThisColumnToBeSorted = (
|
|
138
|
-
columnId?: ColId,
|
|
139
|
-
order?: SortOrder
|
|
140
|
-
) => {
|
|
141
|
-
allColIds.forEach((colId) => {
|
|
142
|
-
const columnEl = screen.getByTestId(colId);
|
|
143
|
-
|
|
144
|
-
if (columnId === colId) {
|
|
145
|
-
expect(columnEl).to.have.attribute("aria-sort", order);
|
|
146
|
-
} else {
|
|
147
|
-
expect(columnEl).to.not.have.attribute("aria-sort");
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const expectTheseIndicatorsToBeVisible = (visibleIds: SvgId[]) => {
|
|
153
|
-
allSvgIds.forEach((svgId) => {
|
|
154
|
-
const svgEl = screen.getByTestId(svgId);
|
|
155
|
-
|
|
156
|
-
if (visibleIds.includes(svgId)) {
|
|
157
|
-
expect(svgEl).to.not.have.class("d-none");
|
|
158
|
-
} else {
|
|
159
|
-
expect(svgEl).to.have.class("d-none");
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
beforeEach(async () => {
|
|
165
|
-
await fixture(mockSortableTable(useButton));
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should start toggle correctly between ASC/DESC after initial click", async () => {
|
|
169
|
-
const seasonColumn = useButton
|
|
170
|
-
? screen.getByTestId("test-sortable-season-btn")
|
|
171
|
-
: screen.getByTestId("test-sortable-season-col");
|
|
172
|
-
|
|
173
|
-
// Starting off in a fresh state, the "None" SVG icon should be visible
|
|
174
|
-
expectThisColumnToBeSorted();
|
|
175
|
-
expectTheseIndicatorsToBeVisible([
|
|
176
|
-
"test-sortable-season-svg-none",
|
|
177
|
-
"test-sortable-month-svg-none",
|
|
178
|
-
"test-sortable-temp-svg-none",
|
|
179
|
-
]);
|
|
180
|
-
|
|
181
|
-
// Cycle through all season sort options
|
|
182
|
-
await user.click(seasonColumn);
|
|
183
|
-
expectThisColumnToBeSorted(
|
|
184
|
-
"test-sortable-season-col",
|
|
185
|
-
SortOrder.Ascending
|
|
186
|
-
);
|
|
187
|
-
expectTheseIndicatorsToBeVisible([
|
|
188
|
-
"test-sortable-season-svg-asc",
|
|
189
|
-
"test-sortable-month-svg-none",
|
|
190
|
-
"test-sortable-temp-svg-none",
|
|
191
|
-
]);
|
|
192
|
-
|
|
193
|
-
await user.click(seasonColumn);
|
|
194
|
-
expectThisColumnToBeSorted(
|
|
195
|
-
"test-sortable-season-col",
|
|
196
|
-
SortOrder.Descending
|
|
197
|
-
);
|
|
198
|
-
expectTheseIndicatorsToBeVisible([
|
|
199
|
-
"test-sortable-season-svg-desc",
|
|
200
|
-
"test-sortable-month-svg-none",
|
|
201
|
-
"test-sortable-temp-svg-none",
|
|
202
|
-
]);
|
|
203
|
-
|
|
204
|
-
// Clicking on a sorted column repeatedly will only toggle between ASC/DESC
|
|
205
|
-
await user.click(seasonColumn);
|
|
206
|
-
expectThisColumnToBeSorted(
|
|
207
|
-
"test-sortable-season-col",
|
|
208
|
-
SortOrder.Ascending
|
|
209
|
-
);
|
|
210
|
-
expectTheseIndicatorsToBeVisible([
|
|
211
|
-
"test-sortable-season-svg-asc",
|
|
212
|
-
"test-sortable-month-svg-none",
|
|
213
|
-
"test-sortable-temp-svg-none",
|
|
214
|
-
]);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('should toggle back a column indicator to "None" when another column is clicked', async () => {
|
|
218
|
-
const seasonColumn = useButton
|
|
219
|
-
? screen.getByTestId("test-sortable-season-btn")
|
|
220
|
-
: screen.getByTestId("test-sortable-season-col");
|
|
221
|
-
const monthColumn = useButton
|
|
222
|
-
? screen.getByTestId("test-sortable-month-btn")
|
|
223
|
-
: screen.getByTestId("test-sortable-month-col");
|
|
224
|
-
|
|
225
|
-
// Starting off in a fresh state, the "None" SVG icon should be visible
|
|
226
|
-
expectThisColumnToBeSorted();
|
|
227
|
-
expectTheseIndicatorsToBeVisible([
|
|
228
|
-
"test-sortable-season-svg-none",
|
|
229
|
-
"test-sortable-month-svg-none",
|
|
230
|
-
"test-sortable-temp-svg-none",
|
|
231
|
-
]);
|
|
232
|
-
|
|
233
|
-
// Click season first; ASC indicator for Season column only should be visible
|
|
234
|
-
await user.click(seasonColumn);
|
|
235
|
-
expectThisColumnToBeSorted(
|
|
236
|
-
"test-sortable-season-col",
|
|
237
|
-
SortOrder.Ascending
|
|
238
|
-
);
|
|
239
|
-
expectTheseIndicatorsToBeVisible([
|
|
240
|
-
"test-sortable-season-svg-asc",
|
|
241
|
-
"test-sortable-month-svg-none",
|
|
242
|
-
"test-sortable-temp-svg-none",
|
|
243
|
-
]);
|
|
244
|
-
|
|
245
|
-
// Click on month next
|
|
246
|
-
await user.click(monthColumn);
|
|
247
|
-
expectThisColumnToBeSorted(
|
|
248
|
-
"test-sortable-month-col",
|
|
249
|
-
SortOrder.Ascending
|
|
250
|
-
);
|
|
251
|
-
expectTheseIndicatorsToBeVisible([
|
|
252
|
-
"test-sortable-season-svg-none",
|
|
253
|
-
"test-sortable-month-svg-asc",
|
|
254
|
-
"test-sortable-temp-svg-none",
|
|
255
|
-
]);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
describe("Helper functions", () => {
|
|
261
|
-
describe("buildIndex()", () => {
|
|
262
|
-
it("should make references to individual cells that use `colspan`", async () => {
|
|
263
|
-
const table = await fixture<HTMLTableElement>(html`
|
|
264
|
-
<table>
|
|
265
|
-
<tbody>
|
|
266
|
-
<tr>
|
|
267
|
-
<td>Fall</td>
|
|
268
|
-
<td>September</td>
|
|
269
|
-
<td>13</td>
|
|
270
|
-
</tr>
|
|
271
|
-
<tr>
|
|
272
|
-
<td colspan="2">Winter</td>
|
|
273
|
-
<td>10</td>
|
|
274
|
-
</tr>
|
|
275
|
-
<tr>
|
|
276
|
-
<td>Spring</td>
|
|
277
|
-
<td colspan="2">April</td>
|
|
278
|
-
</tr>
|
|
279
|
-
</tbody>
|
|
280
|
-
</table>
|
|
281
|
-
`);
|
|
282
|
-
|
|
283
|
-
expect(table.tBodies).to.have.length(1);
|
|
284
|
-
|
|
285
|
-
const tableBody = table.tBodies[0];
|
|
286
|
-
const tableIndex = buildIndex(tableBody);
|
|
287
|
-
|
|
288
|
-
expect(tableIndex).to.satisfy((rows: typeof tableIndex) =>
|
|
289
|
-
rows.every((row) => row.length === 3)
|
|
290
|
-
);
|
|
291
|
-
await expect(tableIndex[1][0]).to.equal(
|
|
292
|
-
tableIndex[1][1],
|
|
293
|
-
"the Winter cell is expected to be referenced twice in this index"
|
|
294
|
-
);
|
|
295
|
-
await expect(tableIndex[2][1]).to.equal(
|
|
296
|
-
tableIndex[2][2],
|
|
297
|
-
"the April cell is expected to be referenced twice in this index"
|
|
298
|
-
);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it("should make references to individual cells that use `rowspan`", async () => {
|
|
302
|
-
const table = await fixture<HTMLTableElement>(html`
|
|
303
|
-
<table>
|
|
304
|
-
<tbody>
|
|
305
|
-
<tr>
|
|
306
|
-
<td rowspan="2">Fall</td>
|
|
307
|
-
<td>September</td>
|
|
308
|
-
<td>13</td>
|
|
309
|
-
</tr>
|
|
310
|
-
<tr>
|
|
311
|
-
<td>October</td>
|
|
312
|
-
<td>20</td>
|
|
313
|
-
</tr>
|
|
314
|
-
<tr>
|
|
315
|
-
<td rowspan="2">Spring</td>
|
|
316
|
-
<td>April</td>
|
|
317
|
-
<td>46</td>
|
|
318
|
-
</tr>
|
|
319
|
-
<tr>
|
|
320
|
-
<td>October</td>
|
|
321
|
-
<td>20</td>
|
|
322
|
-
</tr>
|
|
323
|
-
</tbody>
|
|
324
|
-
</table>
|
|
325
|
-
`);
|
|
326
|
-
|
|
327
|
-
expect(table.tBodies).to.have.length(1);
|
|
328
|
-
|
|
329
|
-
const tableBody = table.tBodies[0];
|
|
330
|
-
const tableIndex = buildIndex(tableBody);
|
|
331
|
-
|
|
332
|
-
expect(tableIndex).to.satisfy((rows: typeof tableIndex) =>
|
|
333
|
-
rows.every((row) => row.length === 3)
|
|
334
|
-
);
|
|
335
|
-
await expect(tableIndex[1][0]).to.equal(
|
|
336
|
-
tableIndex[0][0],
|
|
337
|
-
"the Fall cell is expected to be referenced twice across multiple rows"
|
|
338
|
-
);
|
|
339
|
-
await expect(tableIndex[3][0]).to.equal(
|
|
340
|
-
tableIndex[2][0],
|
|
341
|
-
"the Spring cell is expected to be referenced twice in this index"
|
|
342
|
-
);
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
describe("getCellSlot()", () => {
|
|
347
|
-
it("should correctly calculate the column number for each button", async () => {
|
|
348
|
-
await fixture(mockSortableTable(true));
|
|
349
|
-
|
|
350
|
-
[
|
|
351
|
-
"test-sortable-season-btn",
|
|
352
|
-
"test-sortable-month-btn",
|
|
353
|
-
"test-sortable-temp-btn",
|
|
354
|
-
].forEach((testID, index) => {
|
|
355
|
-
const buttonElement = screen.getByTestId(testID);
|
|
356
|
-
const columnCell = buttonElement.parentElement;
|
|
357
|
-
|
|
358
|
-
assert.isNotNull(columnCell);
|
|
359
|
-
assert.instanceOf(columnCell, HTMLTableCellElement);
|
|
360
|
-
|
|
361
|
-
void expect(getCellSlot(columnCell)).to.equal(index);
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { html } from "@open-wc/testing";
|
|
2
|
-
import { runVisualTests } from "../../test/visual-test-utils";
|
|
3
|
-
import "../../index";
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
const template = ({ component, testid }: any) => html`
|
|
7
|
-
<div class="s-table-container p8" data-testid="${testid}">${component}</div>
|
|
8
|
-
`;
|
|
9
|
-
|
|
10
|
-
const rows = [
|
|
11
|
-
{
|
|
12
|
-
displayName: "Sponge",
|
|
13
|
-
fullName: "Bobby Geometrislacks",
|
|
14
|
-
progress: 10,
|
|
15
|
-
active: true,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
displayName: "Patty",
|
|
19
|
-
fullName: "Pat Supernova",
|
|
20
|
-
progress: 50,
|
|
21
|
-
active: true,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
displayName: "Crustoph",
|
|
25
|
-
fullName: "Eugene Harold K",
|
|
26
|
-
progress: 75,
|
|
27
|
-
active: false,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
displayName: "SCheeks",
|
|
31
|
-
fullName: "Sandra C.",
|
|
32
|
-
progress: 100,
|
|
33
|
-
active: true,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
const children = {
|
|
38
|
-
default: `
|
|
39
|
-
<thead>
|
|
40
|
-
<tr>
|
|
41
|
-
<th scope="col" class="s-table--bulk">
|
|
42
|
-
<label class="v-visible-sr" for="check">bulk action</label>
|
|
43
|
-
<input type="checkbox" class="s-checkbox" id="check">
|
|
44
|
-
</th>
|
|
45
|
-
<th scope="col">Display Name</th>
|
|
46
|
-
<th scope="col">Full name</th>
|
|
47
|
-
<th scope="col" colspan="2">Progress</th>
|
|
48
|
-
<th scope="col"><span>class="v-visible-sr">Bar</span></th>
|
|
49
|
-
</tr>
|
|
50
|
-
</thead>
|
|
51
|
-
<tbody>
|
|
52
|
-
${rows
|
|
53
|
-
.map(
|
|
54
|
-
(row, i) => `
|
|
55
|
-
<tr class="${row.active ? "" : "is-disabled"}">
|
|
56
|
-
<th scope="row">
|
|
57
|
-
<label class="v-visible-sr" for="check-${i}">bulk</label>
|
|
58
|
-
<input type="checkbox" class="s-checkbox" id="check-${i}">
|
|
59
|
-
</th>
|
|
60
|
-
<td>${row.displayName}</td>
|
|
61
|
-
<td>${row.fullName}</td>
|
|
62
|
-
<td class="s-table--progress">${row.progress}</td>
|
|
63
|
-
<td class="s-table--progress-bar">
|
|
64
|
-
<div class="s-progress bg-white">
|
|
65
|
-
<div class="s-progress--bar bg-blue-400" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="${
|
|
66
|
-
row.progress
|
|
67
|
-
}" aria-label="progressbar" style="width: ${
|
|
68
|
-
row.progress
|
|
69
|
-
}%"></div>
|
|
70
|
-
</div>
|
|
71
|
-
</td>
|
|
72
|
-
<td><a class="s-link" href="#">Add</a></td>
|
|
73
|
-
</tr>
|
|
74
|
-
`
|
|
75
|
-
)
|
|
76
|
-
.join("")}
|
|
77
|
-
</tbody>
|
|
78
|
-
<tfoot class="s-table--totals">
|
|
79
|
-
<tr>
|
|
80
|
-
<td scope="row"><span class="v-visible-sr">Empty</span></td>
|
|
81
|
-
<th scope="row" class="ta-left">Totals</th>
|
|
82
|
-
<td><span class="v-visible-sr">Empty</span></td>
|
|
83
|
-
<td colspan="2">160</td>
|
|
84
|
-
<td><span class="v-visible-sr">Empty</span></td>
|
|
85
|
-
</tr>
|
|
86
|
-
</tfoot>
|
|
87
|
-
`,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
describe("table", () => {
|
|
91
|
-
// default, sizes
|
|
92
|
-
runVisualTests({
|
|
93
|
-
baseClass: "s-table",
|
|
94
|
-
variants: ["stripes"],
|
|
95
|
-
modifiers: {
|
|
96
|
-
primary: ["sm", "lg"],
|
|
97
|
-
secondary: ["b0", "bx", "bx-simple", "sortable"],
|
|
98
|
-
// global: ["ta-center", "ta-left", "ta-justify", "ta-right", "va-bottom", "va-middle", "va-top"], // Removing these modifiers *for now* since they create so many test images and would slow testing
|
|
99
|
-
},
|
|
100
|
-
tag: "table",
|
|
101
|
-
children,
|
|
102
|
-
template,
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IconClearSm } from "@stackoverflow/stacks-icons";
|
|
2
|
-
import { runA11yTests } from "../../test/a11y-test-utils";
|
|
3
|
-
import "../../index";
|
|
4
|
-
|
|
5
|
-
const children = {
|
|
6
|
-
default: `default`,
|
|
7
|
-
dismiss: `dismiss <span class="s-tag--dismiss">${IconClearSm}</span>`,
|
|
8
|
-
sponsor: `<img class="s-tag--sponsor" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII" width="16" height="16" alt="sponsor">sponsor`,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
describe("tag", () => {
|
|
12
|
-
runA11yTests({
|
|
13
|
-
baseClass: "s-tag",
|
|
14
|
-
variants: ["ignored", "watched", "moderator", "muted", "required"],
|
|
15
|
-
modifiers: {
|
|
16
|
-
global: ["is-selected"],
|
|
17
|
-
},
|
|
18
|
-
children,
|
|
19
|
-
// TODO: revisit this after minor tag changes are made
|
|
20
|
-
skippedTestids: [
|
|
21
|
-
/s-tag-highcontrast-light-muted/, // 6.33
|
|
22
|
-
/s-tag-light-is-selected/, // 58.28Lc
|
|
23
|
-
/s-tag-light-ignored-is-selected/, // 58.28Lc
|
|
24
|
-
/s-tag-light-moderator-is-selected/, // 49.14Lc
|
|
25
|
-
/s-tag-light-watched-is-selected/, // 58.28Lc
|
|
26
|
-
],
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { html } from "@open-wc/testing";
|
|
2
|
-
import { IconClearSm } from "@stackoverflow/stacks-icons";
|
|
3
|
-
import { runVisualTests } from "../../test/visual-test-utils";
|
|
4
|
-
import "../../index";
|
|
5
|
-
|
|
6
|
-
const children = {
|
|
7
|
-
default: `default`,
|
|
8
|
-
dismiss: `dismiss <span class="s-tag--dismiss">${IconClearSm}</span>`,
|
|
9
|
-
sponsor: `<img class="s-tag--sponsor" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII" width="16" height="16" alt="sponsor">sponsor`,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
const template = ({ component, testid }: any) => html`
|
|
14
|
-
<div data-testid="${testid}" class="d-inline-block p4">${component}</div>
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
describe("tag", () => {
|
|
18
|
-
runVisualTests({
|
|
19
|
-
baseClass: "s-tag",
|
|
20
|
-
variants: ["ignored", "watched", "moderator", "muted", "required"],
|
|
21
|
-
modifiers: {
|
|
22
|
-
global: ["is-selected"],
|
|
23
|
-
},
|
|
24
|
-
children,
|
|
25
|
-
template,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Size modifiers
|
|
29
|
-
runVisualTests({
|
|
30
|
-
baseClass: "s-tag",
|
|
31
|
-
modifiers: {
|
|
32
|
-
primary: ["xs", "sm", "md", "lg"],
|
|
33
|
-
global: ["is-selected"],
|
|
34
|
-
},
|
|
35
|
-
children: {
|
|
36
|
-
default: `default`,
|
|
37
|
-
},
|
|
38
|
-
template,
|
|
39
|
-
options: {
|
|
40
|
-
includeNullModifier: false,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { runA11yTests } from "../../test/a11y-test-utils";
|
|
2
|
-
import { html } from "@open-wc/testing";
|
|
3
|
-
import "../../index";
|
|
4
|
-
|
|
5
|
-
describe("toast > notice", () => {
|
|
6
|
-
// This is a test of notice component wrapped in a toast component
|
|
7
|
-
runA11yTests({
|
|
8
|
-
baseClass: "s-notice", // s-toast is a wrapper around s-notice
|
|
9
|
-
variants: ["info", "success", "warning", "danger"],
|
|
10
|
-
modifiers: {
|
|
11
|
-
primary: ["important"],
|
|
12
|
-
},
|
|
13
|
-
children: {
|
|
14
|
-
toast: `<span id="message">Test toast</span>`,
|
|
15
|
-
},
|
|
16
|
-
tag: "aside",
|
|
17
|
-
template: ({ component, testid }) => html`
|
|
18
|
-
<div
|
|
19
|
-
class="s-toast ps-static t0 l0"
|
|
20
|
-
role="alertdialog"
|
|
21
|
-
aria-hidden="false"
|
|
22
|
-
aria-labelledby="message"
|
|
23
|
-
data-testid="${testid}"
|
|
24
|
-
>
|
|
25
|
-
${component}
|
|
26
|
-
</div>
|
|
27
|
-
`,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { html, fixture, expect } from "@open-wc/testing";
|
|
2
|
-
import { screen } from "@testing-library/dom";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import "../../index";
|
|
5
|
-
import { showToast, hideToast } from "../../controllers";
|
|
6
|
-
|
|
7
|
-
const user = userEvent.setup();
|
|
8
|
-
|
|
9
|
-
const testToast = (hidden = true) =>
|
|
10
|
-
html` <button
|
|
11
|
-
class="js-open-test-toast"
|
|
12
|
-
data-toggle="s-toast"
|
|
13
|
-
data-target="#test-toast"
|
|
14
|
-
>
|
|
15
|
-
Show test toast
|
|
16
|
-
</button>
|
|
17
|
-
<button type="button" aria-label="Dismiss">Close toast</button>
|
|
18
|
-
<div
|
|
19
|
-
role="alertdialog"
|
|
20
|
-
id="test-toast"
|
|
21
|
-
class="s-toast"
|
|
22
|
-
aria-hidden="${hidden}"
|
|
23
|
-
aria-labelledby="toast-message"
|
|
24
|
-
data-controller="s-toast"
|
|
25
|
-
data-s-toast-target="toast"
|
|
26
|
-
data-s-toast-return-element=".js-open-test-toast[data-target='#test-toast']"
|
|
27
|
-
data-testid="test-toast"
|
|
28
|
-
>
|
|
29
|
-
<aside class="s-notice s-notice__success">
|
|
30
|
-
<div id="notice-message">Test toast</div>
|
|
31
|
-
</aside>
|
|
32
|
-
</div>`;
|
|
33
|
-
|
|
34
|
-
describe("toast", () => {
|
|
35
|
-
it("trigger should make toast visible", async () => {
|
|
36
|
-
await fixture(testToast(true));
|
|
37
|
-
|
|
38
|
-
const button = screen.getAllByRole("button")[0]; // Trigger button
|
|
39
|
-
const toast = screen.getByTestId("test-toast");
|
|
40
|
-
|
|
41
|
-
expect(toast).to.have.attribute("aria-hidden", "true");
|
|
42
|
-
button.addEventListener("click", () => showToast(toast));
|
|
43
|
-
|
|
44
|
-
await user.click(button);
|
|
45
|
-
expect(toast).to.have.attribute("aria-hidden", "false");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("trigger should hide toast", async () => {
|
|
49
|
-
await fixture(testToast(false));
|
|
50
|
-
|
|
51
|
-
const button = screen.getAllByRole("button")[1]; // Close button
|
|
52
|
-
const toast = screen.getByTestId("test-toast");
|
|
53
|
-
|
|
54
|
-
expect(toast).to.have.attribute("aria-hidden", "false");
|
|
55
|
-
button.addEventListener("click", () => hideToast(toast));
|
|
56
|
-
|
|
57
|
-
await user.click(button);
|
|
58
|
-
expect(toast).to.have.attribute("aria-hidden", "true");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// TODO: add test for refocus trigger
|
|
62
|
-
|
|
63
|
-
// TODO: add test for removing toast from DOM
|
|
64
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { runVisualTests } from "../../test/visual-test-utils";
|
|
2
|
-
import { html } from "@open-wc/testing";
|
|
3
|
-
import "../../index";
|
|
4
|
-
|
|
5
|
-
describe("toast > notice", () => {
|
|
6
|
-
// This is a test of notice component wrapped in a toast component
|
|
7
|
-
runVisualTests({
|
|
8
|
-
baseClass: "s-notice", // s-toast is a wrapper around s-notice
|
|
9
|
-
variants: ["info", "success", "warning", "danger"],
|
|
10
|
-
modifiers: {
|
|
11
|
-
primary: ["important"],
|
|
12
|
-
},
|
|
13
|
-
children: {
|
|
14
|
-
toast: `<span id="message">Test toast</span>`,
|
|
15
|
-
},
|
|
16
|
-
tag: "aside",
|
|
17
|
-
template: ({ component, testid }) => html`
|
|
18
|
-
<div class="d-inline-block p8" data-testid="${testid}">
|
|
19
|
-
<div
|
|
20
|
-
class="s-toast ps-static t0 l0"
|
|
21
|
-
role="alertdialog"
|
|
22
|
-
aria-hidden="false"
|
|
23
|
-
aria-labelledby="message"
|
|
24
|
-
>
|
|
25
|
-
${component}
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
`,
|
|
29
|
-
});
|
|
30
|
-
});
|