@simplix-react-ui-kits/site-core 0.1.0 → 0.1.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.
Files changed (112) hide show
  1. package/README.md +4 -3
  2. package/dist/account/index.d.ts +1 -1
  3. package/dist/account/index.js +3 -3
  4. package/dist/action/index.d.ts +59 -3
  5. package/dist/action/index.js +82 -0
  6. package/dist/action/index.js.map +1 -1
  7. package/dist/checkout/index.d.ts +1 -1
  8. package/dist/checkout/index.js +1 -1
  9. package/dist/{chunk-BJUU2WTX.js → chunk-EELJOGWB.js} +12 -5
  10. package/dist/chunk-EELJOGWB.js.map +1 -0
  11. package/dist/{chunk-7K476KMZ.js → chunk-EOTYGKKM.js} +3 -3
  12. package/dist/{chunk-7K476KMZ.js.map → chunk-EOTYGKKM.js.map} +1 -1
  13. package/dist/{chunk-FKC262N4.js → chunk-EWBTUSZY.js} +9 -3
  14. package/dist/chunk-EWBTUSZY.js.map +1 -0
  15. package/dist/{chunk-5TFLOQT6.js → chunk-HRRP6HMF.js} +10 -5
  16. package/dist/chunk-HRRP6HMF.js.map +1 -0
  17. package/dist/{chunk-4KFQ26JW.js → chunk-HZGBIIGN.js} +27 -6
  18. package/dist/chunk-HZGBIIGN.js.map +1 -0
  19. package/dist/{chunk-JJQJFRBI.js → chunk-OWQVRM4W.js} +3 -3
  20. package/dist/{chunk-JJQJFRBI.js.map → chunk-OWQVRM4W.js.map} +1 -1
  21. package/dist/{chunk-6S23FFBB.js → chunk-TGG4ZKPG.js} +3 -3
  22. package/dist/{chunk-6S23FFBB.js.map → chunk-TGG4ZKPG.js.map} +1 -1
  23. package/dist/{chunk-JVMJF5JJ.js → chunk-UF2MDCWB.js} +5 -5
  24. package/dist/chunk-UF2MDCWB.js.map +1 -0
  25. package/dist/{chunk-EG6GE3YS.js → chunk-YXASVWY7.js} +3 -3
  26. package/dist/{chunk-EG6GE3YS.js.map → chunk-YXASVWY7.js.map} +1 -1
  27. package/dist/content/index.d.ts +95 -0
  28. package/dist/content/index.js +85 -0
  29. package/dist/content/index.js.map +1 -0
  30. package/dist/form/index.d.ts +229 -8
  31. package/dist/form/index.js +150 -10
  32. package/dist/form/index.js.map +1 -1
  33. package/dist/help/index.d.ts +1 -1
  34. package/dist/help/index.js +6 -6
  35. package/dist/install/index.d.ts +1 -1
  36. package/dist/install/index.js +4 -4
  37. package/dist/legal/index.d.ts +2 -2
  38. package/dist/legal/index.js +5 -5
  39. package/dist/link/index.d.ts +14 -1
  40. package/dist/link/index.js +8 -1
  41. package/dist/link/index.js.map +1 -1
  42. package/dist/marketing/index.d.ts +1 -1
  43. package/dist/page/index.d.ts +2 -2
  44. package/dist/page/index.js +4 -4
  45. package/dist/pricing/index.d.ts +1 -1
  46. package/dist/pricing/index.js +2 -2
  47. package/dist/shell/index.d.ts +1 -1
  48. package/dist/{site-action-B79fuwMb.d.ts → site-action-CPpf8JZl.d.ts} +1 -1
  49. package/dist/{site-page-Dl0A5T1N.d.ts → site-page-DKcjqh9y.d.ts} +7 -2
  50. package/package.json +10 -3
  51. package/src/action/action-tile.style.ts +63 -0
  52. package/src/action/action-tile.tsx +83 -0
  53. package/src/action/index.ts +11 -0
  54. package/src/content/content.style.ts +72 -0
  55. package/src/content/content.tsx +124 -0
  56. package/src/content/index.ts +12 -0
  57. package/src/form/choices.style.ts +16 -0
  58. package/src/form/choices.tsx +28 -5
  59. package/src/form/country-field.tsx +61 -0
  60. package/src/form/date-time.style.ts +26 -0
  61. package/src/form/date-time.tsx +123 -0
  62. package/src/form/dialog.style.ts +4 -2
  63. package/src/form/errors.tsx +16 -4
  64. package/src/form/form.style.ts +8 -0
  65. package/src/form/index.ts +11 -1
  66. package/src/form/phone-field.tsx +98 -0
  67. package/src/form/select.style.ts +6 -1
  68. package/src/form/select.tsx +13 -3
  69. package/src/form/signature.style.ts +20 -0
  70. package/src/form/signature.tsx +46 -0
  71. package/src/link/index.ts +1 -0
  72. package/src/link/mounted-href.ts +16 -0
  73. package/src/page/site-page.style.ts +13 -4
  74. package/src/page/site-page.tsx +8 -3
  75. package/src/styles/designs/base.css +121 -4
  76. package/templates/app-shell.hbs +5 -4
  77. package/dist/chunk-4KFQ26JW.js.map +0 -1
  78. package/dist/chunk-5TFLOQT6.js.map +0 -1
  79. package/dist/chunk-BJUU2WTX.js.map +0 -1
  80. package/dist/chunk-FKC262N4.js.map +0 -1
  81. package/dist/chunk-JVMJF5JJ.js.map +0 -1
  82. package/src/account/account.test.tsx +0 -186
  83. package/src/action/site-action.test.tsx +0 -154
  84. package/src/auth/auth.test.tsx +0 -132
  85. package/src/checkout/checkout.test.tsx +0 -187
  86. package/src/form/choices-field.test.tsx +0 -20
  87. package/src/form/errors.test.tsx +0 -49
  88. package/src/form/form.test.tsx +0 -275
  89. package/src/form/question-focus.test.ts +0 -182
  90. package/src/form/slider.test.tsx +0 -148
  91. package/src/form/typed-text.test.ts +0 -52
  92. package/src/help/article.test.tsx +0 -189
  93. package/src/help/help.test.tsx +0 -215
  94. package/src/help/screen-sketch.test.tsx +0 -59
  95. package/src/install/install.test.tsx +0 -177
  96. package/src/legal/legal.test.tsx +0 -161
  97. package/src/legal/policy.test.tsx +0 -137
  98. package/src/legal/refund.test.tsx +0 -148
  99. package/src/link/routes-in-page.test.ts +0 -26
  100. package/src/link/site-link.test.ts +0 -10
  101. package/src/marketing/marketing.test.tsx +0 -221
  102. package/src/page/site-failure.test.tsx +0 -65
  103. package/src/page/site-page.test.tsx +0 -109
  104. package/src/page/site-read.test.tsx +0 -41
  105. package/src/pricing/pack-card.test.tsx +0 -107
  106. package/src/pricing/pricing.test.tsx +0 -261
  107. package/src/shell/refusal-page.test.ts +0 -19
  108. package/src/shell/site-scheme-param.test.ts +0 -53
  109. package/src/shell/site-scheme-switch.test.ts +0 -80
  110. package/src/shell/site-scheme.test.ts +0 -149
  111. package/src/shell/site-shell.test.tsx +0 -401
  112. package/src/testing/markup.ts +0 -65
@@ -1,215 +0,0 @@
1
- import { renderToStaticMarkup } from "react-dom/server";
2
- import { describe, expect, it } from "vitest";
3
- import type { SiteActionSpec } from "../action/site-action";
4
-
5
- import { SiteChip } from "../page/site-bits";
6
- import { bySlot, silentRefusals, tabStops, unmarked } from "../testing/markup";
7
- import { FieldRow, FormField } from "../form/fields";
8
- import { SITE_FIELD_NARROW } from "../form/form.style";
9
- import { AttachBox, ContactForm, ContactPanel, ContactSent, SuggestBox } from "./contact";
10
-
11
- import { ArticleList, CategoryGrid, SiteColumns } from "./help-lists";
12
- import { SearchHero, SiteSearch, searchKeyTarget, StatusLine } from "./search-hero";
13
- import { siteCategoryGridStyle, siteColumnsStyle } from "./help-lists.style";
14
- import { siteSearchHeroInnerStyle, siteSearchKeysStyle, siteSearchInputStyle } from "./search-hero.style";
15
- import { siteContactStyle } from "./contact.style";
16
- import { siteTextareaStyle, siteInputStyle, siteFieldRowStyle } from "../form/fields.style";
17
-
18
- const matches = [
19
- { key: "a", title: "When voices are not made", meta: "Troubleshooting" },
20
- { key: "b", title: "Getting a refund", meta: "Payment" },
21
- ];
22
- const search = (value: string, list = matches) =>
23
- renderToStaticMarkup(<SiteSearch label="Search help" value={value} onValueChange={() => {}} matches={list} onPick={() => {}} foundLabel="2 results" keysLabel="↑ ↓ to pick" emptyLabel="Nothing matches" listId="results" />);
24
-
25
- describe("SearchHero and SiteSearch", () => {
26
- it("draws the status, the one h1, the lede, the searches to try and the search in that order", () => {
27
- const html = renderToStaticMarkup(
28
- <SearchHero status={<StatusLine>All services running</StatusLine>} title="How can we help?" lede="In your own words." suggestionsLabel="Try searching" suggestions={[{ id: "a", label: "Refund" }]} search={<span data-slot="product-search" />} />,
29
- );
30
- expect(html.match(/<h1/g)).toHaveLength(1);
31
- const order = ["site-status-line", "site-search-hero-title", "site-search-hero-lede", "site-suggestions", "product-search"].map((slot) => html.indexOf(`data-slot="${slot}"`));
32
- expect(order.every((at, i) => at > 0 && (i === 0 || at > (order[i - 1] ?? 0)))).toBe(true);
33
- expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
34
- expect(siteSearchHeroInnerStyle.base).toContain("@max-page-narrow/page:py-6");
35
- expect(unmarked(html.replace('<span data-slot="product-search"></span>', ""))).toEqual([]);
36
- });
37
-
38
- it("draws the status in its tone with its dot", () => {
39
- const html = renderToStaticMarkup(<StatusLine tone="warn">Delays</StatusLine>);
40
- expect(bySlot(html, "site-status-line")[0]?.attributes["data-tone"]).toBe("warn");
41
- expect(bySlot(html, "site-status-dot")[0]?.attributes["aria-hidden"]).toBe("true");
42
- });
43
-
44
- it("is a combobox whose matches open under it only while something is typed, the first one active", () => {
45
- expect(bySlot(search(""), "site-search-results")).toEqual([]);
46
- const html = search("voice");
47
- const input = bySlot(html, "site-search-input")[0];
48
- expect(input?.attributes.role).toBe("combobox");
49
- expect(input?.attributes["aria-expanded"]).toBe("true");
50
- expect(input?.attributes["aria-controls"]).toBe("results");
51
- expect(bySlot(html, "site-search-results")[0]?.attributes.role).toBe("listbox");
52
- expect(bySlot(html, "site-search-option").map((option) => [option.attributes["aria-selected"], option.attributes["data-active"]])).toEqual([
53
- ["true", "true"],
54
- ["false", "false"],
55
- ]);
56
- expect(unmarked(html)).toEqual([]);
57
- });
58
-
59
- it("says when nothing matches and leaves the keys hint off a narrow page", () => {
60
- const html = search("xyzzy", []);
61
- expect(bySlot(html, "site-search-empty")).toHaveLength(1);
62
- expect(bySlot(html, "site-search-option")).toEqual([]);
63
- expect(bySlot(html, "site-search-input")[0]?.attributes["aria-expanded"]).toBe("false");
64
- expect(siteSearchKeysStyle.base).toBe("@max-page-narrow/page:hidden");
65
- });
66
-
67
- it("moves the active match with the arrows and holds it to the list's ends", () => {
68
- expect(searchKeyTarget(0, 3, "ArrowDown")).toBe(1);
69
- expect(searchKeyTarget(2, 3, "ArrowDown")).toBe(2);
70
- expect(searchKeyTarget(0, 3, "ArrowUp")).toBe(0);
71
- expect(searchKeyTarget(1, 3, "Enter")).toBeNull();
72
- expect(searchKeyTarget(0, 0, "ArrowDown")).toBeNull();
73
- });
74
- });
75
-
76
- describe("CategoryGrid and ArticleList", () => {
77
- it("draws each category named by its title, with its count and its articles as links", () => {
78
- const html = renderToStaticMarkup(<CategoryGrid categories={[{ key: "start", title: "Getting started", count: "2 articles", articles: [{ key: "a", title: "Installing", href: "/help/a" }, { key: "b", title: "First deck", href: "/help/b" }] }]} />);
79
- expect(bySlot(html, "site-category")[0]?.attributes["aria-label"]).toBe("Getting started");
80
- expect(tabStops(html).map((stop) => stop.attributes.href)).toEqual(["/help/a", "/help/b"]);
81
- expect(siteCategoryGridStyle.base).toContain("grid-cols-5");
82
- expect(siteCategoryGridStyle.base).toContain("@max-page-medium/page:grid-cols-2");
83
- expect(unmarked(html)).toEqual([]);
84
- });
85
-
86
- it("numbers the most read articles in two digits, with the heading's badge", () => {
87
- const html = renderToStaticMarkup(<ArticleList title="Most read" badge={<SiteChip>This week</SiteChip>} items={[{ key: "a", title: "Refunds", meta: "Payment · 940 people", href: "/help/a" }]} />);
88
- expect(bySlot(html, "site-article-list")[0]?.attributes["aria-label"]).toBe("Most read");
89
- expect(bySlot(html, "site-article-rows")[0]?.name).toBe("ol");
90
- expect(html).toContain(">01</span>");
91
- expect(bySlot(html, "site-chip")).toHaveLength(1);
92
- expect(unmarked(html)).toEqual([]);
93
- });
94
-
95
- it("draws an article with no address as its words in the link's place, pending and out of the tab order", () => {
96
- const grid = renderToStaticMarkup(<CategoryGrid categories={[{ key: "start", title: "Getting started", articles: [{ key: "a", title: "Installing", href: "/help/a" }, { key: "b", title: "First deck" }] }]} />);
97
- expect(tabStops(grid).map((stop) => stop.attributes.href)).toEqual(["/help/a"]);
98
- expect(bySlot(grid, "site-category-link").map((link) => [link.name, link.attributes["data-pending"]])).toEqual([
99
- ["a", "false"],
100
- ["span", "true"],
101
- ]);
102
- const list = renderToStaticMarkup(<ArticleList title="Most read" items={[{ key: "a", title: "Refunds", href: "/help/a" }, { key: "b", title: "Tone" }]} />);
103
- expect(bySlot(list, "site-article-link").map((link) => [link.name, link.attributes["data-pending"]])).toEqual([
104
- ["a", "false"],
105
- ["span", "true"],
106
- ]);
107
- expect(bySlot(list, "site-article-number")).toHaveLength(2);
108
- expect(unmarked(grid)).toEqual([]);
109
- expect(unmarked(list)).toEqual([]);
110
- });
111
-
112
- it("stands two parts side by side, one under the other below the medium tier", () => {
113
- expect(bySlot(renderToStaticMarkup(<SiteColumns>x</SiteColumns>), "site-columns")).toHaveLength(1);
114
- expect(siteColumnsStyle.base).toContain("@max-page-medium/page:grid-cols-1");
115
- });
116
- });
117
-
118
- describe("the contact parts", () => {
119
- it("offers the form with a primary action and the hours", () => {
120
- const html = renderToStaticMarkup(<ContactPanel title="Didn't find your answer?" body="Support answers in 4 hours." action={{ id: "open", label: "Contact us" }} hours="Weekdays" />);
121
- expect(bySlot(html, "site-contact")[0]?.attributes["data-state"]).toBe("closed");
122
- expect(bySlot(html, "site-action")[0]?.attributes["data-tone"]).toBe("primary");
123
- expect(bySlot(html, "site-contact-note")).toHaveLength(1);
124
- expect(unmarked(html)).toEqual([]);
125
- });
126
-
127
- it("lays the form out, outlined, with a submit button, the cancel action and what is missing", () => {
128
- const html = renderToStaticMarkup(
129
- <ContactForm title="Contact us" submit={{ id: "send", label: "Send", disabled: true, reason: "Write a subject" }} cancel={{ id: "close", label: "Close" }} note="Write a subject">
130
- <FieldRow>
131
- <FormField as="group" label="Category">
132
- <span data-slot="product-control" />
133
- </FormField>
134
- <FormField label="Reply to">
135
- <span data-slot="product-control" />
136
- </FormField>
137
- </FieldRow>
138
- <SuggestBox label="These may answer it" articles={[{ key: "a", title: "Refunds", href: "/help/a" }]} />
139
- <AttachBox control={(label) => <label data-slot="product-checkbox">{label}</label>} title="Attach the record" badge={<SiteChip tone="accent">Recommended</SiteChip>} about="Versions only" />
140
- </ContactForm>,
141
- );
142
- const form = bySlot(html, "site-contact")[0];
143
- expect(form?.name).toBe("form");
144
- expect(form?.attributes["data-state"]).toBe("open");
145
- expect(form?.attributes.noValidate ?? form?.attributes.novalidate).toBeDefined();
146
- const actions = bySlot(html, "site-action");
147
- expect(actions[0]?.attributes.type).toBe("submit");
148
- expect(actions[0]?.attributes.disabled).toBeDefined();
149
- expect(actions[1]?.attributes.type).toBe("button");
150
- expect(bySlot(html, "site-field").map((field) => field.name)).toEqual(["div", "label"]);
151
- expect(bySlot(html, "site-attach-title")).toHaveLength(1);
152
- expect(siteFieldRowStyle.base).toContain("@max-page-narrow/page:grid-cols-1");
153
- expect(unmarked(html.replaceAll('<span data-slot="product-control"></span>', ""))).toEqual([]);
154
- });
155
-
156
- it("describes a disabled send by the note beside it, and leaves an enabled one undescribed", () => {
157
- const form = (submit: SiteActionSpec, note?: string) =>
158
- renderToStaticMarkup(
159
- <ContactForm title="Contact us" submit={submit} cancel={{ id: "close", label: "Close" }} {...(note === undefined ? {} : { note })}>
160
- <span data-slot="product-control" />
161
- </ContactForm>,
162
- );
163
- const refused = form({ id: "send", label: "Send", disabled: true, reason: "Write a subject first" }, "Questions cannot be sent from here yet");
164
- expect(silentRefusals(refused)).toEqual([]);
165
- expect(bySlot(refused, "site-action")[0]?.attributes["aria-describedby"]).toBe(bySlot(refused, "site-contact-note")[0]?.attributes.id);
166
- // Without the note the send is described by its own reason, drawn for a screen reader only.
167
- const unnoted = form({ id: "send", label: "Send", disabled: true, reason: "Write a subject first" });
168
- expect(bySlot(unnoted, "site-action")[0]?.attributes["aria-describedby"]).toBe(bySlot(unnoted, "site-action-reason")[0]?.attributes.id);
169
- expect(silentRefusals(unnoted)).toEqual([]);
170
- expect(bySlot(form({ id: "send", label: "Send" }, "Write a subject"), "site-action")[0]?.attributes["aria-describedby"]).toBeUndefined();
171
- });
172
-
173
- it("hands the checkbox the id of the line saying why the attachment cannot be added", () => {
174
- const seen: (string | undefined)[] = [];
175
- const box = (reason?: string) =>
176
- renderToStaticMarkup(
177
- <AttachBox
178
- control={(label, describedBy) => {
179
- seen.push(describedBy);
180
- return <label data-slot="product-checkbox">{label}</label>;
181
- }}
182
- title="Attach the record"
183
- {...(reason === undefined ? {} : { reason })}
184
- />,
185
- );
186
- const html = box("The app on this computer cannot be reached from here yet");
187
- expect(seen[0]).toBeDefined();
188
- expect(bySlot(html, "site-attach-reason")[0]?.attributes.id).toBe(seen[0]);
189
- expect(bySlot(box(), "site-attach-reason")).toEqual([]);
190
- expect(seen[1]).toBeUndefined();
191
- });
192
-
193
- it("says the question arrived, with its ticket and the way to ask again", () => {
194
- const html = renderToStaticMarkup(<ContactSent title="We got your question" ticket={<SiteChip>SV-1</SiteChip>} body="We answer by mail." action={{ id: "again", label: "Ask again" }} />);
195
- expect(bySlot(html, "site-contact")[0]?.attributes["data-state"]).toBe("sent");
196
- expect(bySlot(html, "site-contact-mark")[0]?.attributes["aria-hidden"]).toBe("true");
197
- expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
198
- expect(unmarked(html)).toEqual([]);
199
- });
200
-
201
- it("can take the focus as it replaces the form, named by its title", () => {
202
- const html = renderToStaticMarkup(<ContactSent title="We got your question" body="We answer by mail." />);
203
- const section = bySlot(html, "site-contact")[0];
204
- expect(section?.attributes.tabindex).toBe("-1");
205
- expect(bySlot(html, "site-contact-title")[0]?.attributes.id).toBe(section?.attributes["aria-labelledby"]);
206
- expect(siteContactStyle.variants.state.sent).toContain("outline-none");
207
- });
208
- });
209
-
210
- describe("text a reader types", () => {
211
- it("is read at the input size at phone width in every slot that takes it, the help search included", () => {
212
- expect(SITE_FIELD_NARROW).toContain("--site-fs-input");
213
- for (const style of [siteInputStyle, siteTextareaStyle, siteSearchInputStyle]) expect(style.base).toContain(SITE_FIELD_NARROW);
214
- });
215
- });
@@ -1,59 +0,0 @@
1
- import { renderToStaticMarkup } from "react-dom/server";
2
- import { describe, expect, it } from "vitest";
3
-
4
- import { bySlot, unmarked } from "../testing/markup";
5
- import { ScreenSketch, SketchLines, SketchMeter, SketchNotice, SketchPill, SketchPills, SketchRow, SketchWords } from "./screen-sketch";
6
- import { siteScreenStyle } from "./screen.style";
7
-
8
- const tick = <svg data-slot="product-glyph" />;
9
-
10
- describe("ScreenSketch", () => {
11
- it("is one picture hidden from assistive technology, with its title bar, rows and footer", () => {
12
- const html = renderToStaticMarkup(
13
- <ScreenSketch title="StageVoice" closeMark={tick} footer={<SketchPill tone="accent">Remake failed only</SketchPill>}>
14
- <SketchRow state="ok" text="We automated 32 tasks" meta="0:04" mark={tick} />
15
- </ScreenSketch>,
16
- );
17
- expect(bySlot(html, "site-screen")[0]?.attributes["aria-hidden"]).toBe("true");
18
- const order = ["site-screen-head", "site-screen-body", "site-screen-foot"].map((slot) => html.indexOf(`data-slot="${slot}"`));
19
- expect(order.every((at, i) => at > 0 && (i === 0 || at > (order[i - 1] ?? 0)))).toBe(true);
20
- expect(siteScreenStyle.base).toContain("max-w-sm");
21
- expect(unmarked(html.replaceAll('<svg data-slot="product-glyph"></svg>', ""))).toEqual([]);
22
- });
23
-
24
- it("draws a row's state on its disc and its ground, and no mark on a waiting row", () => {
25
- const row = (state: "ok" | "bad" | "wait") => renderToStaticMarkup(<SketchRow state={state} text="A sentence" mark={tick} />);
26
- expect(bySlot(row("bad"), "site-screen-row")[0]?.attributes["data-state"]).toBe("bad");
27
- expect(bySlot(row("bad"), "site-screen-disc")[0]?.attributes["data-state"]).toBe("bad");
28
- expect(row("ok")).toContain("product-glyph");
29
- expect(row("wait")).not.toContain("product-glyph");
30
- const failed = renderToStaticMarkup(
31
- <SketchRow state="bad" text="A sentence" meta="—">
32
- <SketchWords tone="bad" strong>
33
- Not enough credits
34
- </SketchWords>
35
- <SketchPills>
36
- <SketchPill tone="accent">Extra credits</SketchPill>
37
- <SketchPill>Use a free voice</SketchPill>
38
- </SketchPills>
39
- </SketchRow>,
40
- );
41
- expect(bySlot(failed, "site-screen-words")[0]?.name).toBe("b");
42
- expect(bySlot(failed, "site-screen-pill").map((pill) => pill.attributes["data-tone"])).toEqual(["accent", "plain"]);
43
- expect(unmarked(failed)).toEqual([]);
44
- });
45
-
46
- it("draws a notice, standing lines and a meter held to its track", () => {
47
- const html = renderToStaticMarkup(
48
- <ScreenSketch title="StageVoice">
49
- <SketchNotice title="App not found" text="Voices are made by the app" action={<SketchPill tone="accent">Open the app</SketchPill>} />
50
- <SketchLines lengths={["long", "short", "middle"]} />
51
- <SketchMeter label="Premium characters left" value="1,240 / 50,000" share={2} low note="Refilled Dec 1" />
52
- </ScreenSketch>,
53
- );
54
- expect(bySlot(html, "site-screen-line-bar").map((bar) => bar.attributes["data-length"])).toEqual(["long", "short", "middle"]);
55
- expect(bySlot(html, "site-screen-fill")[0]?.attributes["data-tone"]).toBe("warn");
56
- expect(html).toContain("width:100%");
57
- expect(unmarked(html)).toEqual([]);
58
- });
59
- });
@@ -1,177 +0,0 @@
1
- import { renderToStaticMarkup } from "react-dom/server";
2
- import { describe, expect, it } from "vitest";
3
-
4
- import { SiteCaption, SiteChip, SiteLive, SiteSpinner } from "../page/site-bits";
5
- import { bySlot, silentRefusals, tabStops, unmarked } from "../testing/markup";
6
- import { CheckCard, checkPassed } from "./check-card";
7
- import { ActionLine, CopyBlock, DisclosureList, NumberedList } from "./disclosure-list";
8
- import { DownloadCard, DownloadGrid, NoticeCard } from "./download-card";
9
- import { siteDownloadFileStyle, siteDownloadGridStyle, siteInstallStepStyle } from "./install.style";
10
- import { InstallSteps, ScreenSketch } from "./install-steps";
11
- import { SiteProgress, VideoCard } from "./video-card";
12
-
13
- describe("CheckCard", () => {
14
- const findings = [
15
- { key: "os", label: "Windows 11", ok: true },
16
- { key: "office", label: "PowerPoint 2016", ok: false },
17
- ];
18
-
19
- it("asks before it runs, with its one action", () => {
20
- const html = renderToStaticMarkup(<CheckCard state={{ kind: "idle", ask: "Check this computer?", action: { id: "check", label: "Check" } }} />);
21
- expect(bySlot(html, "site-check-title")[0]?.attributes["data-grow"]).toBe("true");
22
- expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
23
- expect(tabStops(html)).toHaveLength(1);
24
- expect(unmarked(html)).toEqual([]);
25
- });
26
-
27
- it("turns a spinner while it runs and offers no action", () => {
28
- const html = renderToStaticMarkup(<CheckCard state={{ kind: "running", label: "Checking…" }} status="Checking…" />);
29
- expect(bySlot(html, "site-spinner")[0]?.attributes["aria-hidden"]).toBe("true");
30
- expect(tabStops(html)).toEqual([]);
31
- expect(bySlot(html, "site-live")[0]?.attributes.role).toBe("status");
32
- expect(html).toContain(">Checking…</span>");
33
- });
34
-
35
- it("draws a chip per finding in its tone and the verdict bad when any finding blocks", () => {
36
- const html = renderToStaticMarkup(<CheckCard state={{ kind: "done", title: "This computer", findings, verdict: "Not ready yet" }} />);
37
- expect(bySlot(html, "site-chip").map((chip) => chip.attributes["data-tone"])).toEqual(["good", "bad"]);
38
- expect(bySlot(html, "site-chip-dot")).toHaveLength(2);
39
- expect(bySlot(html, "site-check-verdict")[0]?.attributes["data-tone"]).toBe("bad");
40
- expect(checkPassed(findings)).toBe(false);
41
- expect(checkPassed(findings.slice(0, 1))).toBe(true);
42
- expect(unmarked(html)).toEqual([]);
43
- });
44
- });
45
-
46
- describe("DownloadCard and NoticeCard", () => {
47
- it("outlines the download to take first and makes its action primary, the other secondary", () => {
48
- const html = renderToStaticMarkup(
49
- <DownloadGrid>
50
- <DownloadCard highlight title="Windows" body="Windows 10 or later." file="Setup.exe · 64 MB" action={{ id: "win", label: "Download for Windows" }} />
51
- <DownloadCard title="Mac" body="macOS 13 or later." file="App.dmg" action={{ id: "mac", label: "Download for Mac" }} />
52
- </DownloadGrid>,
53
- );
54
- expect(bySlot(html, "site-download").map((card) => card.attributes["data-highlight"])).toEqual(["true", "false"]);
55
- expect(bySlot(html, "site-action").map((action) => action.attributes["data-tone"])).toEqual(["primary", "secondary"]);
56
- expect(siteDownloadGridStyle.base).toContain("@max-page-narrow/page:grid-cols-1");
57
- expect(unmarked(html)).toEqual([]);
58
- });
59
-
60
- it("breaks a file line that has no break points, such as a checksum, at the card's edge", () => {
61
- expect(siteDownloadFileStyle.base).toContain("break-words");
62
- });
63
-
64
- it("describes a disabled download by its file line, which says there is no file yet", () => {
65
- const html = renderToStaticMarkup(<DownloadCard title="Windows" body="Windows 10 or later." file="Not available yet" action={{ id: "win", label: "Download for Windows", disabled: true, reason: "No installer yet" }} />);
66
- expect(bySlot(html, "site-action")[0]?.attributes["aria-describedby"]).toBe(bySlot(html, "site-download-file")[0]?.attributes.id);
67
- expect(silentRefusals(html)).toEqual([]);
68
- expect(silentRefusals(renderToStaticMarkup(<DownloadCard title="Windows" body="Windows 10 or later." action={{ id: "win", label: "Download for Windows", disabled: true, reason: "No installer yet" }} />))).toEqual([]);
69
- const open = renderToStaticMarkup(<DownloadCard title="Windows" body="Windows 10 or later." file="Setup.exe · 64 MB" action={{ id: "win", label: "Download for Windows" }} />);
70
- expect(bySlot(open, "site-action")[0]?.attributes["aria-describedby"]).toBeUndefined();
71
- });
72
-
73
- it("draws neither file nor action when a phone cannot install", () => {
74
- const html = renderToStaticMarkup(<DownloadCard title="Windows" body="Windows 10 or later." />);
75
- expect(bySlot(html, "site-download-file")).toEqual([]);
76
- expect(tabStops(html)).toEqual([]);
77
- });
78
-
79
- it("draws a notice as an outlined card with its title and words", () => {
80
- const html = renderToStaticMarkup(<NoticeCard title="Install on your computer" body="Open this page there." />);
81
- expect(bySlot(html, "site-notice")[0]?.attributes["data-tone"]).toBe("accent");
82
- expect(bySlot(html, "site-notice-title")).toHaveLength(1);
83
- expect(unmarked(html)).toEqual([]);
84
- });
85
- });
86
-
87
- describe("InstallSteps and ScreenSketch", () => {
88
- it("numbers each step on a disc, with its tag, words and sketch, stacked below the narrow tier", () => {
89
- const html = renderToStaticMarkup(
90
- <InstallSteps
91
- steps={[
92
- { key: "a", title: "Install the app", body: "Open the file.", media: <ScreenSketch content={{ kind: "progress", label: "Installing", share: 0.6 }} /> },
93
- { key: "b", title: "Install the add-in", tag: <SiteChip>For PowerPoint</SiteChip>, body: "Press Add.", media: <ScreenSketch content={{ kind: "pill", label: "App", pill: "Add" }} /> },
94
- { key: "c", title: "Connect", body: "Six digits.", media: <ScreenSketch accentBar content={{ kind: "code", code: "482913" }} /> },
95
- ]}
96
- />,
97
- );
98
- expect(bySlot(html, "site-install-steps")[0]?.name).toBe("ol");
99
- expect(bySlot(html, "site-step-disc").length).toBe(3);
100
- expect(html).toContain(">1</span>");
101
- expect(bySlot(html, "site-install-step-tag")).toHaveLength(1);
102
- expect(bySlot(html, "site-sketch").every((sketch) => sketch.attributes["aria-hidden"] === "true")).toBe(true);
103
- expect(bySlot(html, "site-sketch-fill")[0]?.attributes.style).toBe("width:60%");
104
- expect(bySlot(html, "site-sketch-label").map((label) => label.attributes["data-kind"])).toEqual(["progress", "pill", "code"]);
105
- expect(bySlot(html, "site-sketch-line").map((line) => line.attributes["data-span"])).toEqual(["short", "long", "short", "long", "short", "accent"]);
106
- expect(siteInstallStepStyle.base).toContain("@max-page-narrow/page:grid-cols-1");
107
- expect(unmarked(html)).toEqual([]);
108
- });
109
-
110
- it("holds a sketch's progress between empty and full", () => {
111
- const html = renderToStaticMarkup(<ScreenSketch content={{ kind: "progress", label: "x", share: 1.7 }} />);
112
- expect(bySlot(html, "site-sketch-fill")[0]?.attributes.style).toBe("width:100%");
113
- });
114
- });
115
-
116
- describe("VideoCard", () => {
117
- it("is named by its title, its toggle pressed while it plays and its track filled to the share played", () => {
118
- const html = renderToStaticMarkup(<VideoCard title="Watch the install" caption="Two minutes." played={0.25} toggleLabel="Play the install video" />);
119
- expect(bySlot(html, "site-video")[0]?.attributes["aria-label"]).toBe("Watch the install");
120
- expect(bySlot(html, "site-video-toggle")[0]?.attributes["aria-pressed"]).toBe("true");
121
- expect(bySlot(html, "site-progress-fill")[0]?.attributes.style).toBe("width:25%");
122
- expect(unmarked(html)).toEqual([]);
123
- });
124
-
125
- it("draws an empty track while it is not playing", () => {
126
- const html = renderToStaticMarkup(<VideoCard title="Watch" played={null} toggleLabel="Play" />);
127
- expect(bySlot(html, "site-video-toggle")[0]?.attributes["aria-pressed"]).toBe("false");
128
- expect(renderToStaticMarkup(<SiteProgress share={-1} />)).toContain("width:0%");
129
- });
130
- });
131
-
132
- describe("DisclosureList", () => {
133
- const items = [
134
- { key: "old", title: "Add-ins are not available", lead: "PowerPoint is too old.", body: "Update it.", steps: ["File › Account", "Update Now"] },
135
- { key: "store", title: "Not in Get Add-ins", body: "An admin deploys it.", copy: <CopyBlock text={"Admin center\n› Integrated apps"} action={{ id: "copy", label: "Copy the message" }} /> },
136
- ];
137
-
138
- it("opens one answer, its question pressed open and pointing at it, the cause first and the steps numbered", () => {
139
- const html = renderToStaticMarkup(<DisclosureList items={items} open="old" onOpenChange={() => {}} mark={<svg data-slot="product-glyph" />} />);
140
- const buttons = bySlot(html, "site-disclosure-button");
141
- expect(buttons.map((button) => button.attributes["aria-expanded"])).toEqual(["true", "false"]);
142
- const panel = bySlot(html, "site-disclosure-panel")[0];
143
- expect(buttons[0]?.attributes["aria-controls"]).toBe(panel?.attributes.id);
144
- expect(buttons[1]?.attributes["aria-controls"]).toBeUndefined();
145
- expect(bySlot(html, "site-disclosure-mark").map((mark) => mark.attributes["data-open"])).toEqual(["true", "false"]);
146
- expect(bySlot(html, "site-disclosure-lead")).toHaveLength(1);
147
- expect(bySlot(html, "site-numbered-item")).toHaveLength(2);
148
- expect(unmarked(html.replace('<svg data-slot="product-glyph"></svg>', ""))).toEqual([]);
149
- });
150
-
151
- it("keeps a copied message as written, with the action that copies it", () => {
152
- const html = renderToStaticMarkup(<DisclosureList items={items} open="store" onOpenChange={() => {}} />);
153
- expect(bySlot(html, "site-copy-text")[0]?.name).toBe("pre");
154
- expect(html).toContain("Admin center\n› Integrated apps");
155
- expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
156
- });
157
-
158
- it("opens nothing when no key is open", () => {
159
- const html = renderToStaticMarkup(<DisclosureList items={items} open={null} onOpenChange={() => {}} />);
160
- expect(bySlot(html, "site-disclosure-panel")).toEqual([]);
161
- });
162
-
163
- it("draws a numbered list on its own", () => {
164
- expect(bySlot(renderToStaticMarkup(<NumberedList items={["One", "Two"]} />), "site-numbered-list")[0]?.name).toBe("ol");
165
- });
166
- });
167
-
168
- describe("the small page parts", () => {
169
- it("end a muted line in its one action, caption a part, and speak a status", () => {
170
- const line = renderToStaticMarkup(<ActionLine text="Not installing?" action={{ id: "help", label: "Troubleshooting", href: "/help" }} />);
171
- expect(tabStops(line).map((stop) => stop.attributes.href)).toEqual(["/help"]);
172
- expect(bySlot(renderToStaticMarkup(<SiteCaption>Still stuck?</SiteCaption>), "site-caption")[0]?.name).toBe("p");
173
- expect(bySlot(renderToStaticMarkup(<SiteLive>Ready</SiteLive>), "site-live")[0]?.attributes.role).toBe("status");
174
- expect(unmarked(renderToStaticMarkup(<SiteSpinner />))).toEqual([]);
175
- expect(bySlot(renderToStaticMarkup(<SiteChip tone="warn">Draft</SiteChip>), "site-chip")[0]?.attributes["data-tone"]).toBe("warn");
176
- });
177
- });
@@ -1,161 +0,0 @@
1
- import { renderToStaticMarkup } from "react-dom/server";
2
- import { describe, expect, it } from "vitest";
3
-
4
- import { SiteBadge } from "../page/site-bits";
5
- import { bySlot, silentRefusals, tabStops, unmarked } from "../testing/markup";
6
- import { DocLayout } from "./doc-layout";
7
- import { ChangeList, ClauseList, DiffText, diffChanged, diffVisible, FilledText, InfoCard, InfoGrid, KeyValues, LegalArticle, NoticeBanner, PlainSummary, PrintButton, VersionPicker } from "./legal-parts";
8
-
9
- import { siteKeyValuesStyle, siteInfoGridStyle, siteValueStyle } from "./legal-parts.style";
10
-
11
- const clause = "The app {+edits a pptx+}{-only reads files-} for {company}.";
12
-
13
- describe("DiffText", () => {
14
- it("drops the removed text in the current version and the added text in the previous one", () => {
15
- expect(renderToStaticMarkup(<DiffText text={clause} mode="current" />)).toBe("The app edits a pptx for {company}.");
16
- expect(renderToStaticMarkup(<DiffText text={clause} mode="previous" />)).toBe("The app only reads files for {company}.");
17
- });
18
-
19
- it("marks both in the comparison, the addition as ins and the removal as del", () => {
20
- const html = renderToStaticMarkup(<DiffText text={clause} mode="diff" />);
21
- expect(bySlot(html, "site-diff-added")[0]?.name).toBe("ins");
22
- expect(bySlot(html, "site-diff-removed")[0]?.name).toBe("del");
23
- expect(html).toContain(">edits a pptx</ins>");
24
- expect(html).toContain(">only reads files</del>");
25
- });
26
-
27
- it("draws an unfilled field as a dashed field, inside a change too", () => {
28
- const html = renderToStaticMarkup(<DiffText text="{+Run by {company}+}" mode="diff" placeholders={{ company: "[Company]" }} />);
29
- expect(bySlot(html, "site-field-gap")).toHaveLength(1);
30
- expect(html).toContain(">[Company]</span>");
31
- expect(renderToStaticMarkup(<FilledText text="No {fields} here" />)).toBe("No {fields} here");
32
- });
33
-
34
- it("knows when a clause says nothing in a version and when it carries a change", () => {
35
- expect(diffVisible("{+New clause+}", "previous")).toBe(false);
36
- expect(diffVisible("{+New clause+}", "current")).toBe(true);
37
- expect(diffVisible("{-Old clause-}", "current")).toBe(false);
38
- expect(diffVisible("{-Old clause-}", "diff")).toBe(true);
39
- expect(diffChanged(clause)).toBe(true);
40
- expect(diffChanged("Plain")).toBe(false);
41
- });
42
- });
43
-
44
- describe("the legal head parts", () => {
45
- it("speaks an info banner as a status and a warning as an alert, with its actions small", () => {
46
- const info = renderToStaticMarkup(<NoticeBanner tone="info" title="New terms apply" actions={[{ id: "see", label: "See the changes" }]}>From October 1.</NoticeBanner>);
47
- expect(bySlot(info, "site-banner")[0]?.attributes["data-tone"]).toBe("info");
48
- expect(bySlot(info, "site-banner-title")[0]?.attributes.role).toBe("status");
49
- expect(bySlot(info, "site-action")[0]?.attributes["data-size"]).toBe("sm");
50
- expect(bySlot(renderToStaticMarkup(<NoticeBanner tone="warn" title="Old version" />), "site-banner-title")[0]?.attributes.role).toBe("alert");
51
- expect(unmarked(info)).toEqual([]);
52
- });
53
-
54
- it("dims the comparison switch while it cannot be used, and describes it by the reason for a screen reader and on hover", () => {
55
- const off = renderToStaticMarkup(
56
- <VersionPicker select={<span data-slot="product-select" />} compare={{ label: "Show changes", control: (describedBy) => <span data-slot="product-switch" aria-describedby={describedBy} />, disabled: true, reason: "Only the current version" }} />,
57
- );
58
- const field = bySlot(off, "site-toggle-field")[0];
59
- expect(field?.name).toBe("label");
60
- expect(field?.attributes["data-disabled"]).toBe("true");
61
- expect(field?.attributes.title).toBe("Only the current version");
62
- const described = bySlot(off, "product-switch")[0]?.attributes["aria-describedby"];
63
- expect(described).toBeTruthy();
64
- expect(off).toContain(`id="${described}">Only the current version</span>`);
65
- expect(silentRefusals(off)).toEqual([]);
66
- const on = renderToStaticMarkup(<VersionPicker select={<span />} compare={{ label: "Show changes", control: (describedBy) => <span data-slot="product-switch" aria-describedby={describedBy} /> }} />);
67
- expect(bySlot(on, "site-toggle-field")[0]?.attributes.title).toBeUndefined();
68
- expect(bySlot(on, "product-switch")[0]?.attributes["aria-describedby"]).toBeUndefined();
69
- });
70
-
71
- it("prints the page from a small action, and marks a draft with a warning badge", () => {
72
- const html = renderToStaticMarkup(<PrintButton label="Save as PDF" onPrint={() => {}} />);
73
- expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
74
- expect(tabStops(html)).toHaveLength(1);
75
- const badge = renderToStaticMarkup(<SiteBadge tone="warn" title="A draft before legal review">Draft</SiteBadge>);
76
- expect(bySlot(badge, "site-badge")[0]?.attributes["data-tone"]).toBe("warn");
77
- expect(bySlot(badge, "site-badge")[0]?.attributes.title).toBe("A draft before legal review");
78
- });
79
-
80
- it("lists the changes with the legend of the marks, each change a button", () => {
81
- const html = renderToStaticMarkup(<ChangeList title="2 changes" added="Added" removed="Removed" changes={[{ key: "a", no: "Article 2", what: "Added editing" }]} />);
82
- expect(bySlot(html, "site-change-legend").map((legend) => [legend.name, legend.attributes["data-kind"]])).toEqual([
83
- ["ins", "added"],
84
- ["del", "removed"],
85
- ]);
86
- expect(bySlot(html, "site-change-link")[0]?.name).toBe("button");
87
- expect(unmarked(html)).toEqual([]);
88
- });
89
- });
90
-
91
- describe("the legal body parts", () => {
92
- it("draws an article's numbered heading, its summary and its circled clauses", () => {
93
- const html = renderToStaticMarkup(
94
- <LegalArticle id="t-ai" no="Article 7" title="Labelling AI content" was="was Article 6" added summary={<PlainSummary label="In short">AI content is marked.</PlainSummary>}>
95
- <ClauseList items={[{ key: "a", content: "Notes are marked." }, { key: "b", content: "Videos too." }]} />
96
- </LegalArticle>,
97
- );
98
- const article = bySlot(html, "site-legal-article")[0];
99
- expect(article?.attributes.id).toBe("t-ai");
100
- expect(article?.attributes["data-added"]).toBe("true");
101
- expect(article?.attributes["data-kind"]).toBe("article");
102
- expect(html).toContain(">①</span>");
103
- expect(html).toContain(">②</span>");
104
- expect(bySlot(html, "site-legal-article-was")[0]?.name).toBe("small");
105
- expect(unmarked(html)).toEqual([]);
106
- });
107
-
108
- it("reads its heading as words in the text a screen reader or a copy takes: number, title, previous number and tag apart", () => {
109
- const html = renderToStaticMarkup(<LegalArticle id="t-ai" no="Article 7" title="Labelling AI content" was="was Article 6" tag={<span>New</span>} />);
110
- const heading = /<h2[^>]*>([\s\S]*?)<\/h2>/.exec(html)?.[1] ?? "";
111
- expect(heading.replace(/<[^>]*>/g, "")).toBe("Article 7 Labelling AI content was Article 6 New");
112
- const bare = /<h2[^>]*>([\s\S]*?)<\/h2>/.exec(renderToStaticMarkup(<LegalArticle id="t-x" no="Article 8" title="Effective date" />))?.[1] ?? "";
113
- expect(bare.replace(/<[^>]*>/g, "")).toBe("Article 8 Effective date");
114
- });
115
-
116
- it("sets the closing provisions closer together", () => {
117
- const html = renderToStaticMarkup(<LegalArticle id="t-addendum" kind="addendum" no="Addendum" title="Effective date" />);
118
- expect(bySlot(html, "site-legal-article")[0]?.attributes["data-kind"]).toBe("addendum");
119
- });
120
-
121
- it("lays labelled values in a definition list, the value two columns wide, stacked below the narrow tier", () => {
122
- const html = renderToStaticMarkup(
123
- <InfoGrid id="b-info">
124
- <InfoCard title="Business information" action={{ id: "check", label: "Check", tone: "quiet" }}>
125
- <KeyValues rows={[{ key: "c", label: "Company", value: "Example Inc." }]} />
126
- </InfoCard>
127
- </InfoGrid>,
128
- );
129
- expect(bySlot(html, "site-key-values")[0]?.name).toBe("dl");
130
- expect(bySlot(html, "site-key")[0]?.name).toBe("dt");
131
- expect(bySlot(html, "site-value")[0]?.name).toBe("dd");
132
- expect(bySlot(html, "site-info-grid")[0]?.attributes.id).toBe("b-info");
133
- expect(siteKeyValuesStyle.base).toContain("@max-page-narrow/page:grid-cols-1");
134
- expect(siteValueStyle.base).toContain("col-span-2");
135
- expect(siteInfoGridStyle.base).toContain("@max-page-narrow/page:grid-cols-1");
136
- expect(unmarked(html)).toEqual([]);
137
- });
138
- });
139
-
140
- describe("DocLayout", () => {
141
- const draw = (jump?: string) =>
142
- renderToStaticMarkup(
143
- <DocLayout crumbs={[]} crumbsLabel="Trail" title="Terms" tocTitle="Contents" toc={[{ id: "t-pay", no: "Article 4", title: "Payment" }, { id: "t-end", title: "Effective date" }]} current={null} onJump={() => undefined} {...(jump === undefined ? {} : { jump: <span>{jump}</span> })}>
144
- <p>Body</p>
145
- </DocLayout>,
146
- );
147
-
148
- it("draws its own jump select over the rail's sections, named by the rail's title, when the page hands none", () => {
149
- const html = draw();
150
- const jump = bySlot(html, "site-toc-jump")[0];
151
- expect(jump).toBeDefined();
152
- expect(html).toContain('aria-label="Contents"');
153
- expect(html).toContain("Article 4 Payment");
154
- });
155
-
156
- it("draws the page's own jump control in its place when it hands one", () => {
157
- const html = draw("own control");
158
- expect(html).toContain("own control");
159
- expect(html).not.toContain("Article 4 Payment");
160
- });
161
- });