@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.
- package/README.md +4 -3
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.js +3 -3
- package/dist/action/index.d.ts +59 -3
- package/dist/action/index.js +82 -0
- package/dist/action/index.js.map +1 -1
- package/dist/checkout/index.d.ts +1 -1
- package/dist/checkout/index.js +1 -1
- package/dist/{chunk-BJUU2WTX.js → chunk-EELJOGWB.js} +12 -5
- package/dist/chunk-EELJOGWB.js.map +1 -0
- package/dist/{chunk-7K476KMZ.js → chunk-EOTYGKKM.js} +3 -3
- package/dist/{chunk-7K476KMZ.js.map → chunk-EOTYGKKM.js.map} +1 -1
- package/dist/{chunk-FKC262N4.js → chunk-EWBTUSZY.js} +9 -3
- package/dist/chunk-EWBTUSZY.js.map +1 -0
- package/dist/{chunk-5TFLOQT6.js → chunk-HRRP6HMF.js} +10 -5
- package/dist/chunk-HRRP6HMF.js.map +1 -0
- package/dist/{chunk-4KFQ26JW.js → chunk-HZGBIIGN.js} +27 -6
- package/dist/chunk-HZGBIIGN.js.map +1 -0
- package/dist/{chunk-JJQJFRBI.js → chunk-OWQVRM4W.js} +3 -3
- package/dist/{chunk-JJQJFRBI.js.map → chunk-OWQVRM4W.js.map} +1 -1
- package/dist/{chunk-6S23FFBB.js → chunk-TGG4ZKPG.js} +3 -3
- package/dist/{chunk-6S23FFBB.js.map → chunk-TGG4ZKPG.js.map} +1 -1
- package/dist/{chunk-JVMJF5JJ.js → chunk-UF2MDCWB.js} +5 -5
- package/dist/chunk-UF2MDCWB.js.map +1 -0
- package/dist/{chunk-EG6GE3YS.js → chunk-YXASVWY7.js} +3 -3
- package/dist/{chunk-EG6GE3YS.js.map → chunk-YXASVWY7.js.map} +1 -1
- package/dist/content/index.d.ts +95 -0
- package/dist/content/index.js +85 -0
- package/dist/content/index.js.map +1 -0
- package/dist/form/index.d.ts +229 -8
- package/dist/form/index.js +150 -10
- package/dist/form/index.js.map +1 -1
- package/dist/help/index.d.ts +1 -1
- package/dist/help/index.js +6 -6
- package/dist/install/index.d.ts +1 -1
- package/dist/install/index.js +4 -4
- package/dist/legal/index.d.ts +2 -2
- package/dist/legal/index.js +5 -5
- package/dist/link/index.d.ts +14 -1
- package/dist/link/index.js +8 -1
- package/dist/link/index.js.map +1 -1
- package/dist/marketing/index.d.ts +1 -1
- package/dist/page/index.d.ts +2 -2
- package/dist/page/index.js +4 -4
- package/dist/pricing/index.d.ts +1 -1
- package/dist/pricing/index.js +2 -2
- package/dist/shell/index.d.ts +1 -1
- package/dist/{site-action-B79fuwMb.d.ts → site-action-CPpf8JZl.d.ts} +1 -1
- package/dist/{site-page-Dl0A5T1N.d.ts → site-page-DKcjqh9y.d.ts} +7 -2
- package/package.json +10 -3
- package/src/action/action-tile.style.ts +63 -0
- package/src/action/action-tile.tsx +83 -0
- package/src/action/index.ts +11 -0
- package/src/content/content.style.ts +72 -0
- package/src/content/content.tsx +124 -0
- package/src/content/index.ts +12 -0
- package/src/form/choices.style.ts +16 -0
- package/src/form/choices.tsx +28 -5
- package/src/form/country-field.tsx +61 -0
- package/src/form/date-time.style.ts +26 -0
- package/src/form/date-time.tsx +123 -0
- package/src/form/dialog.style.ts +4 -2
- package/src/form/errors.tsx +16 -4
- package/src/form/form.style.ts +8 -0
- package/src/form/index.ts +11 -1
- package/src/form/phone-field.tsx +98 -0
- package/src/form/select.style.ts +6 -1
- package/src/form/select.tsx +13 -3
- package/src/form/signature.style.ts +20 -0
- package/src/form/signature.tsx +46 -0
- package/src/link/index.ts +1 -0
- package/src/link/mounted-href.ts +16 -0
- package/src/page/site-page.style.ts +13 -4
- package/src/page/site-page.tsx +8 -3
- package/src/styles/designs/base.css +121 -4
- package/templates/app-shell.hbs +5 -4
- package/dist/chunk-4KFQ26JW.js.map +0 -1
- package/dist/chunk-5TFLOQT6.js.map +0 -1
- package/dist/chunk-BJUU2WTX.js.map +0 -1
- package/dist/chunk-FKC262N4.js.map +0 -1
- package/dist/chunk-JVMJF5JJ.js.map +0 -1
- package/src/account/account.test.tsx +0 -186
- package/src/action/site-action.test.tsx +0 -154
- package/src/auth/auth.test.tsx +0 -132
- package/src/checkout/checkout.test.tsx +0 -187
- package/src/form/choices-field.test.tsx +0 -20
- package/src/form/errors.test.tsx +0 -49
- package/src/form/form.test.tsx +0 -275
- package/src/form/question-focus.test.ts +0 -182
- package/src/form/slider.test.tsx +0 -148
- package/src/form/typed-text.test.ts +0 -52
- package/src/help/article.test.tsx +0 -189
- package/src/help/help.test.tsx +0 -215
- package/src/help/screen-sketch.test.tsx +0 -59
- package/src/install/install.test.tsx +0 -177
- package/src/legal/legal.test.tsx +0 -161
- package/src/legal/policy.test.tsx +0 -137
- package/src/legal/refund.test.tsx +0 -148
- package/src/link/routes-in-page.test.ts +0 -26
- package/src/link/site-link.test.ts +0 -10
- package/src/marketing/marketing.test.tsx +0 -221
- package/src/page/site-failure.test.tsx +0 -65
- package/src/page/site-page.test.tsx +0 -109
- package/src/page/site-read.test.tsx +0 -41
- package/src/pricing/pack-card.test.tsx +0 -107
- package/src/pricing/pricing.test.tsx +0 -261
- package/src/shell/refusal-page.test.ts +0 -19
- package/src/shell/site-scheme-param.test.ts +0 -53
- package/src/shell/site-scheme-switch.test.ts +0 -80
- package/src/shell/site-scheme.test.ts +0 -149
- package/src/shell/site-shell.test.tsx +0 -401
- package/src/testing/markup.ts +0 -65
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { SiteChip } from "../page/site-bits";
|
|
5
|
-
import { bySlot, silentRefusals, tabStops, unmarked } from "../testing/markup";
|
|
6
|
-
import { InfoCard, KeyValues } from "./legal-parts";
|
|
7
|
-
import { AgencyGrid, GlanceGrid, LegalSection, RightsGrid } from "./policy-parts";
|
|
8
|
-
|
|
9
|
-
const noop = () => {};
|
|
10
|
-
|
|
11
|
-
describe("LegalSection", () => {
|
|
12
|
-
it("draws a plain section's heading straight under the section", () => {
|
|
13
|
-
const html = renderToStaticMarkup(
|
|
14
|
-
<LegalSection id="p-1" heading="2. What we collect">
|
|
15
|
-
<p data-slot="product-text">Words</p>
|
|
16
|
-
</LegalSection>,
|
|
17
|
-
);
|
|
18
|
-
const section = bySlot(html, "site-legal-section")[0];
|
|
19
|
-
expect(section?.attributes.id).toBe("p-1");
|
|
20
|
-
expect(section?.attributes["data-tone"]).toBe("plain");
|
|
21
|
-
expect(bySlot(html, "site-legal-section-head")).toHaveLength(0);
|
|
22
|
-
expect(bySlot(html, "site-doc-heading")[0]?.name).toBe("h2");
|
|
23
|
-
expect(unmarked(html)).toEqual([]);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("sets the voice section apart and puts its chip before the heading in one row", () => {
|
|
27
|
-
const html = renderToStaticMarkup(
|
|
28
|
-
<LegalSection id="p-2" tone="voice" heading="3. Your voice" chip={<SiteChip tone="voice">Biometric data</SiteChip>} action={{ id: "transfer", label: "See 4. Transfers abroad", tone: "quiet", onSelect: noop }} />,
|
|
29
|
-
);
|
|
30
|
-
expect(bySlot(html, "site-legal-section")[0]?.attributes["data-tone"]).toBe("voice");
|
|
31
|
-
expect(html.indexOf('data-slot="site-legal-section-head"')).toBeLessThan(html.indexOf('data-slot="site-chip"'));
|
|
32
|
-
expect(html.indexOf('data-slot="site-chip"')).toBeLessThan(html.indexOf('data-slot="site-doc-heading"'));
|
|
33
|
-
expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
|
|
34
|
-
expect(unmarked(html)).toEqual([]);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe("GlanceGrid", () => {
|
|
39
|
-
it("makes every card a button that jumps, the one about the voice in the voice tone", () => {
|
|
40
|
-
const html = renderToStaticMarkup(
|
|
41
|
-
<GlanceGrid
|
|
42
|
-
items={[
|
|
43
|
-
{ key: "collect", title: "What we collect", text: "Email, payment and usage records", onSelect: noop },
|
|
44
|
-
{ key: "voice", title: "Biometric data", text: "Your voice", voice: true, onSelect: noop },
|
|
45
|
-
]}
|
|
46
|
-
/>,
|
|
47
|
-
);
|
|
48
|
-
const cards = bySlot(html, "site-glance");
|
|
49
|
-
expect(cards.map((card) => card.attributes["data-tone"])).toEqual(["plain", "voice"]);
|
|
50
|
-
expect(tabStops(html)).toHaveLength(2);
|
|
51
|
-
expect(cards.every((card) => card.attributes.type === "button")).toBe(true);
|
|
52
|
-
expect(unmarked(html)).toEqual([]);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("RightsGrid", () => {
|
|
57
|
-
it("draws the reason under the cards and describes every disabled right by it, and draws no reason when every right can be used", () => {
|
|
58
|
-
const html = renderToStaticMarkup(
|
|
59
|
-
<RightsGrid
|
|
60
|
-
reason="Opens with the account pages."
|
|
61
|
-
items={[
|
|
62
|
-
{ key: "data", title: "See my data", text: "We bundle your records.", action: { id: "data", label: "My data", disabled: true, reason: "Opens once accounts are live" } },
|
|
63
|
-
{ key: "fix", title: "Correct", text: "Change your email.", action: { id: "fix", label: "Sign-in", href: "/me" } },
|
|
64
|
-
]}
|
|
65
|
-
/>,
|
|
66
|
-
);
|
|
67
|
-
expect(silentRefusals(html)).toEqual([]);
|
|
68
|
-
expect(bySlot(html, "site-caption")).toHaveLength(1);
|
|
69
|
-
const open = renderToStaticMarkup(<RightsGrid reason="Never shown" items={[{ key: "fix", title: "Correct", text: "Change your email.", action: { id: "fix", label: "Sign-in", href: "/me" } }]} />);
|
|
70
|
-
expect(bySlot(open, "site-caption")).toHaveLength(0);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("describes a right that cannot be used yet by the line that says why", () => {
|
|
74
|
-
const described = renderToStaticMarkup(
|
|
75
|
-
<>
|
|
76
|
-
<RightsGrid items={[{ key: "data", title: "See my data", text: "We bundle your records.", action: { id: "data", label: "My account › My data", disabled: true, reason: "Opens once accounts are live", describedBy: "why" } }]} />
|
|
77
|
-
<p id="why">Opens with the account pages.</p>
|
|
78
|
-
</>,
|
|
79
|
-
);
|
|
80
|
-
expect(silentRefusals(described)).toEqual([]);
|
|
81
|
-
const silent = renderToStaticMarkup(<RightsGrid items={[{ key: "data", title: "See my data", text: "We bundle your records.", action: { id: "data", label: "My account › My data", disabled: true, reason: "Opens once accounts are live" } }]} />);
|
|
82
|
-
// Without a line on the page the action is described by its own reason, drawn for a screen reader only.
|
|
83
|
-
expect(silentRefusals(silent)).toEqual([]);
|
|
84
|
-
expect(bySlot(silent, "site-action")[0]?.attributes["aria-describedby"]).toBe(bySlot(silent, "site-action-reason")[0]?.attributes.id);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("draws each right as a card with its title, words and a small action", () => {
|
|
88
|
-
const html = renderToStaticMarkup(<RightsGrid items={[{ key: "fix", title: "Correct", text: "Change your email.", action: { id: "fix", label: "Sign-in and devices", href: "/me" } }]} />);
|
|
89
|
-
expect(bySlot(html, "site-rights-card")[0]?.name).toBe("section");
|
|
90
|
-
expect(bySlot(html, "site-action")[0]?.attributes["data-size"]).toBe("sm");
|
|
91
|
-
expect(unmarked(html)).toEqual([]);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("AgencyGrid", () => {
|
|
96
|
-
it("draws an agency's name, number and site in that order", () => {
|
|
97
|
-
const html = renderToStaticMarkup(<AgencyGrid items={[{ key: "kisa", name: "Report Center", phone: "118", site: "privacy.kisa.or.kr" }]} />);
|
|
98
|
-
const order = ["site-agency-name", "site-agency-phone", "site-agency-site"].map((slot) => html.indexOf(`data-slot="${slot}"`));
|
|
99
|
-
expect(order).toEqual([...order].sort((a, b) => a - b));
|
|
100
|
-
expect(order.every((at) => at > 0)).toBe(true);
|
|
101
|
-
expect(unmarked(html)).toEqual([]);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe("InfoCard", () => {
|
|
106
|
-
const rows = <KeyValues rows={[{ key: "mail", label: "Email", value: "privacy@example.com" }]} />;
|
|
107
|
-
|
|
108
|
-
it("draws a card of values alone, without a heading", () => {
|
|
109
|
-
const html = renderToStaticMarkup(<InfoCard>{rows}</InfoCard>);
|
|
110
|
-
expect(bySlot(html, "site-info-card-title")).toHaveLength(0);
|
|
111
|
-
expect(bySlot(html, "site-key-values")).toHaveLength(1);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("describes a disabled action by its reason line, and draws no line for an action that runs", () => {
|
|
115
|
-
const off = renderToStaticMarkup(
|
|
116
|
-
<InfoCard title="Business information" action={{ id: "verify", label: "Check business details", tone: "quiet", disabled: true, reason: "Checked once registration is done." }} reason="Checked once registration is done.">
|
|
117
|
-
{rows}
|
|
118
|
-
</InfoCard>,
|
|
119
|
-
);
|
|
120
|
-
expect(silentRefusals(off)).toEqual([]);
|
|
121
|
-
expect(bySlot(off, "site-caption")).toHaveLength(1);
|
|
122
|
-
const silent = renderToStaticMarkup(
|
|
123
|
-
<InfoCard title="Business information" action={{ id: "verify", label: "Check business details", tone: "quiet", disabled: true, reason: "Checked once registration is done." }}>
|
|
124
|
-
{rows}
|
|
125
|
-
</InfoCard>,
|
|
126
|
-
);
|
|
127
|
-
// Without a line on the page the action is described by its own reason, drawn for a screen reader only.
|
|
128
|
-
expect(silentRefusals(silent)).toEqual([]);
|
|
129
|
-
expect(bySlot(silent, "site-action")[0]?.attributes["aria-describedby"]).toBe(bySlot(silent, "site-action-reason")[0]?.attributes.id);
|
|
130
|
-
const on = renderToStaticMarkup(
|
|
131
|
-
<InfoCard title="Support" action={{ id: "contact", label: "Contact us", tone: "primary", href: "/help" }} reason="Never shown">
|
|
132
|
-
{rows}
|
|
133
|
-
</InfoCard>,
|
|
134
|
-
);
|
|
135
|
-
expect(bySlot(on, "site-caption")).toHaveLength(0);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { bySlot, silentRefusals, tabStops, unmarked } from "../testing/markup";
|
|
5
|
-
import { RefundCalculator, RefundHow, RefundProduct, RefundRule, Walkthrough, WalkthroughMenu, WalkthroughPages } from "./refund-parts";
|
|
6
|
-
|
|
7
|
-
const noop = () => {};
|
|
8
|
-
|
|
9
|
-
describe("the refund table's cells", () => {
|
|
10
|
-
it("draws a product with its terms under it", () => {
|
|
11
|
-
const html = renderToStaticMarkup(<RefundProduct product="Presentation pack" detail="₩9,900 · once" />);
|
|
12
|
-
expect(bySlot(html, "site-refund-detail")[0]?.name).toBe("small");
|
|
13
|
-
expect(unmarked(html)).toEqual([]);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("gives a verdict and its dot the case's tone, and draws a note only where there is one", () => {
|
|
17
|
-
const html = renderToStaticMarkup(<RefundRule kind="part" label="The remaining period" note="Past months at the monthly price" />);
|
|
18
|
-
expect(bySlot(html, "site-refund-verdict")[0]?.attributes["data-kind"]).toBe("part");
|
|
19
|
-
expect(bySlot(html, "site-refund-dot")[0]?.attributes["data-kind"]).toBe("part");
|
|
20
|
-
expect(bySlot(html, "site-refund-note")).toHaveLength(1);
|
|
21
|
-
expect(bySlot(renderToStaticMarkup(<RefundRule kind="full" label="Full refund" />), "site-refund-note")).toHaveLength(0);
|
|
22
|
-
expect(unmarked(html)).toEqual([]);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe("RefundCalculator", () => {
|
|
27
|
-
const props = {
|
|
28
|
-
title: "Cancelling a yearly plan now: how much comes back?",
|
|
29
|
-
choice: <span data-slot="product-switch" />,
|
|
30
|
-
usedLabel: "Time used",
|
|
31
|
-
range: { label: "Months used", min: 1, max: 12, value: 3, onValueChange: noop },
|
|
32
|
-
output: "3 months",
|
|
33
|
-
usedShare: 0.25,
|
|
34
|
-
usedBar: "Used",
|
|
35
|
-
backBar: "Refunded",
|
|
36
|
-
formula: "₩149,000 − 3 × ₩14,900",
|
|
37
|
-
basis: "This month counts as used",
|
|
38
|
-
amount: "₩104,300",
|
|
39
|
-
note: "No penalty.",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
it("names the card by its question and splits the year at the share used", () => {
|
|
43
|
-
const html = renderToStaticMarkup(<RefundCalculator {...props} announce={null} />);
|
|
44
|
-
expect(bySlot(html, "site-refund-calc")[0]?.attributes["aria-label"]).toBe(props.title);
|
|
45
|
-
expect(bySlot(html, "site-refund-bar-used")[0]?.attributes.style).toBe("flex-basis:25%");
|
|
46
|
-
expect(bySlot(html, "site-refund-bar")[0]?.attributes["aria-hidden"]).toBe("true");
|
|
47
|
-
expect(unmarked(html)).toEqual([]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("draws the months used on the site slider between the row's words and the months chosen", () => {
|
|
51
|
-
const html = renderToStaticMarkup(<RefundCalculator {...props} announce={null} />);
|
|
52
|
-
const order = ["site-refund-calc-label", "site-slider", "site-refund-calc-output"].map((slot) => html.indexOf(`data-slot="${slot}"`));
|
|
53
|
-
expect(order.every((at, i) => at > -1 && (i === 0 || at > (order[i - 1] ?? 0)))).toBe(true);
|
|
54
|
-
const thumb = bySlot(html, "site-slider-thumb")[0];
|
|
55
|
-
expect(thumb?.attributes.role).toBe("slider");
|
|
56
|
-
expect(thumb?.attributes["aria-label"]).toBe("Months used");
|
|
57
|
-
expect(thumb?.attributes["aria-valuenow"]).toBe("3");
|
|
58
|
-
expect(html).not.toContain('type="range"');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("speaks the amount only once the reader moved something", () => {
|
|
62
|
-
const quiet = renderToStaticMarkup(<RefundCalculator {...props} announce={null} />);
|
|
63
|
-
expect(quiet).toContain('role="status"></span>');
|
|
64
|
-
const spoken = renderToStaticMarkup(<RefundCalculator {...props} announce="₩104,300" />);
|
|
65
|
-
expect(spoken).toContain('role="status">₩104,300</span>');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe("RefundHow", () => {
|
|
70
|
-
const steps = (third: { disabled?: boolean }) => [
|
|
71
|
-
{ key: "open", title: "Open My account", text: "Press your name", current: true, onSelect: noop },
|
|
72
|
-
{ key: "pick", title: "Pick the receipt", text: "Each payment has its row", onSelect: noop },
|
|
73
|
-
{ key: "ask", title: "Request the refund", text: "See the amount", onSelect: noop, ...third },
|
|
74
|
-
];
|
|
75
|
-
|
|
76
|
-
it("marks the step shown and takes a step that cannot be shown out of the keyboard order, described by the reason", () => {
|
|
77
|
-
const html = renderToStaticMarkup(
|
|
78
|
-
<RefundHow steps={steps({ disabled: true })} status="Open My account" reason={{ id: "why", text: "Opens with the receipts." }}>
|
|
79
|
-
<span data-slot="product-picture" />
|
|
80
|
-
</RefundHow>,
|
|
81
|
-
);
|
|
82
|
-
const picks = bySlot(html, "site-step-pick");
|
|
83
|
-
expect(picks.map((pick) => pick.attributes["data-current"])).toEqual(["true", "false", "false"]);
|
|
84
|
-
expect(picks[0]?.attributes["aria-current"]).toBe("step");
|
|
85
|
-
expect(picks[2]?.attributes.disabled).toBeDefined();
|
|
86
|
-
expect(picks[2]?.attributes["aria-describedby"]).toBe("why");
|
|
87
|
-
expect(html).toContain('id="why"');
|
|
88
|
-
expect(tabStops(html)).toHaveLength(2);
|
|
89
|
-
expect(unmarked(html)).toEqual([]);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("describes no step and draws no reason when every step can be shown", () => {
|
|
93
|
-
const html = renderToStaticMarkup(
|
|
94
|
-
<RefundHow steps={steps({})} status="Open My account">
|
|
95
|
-
<span data-slot="product-picture" />
|
|
96
|
-
</RefundHow>,
|
|
97
|
-
);
|
|
98
|
-
expect(bySlot(html, "site-step-pick").some((pick) => pick.attributes["aria-describedby"] !== undefined)).toBe(false);
|
|
99
|
-
expect(bySlot(html, "site-caption")).toHaveLength(0);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("ticks a passed step in place of its number", () => {
|
|
103
|
-
const html = renderToStaticMarkup(
|
|
104
|
-
<RefundHow steps={[{ key: "open", title: "Open", text: "Press", done: true, onSelect: noop }]} doneMark={<svg data-slot="product-tick" />} status="">
|
|
105
|
-
<span data-slot="product-picture" />
|
|
106
|
-
</RefundHow>,
|
|
107
|
-
);
|
|
108
|
-
expect(bySlot(html, "site-step-pick-disc")[0]?.attributes["data-done"]).toBe("true");
|
|
109
|
-
expect(bySlot(html, "product-tick")).toHaveLength(1);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe("Walkthrough", () => {
|
|
114
|
-
it("draws the menu with the entry to press marked and the next step's primary button", () => {
|
|
115
|
-
const html = renderToStaticMarkup(
|
|
116
|
-
<Walkthrough head="stagevoice.example" foot={{ text: "Next: Pick the receipt", action: { id: "next", label: "Next", onSelect: noop } }}>
|
|
117
|
-
<WalkthroughMenu
|
|
118
|
-
email="taylor@example.com"
|
|
119
|
-
items={[
|
|
120
|
-
{ key: "account", label: "My account", current: true },
|
|
121
|
-
{ key: "help", label: "Help" },
|
|
122
|
-
]}
|
|
123
|
-
/>
|
|
124
|
-
</Walkthrough>,
|
|
125
|
-
);
|
|
126
|
-
expect(bySlot(html, "site-walkthrough-stage")[0]?.attributes["data-align"]).toBe("end");
|
|
127
|
-
expect(bySlot(html, "site-walkthrough-menu-item").map((item) => item.attributes["data-current"])).toEqual(["true", "false"]);
|
|
128
|
-
const next = bySlot(html, "site-action")[0];
|
|
129
|
-
expect(next?.attributes["data-tone"]).toBe("primary");
|
|
130
|
-
expect(next?.attributes["data-size"]).toBe("sm");
|
|
131
|
-
expect(unmarked(html)).toEqual([]);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("leaves the address out for a reader who is not signed in, and describes a next step that cannot be shown", () => {
|
|
135
|
-
const html = renderToStaticMarkup(
|
|
136
|
-
<>
|
|
137
|
-
<Walkthrough head="My account" foot={{ text: "Next: Request the refund", action: { id: "next", label: "Next", disabled: true, reason: "Pick a step first", describedBy: "why" } }}>
|
|
138
|
-
<WalkthroughPages items={[{ key: "receipts", label: "Receipts", current: true }]} />
|
|
139
|
-
</Walkthrough>
|
|
140
|
-
<p id="why">Opens with the receipts.</p>
|
|
141
|
-
</>,
|
|
142
|
-
);
|
|
143
|
-
expect(bySlot(html, "site-walkthrough-menu-email")).toHaveLength(0);
|
|
144
|
-
expect(bySlot(html, "site-walkthrough-line").map((line) => line.attributes["data-size"])).toEqual(["title", "long", "short"]);
|
|
145
|
-
expect(silentRefusals(html)).toEqual([]);
|
|
146
|
-
expect(bySlot(renderToStaticMarkup(<WalkthroughMenu items={[]} />), "site-walkthrough-menu-email")).toHaveLength(0);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { routesInPage, type SitePress } from "./routes-in-page";
|
|
4
|
-
|
|
5
|
-
const plain: SitePress = { button: 0, metaKey: false, ctrlKey: false, shiftKey: false, altKey: false, defaultPrevented: false };
|
|
6
|
-
const ORIGIN = "https://portal.example.test";
|
|
7
|
-
|
|
8
|
-
describe("routesInPage", () => {
|
|
9
|
-
it("routes a plain press on an address of the page's own origin, relative or absolute", () => {
|
|
10
|
-
expect(routesInPage(plain, "/pricing?cycle=yearly", {}, ORIGIN)).toBe(true);
|
|
11
|
-
expect(routesInPage(plain, `${ORIGIN}/help/novoice`, {}, ORIGIN)).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("leaves another origin's address, a download and a named window to the browser", () => {
|
|
15
|
-
expect(routesInPage(plain, "https://files.example.test/StageVoice.dmg", {}, ORIGIN)).toBe(false);
|
|
16
|
-
expect(routesInPage(plain, "https://id.example.test/realms/stagevoice/account", {}, ORIGIN)).toBe(false);
|
|
17
|
-
expect(routesInPage(plain, "/files/receipt.pdf", { download: "" }, ORIGIN)).toBe(false);
|
|
18
|
-
expect(routesInPage(plain, "/terms", { target: "_blank" }, ORIGIN)).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("leaves a press with a key, another button, or one a handler took to the browser", () => {
|
|
22
|
-
expect(routesInPage({ ...plain, metaKey: true }, "/pricing", {}, ORIGIN)).toBe(false);
|
|
23
|
-
expect(routesInPage({ ...plain, button: 1 }, "/pricing", {}, ORIGIN)).toBe(false);
|
|
24
|
-
expect(routesInPage({ ...plain, defaultPrevented: true }, "/pricing", {}, ORIGIN)).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { describe, expectTypeOf, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import type { SiteLinkProps } from "./site-link";
|
|
4
|
-
|
|
5
|
-
describe("SiteLinkProps", () => {
|
|
6
|
-
it("carries no ref, so an app on its own copy of the React types can hand the props to its anchor", () => {
|
|
7
|
-
expectTypeOf<SiteLinkProps>().not.toHaveProperty("ref");
|
|
8
|
-
expectTypeOf<SiteLinkProps>().toHaveProperty("href").toEqualTypeOf<string>();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { bySlot, tabStops, unmarked } from "../testing/markup";
|
|
5
|
-
import { HeroBand } from "./hero-band";
|
|
6
|
-
import { siteHeroInnerStyle, siteHeroTitleStyle, siteSplitStyle, siteStepsListStyle } from "./marketing.style";
|
|
7
|
-
import { seededLevels } from "./levels";
|
|
8
|
-
import { NumberedSteps, stepNumber } from "./numbered-steps";
|
|
9
|
-
import { PlayerCard, PlayToggle, ReadAlong, readWordAt, readWordState, SiteBars, SiteWave } from "./player";
|
|
10
|
-
import { SampleList, SampleRow, SplitSection } from "./sample-row";
|
|
11
|
-
|
|
12
|
-
describe("HeroBand", () => {
|
|
13
|
-
const hero = (over = {}) =>
|
|
14
|
-
renderToStaticMarkup(
|
|
15
|
-
<HeroBand
|
|
16
|
-
tone="dark"
|
|
17
|
-
eyebrow="VOICE YOUR DECK."
|
|
18
|
-
title="Speaker notes"
|
|
19
|
-
accent="in your own voice"
|
|
20
|
-
lede="Write notes for every slide."
|
|
21
|
-
actions={[
|
|
22
|
-
{ id: "download", label: "Download free", href: "/download", tone: "primary" },
|
|
23
|
-
{ id: "pricing", label: "See pricing", href: "/pricing" },
|
|
24
|
-
]}
|
|
25
|
-
facts="Windows · PowerPoint"
|
|
26
|
-
media={<span data-slot="product-media">player</span>}
|
|
27
|
-
{...over}
|
|
28
|
-
/>,
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
it("draws the eyebrow, the one h1 with its accent line, the lede, the actions, the facts and the media in that order", () => {
|
|
32
|
-
const html = hero();
|
|
33
|
-
expect(html.match(/<h1/g)).toHaveLength(1);
|
|
34
|
-
const order = ["site-hero-eyebrow", "site-hero-title", "site-hero-accent", "site-hero-lede", "site-hero-actions", "site-hero-facts", "site-hero-media"].map((slot) => html.indexOf(`data-slot="${slot}"`));
|
|
35
|
-
expect(order.every((at, i) => at > 0 && (i === 0 || at > (order[i - 1] ?? 0)))).toBe(true);
|
|
36
|
-
expect(unmarked(html.replace(/<span data-slot="product-media">player<\/span>/, ""))).toEqual([]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("reads its title and accent as two words in the h1's text, since the line break between them is no space to a reader of the text", () => {
|
|
40
|
-
const h1 = /<h1[^>]*>([\s\S]*?)<\/h1>/.exec(hero())?.[1] ?? "";
|
|
41
|
-
// The text a screen reader or a copy takes: tags dropped, entities left as written.
|
|
42
|
-
expect(h1.replace(/<[^>]*>/g, "")).toBe("Speaker notes in your own voice");
|
|
43
|
-
const bare = /<h1[^>]*>([\s\S]*?)<\/h1>/.exec(hero({ accent: undefined }))?.[1] ?? "";
|
|
44
|
-
expect(bare.replace(/<[^>]*>/g, "")).toBe("Speaker notes");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("is its own dark band when asked, and draws its actions large, the strongest first", () => {
|
|
48
|
-
const html = hero();
|
|
49
|
-
expect(bySlot(html, "site-hero")[0]?.attributes["data-band"]).toBe("dark");
|
|
50
|
-
const actions = bySlot(html, "site-action");
|
|
51
|
-
expect(actions.map((action) => [action.attributes["data-size"], action.attributes["data-tone"]])).toEqual([
|
|
52
|
-
["lg", "primary"],
|
|
53
|
-
["lg", "secondary"],
|
|
54
|
-
]);
|
|
55
|
-
expect(tabStops(html).map((stop) => stop.attributes.href)).toEqual(["/download", "/pricing"]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("draws no band mark on a light hero and leaves out what it is not handed", () => {
|
|
59
|
-
const html = renderToStaticMarkup(<HeroBand title="Speaker notes" />);
|
|
60
|
-
expect(bySlot(html, "site-hero")[0]?.attributes["data-band"]).toBeUndefined();
|
|
61
|
-
for (const slot of ["site-hero-eyebrow", "site-hero-accent", "site-hero-lede", "site-hero-actions", "site-hero-facts", "site-hero-media"]) expect(bySlot(html, slot)).toEqual([]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("puts the media under the pitch below the medium tier and draws the title a step smaller below the narrow tier", () => {
|
|
65
|
-
expect(siteHeroInnerStyle.base).toContain("grid-cols-2");
|
|
66
|
-
expect(siteHeroInnerStyle.base).toContain("@max-page-medium/page:grid-cols-1");
|
|
67
|
-
expect(siteHeroInnerStyle.base).toContain("@max-page-narrow/page:px-4");
|
|
68
|
-
expect(siteHeroTitleStyle.base).toContain("@max-page-narrow/page:text-(length:--site-fs-display)");
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("PlayerCard and its parts", () => {
|
|
73
|
-
it("draws the choice, the sentence, the wave and the play row, the toggle saying what a press does", () => {
|
|
74
|
-
const html = renderToStaticMarkup(
|
|
75
|
-
<PlayerCard choice={<span data-slot="product-choice" />} text={<ReadAlong text="We save hours" at={null} />} playing={false} toggleLabel="Listen" caption="Free voice" />,
|
|
76
|
-
);
|
|
77
|
-
const toggle = bySlot(html, "site-play-toggle")[0];
|
|
78
|
-
expect(toggle?.name).toBe("button");
|
|
79
|
-
expect(toggle?.attributes["aria-label"]).toBe("Listen");
|
|
80
|
-
expect(toggle?.attributes["aria-pressed"]).toBe("false");
|
|
81
|
-
expect(bySlot(html, "site-player-caption")).toHaveLength(1);
|
|
82
|
-
expect(tabStops(html)).toHaveLength(1);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("presses the toggle while the sample plays", () => {
|
|
86
|
-
const html = renderToStaticMarkup(<PlayToggle playing label="Stop" />);
|
|
87
|
-
expect(bySlot(html, "site-play-toggle")[0]?.attributes["aria-pressed"]).toBe("true");
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("lights the word the voice reached, marks the words before it read and the ones after it waiting", () => {
|
|
91
|
-
expect([0, 1, 2, 3].map((index) => readWordState(index, 2))).toEqual(["read", "read", "spoken", "upcoming"]);
|
|
92
|
-
expect(readWordState(0, null)).toBe("rest");
|
|
93
|
-
const html = renderToStaticMarkup(<ReadAlong text="one two three four" at={2} />);
|
|
94
|
-
expect(bySlot(html, "site-read-word").map((word) => word.attributes["data-state"])).toEqual(["read", "read", "spoken", "upcoming"]);
|
|
95
|
-
expect(bySlot(html, "site-read-along")[0]?.attributes["aria-live"]).toBe("off");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("finds the word reached from the share played, never past the last word", () => {
|
|
99
|
-
expect(readWordAt(null, 10)).toBeNull();
|
|
100
|
-
expect(readWordAt(0, 10)).toBe(0);
|
|
101
|
-
expect(readWordAt(0.45, 10)).toBe(4);
|
|
102
|
-
expect(readWordAt(1, 10)).toBe(9);
|
|
103
|
-
expect(readWordAt(0.5, 0)).toBeNull();
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("draws a wave bar per level, the share played marked, with its name for a screen reader", () => {
|
|
107
|
-
const html = renderToStaticMarkup(<SiteWave levels={[0.5, 0.2, 1, 0.4]} progress={0.5} height={40} label="Voice waveform, 50% played" />);
|
|
108
|
-
const svg = bySlot(html, "site-wave")[0];
|
|
109
|
-
expect(svg?.attributes.role).toBe("img");
|
|
110
|
-
expect(svg?.attributes["aria-label"]).toBe("Voice waveform, 50% played");
|
|
111
|
-
expect(svg?.attributes.viewBox).toBe("0 0 16 40");
|
|
112
|
-
expect(bySlot(html, "site-wave-bar").map((bar) => bar.attributes["data-played"])).toEqual(["true", "true", "false", "false"]);
|
|
113
|
-
expect(unmarked(html)).toEqual([]);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("draws the same stand-in shape for a seed every time, as the reference design's waveform does", () => {
|
|
117
|
-
const shape = seededLevels("site-step-voice", 80);
|
|
118
|
-
expect(shape).toHaveLength(80);
|
|
119
|
-
// The reference design's generator gives these first levels for this seed; a changed hash, step
|
|
120
|
-
// or envelope draws a different picture than the design.
|
|
121
|
-
expect(shape.slice(0, 4).map((level) => level.toFixed(6))).toEqual(["0.572904", "0.425043", "0.702697", "0.234714"]);
|
|
122
|
-
expect(seededLevels("", 3).map((level) => level.toFixed(6))).toEqual(["0.148868", "0.327252", "0.486888"]);
|
|
123
|
-
expect(seededLevels("site-step-voice", 80)).toEqual(shape);
|
|
124
|
-
expect(seededLevels("site-hero-free", 80)).not.toEqual(shape);
|
|
125
|
-
expect(Math.min(...shape)).toBeGreaterThanOrEqual(0.07);
|
|
126
|
-
expect(Math.max(...shape)).toBeLessThanOrEqual(1);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("draws a picture of bars hidden from screen readers, each with its height or its share of the width", () => {
|
|
130
|
-
const html = renderToStaticMarkup(
|
|
131
|
-
<SiteBars
|
|
132
|
-
tone="strong"
|
|
133
|
-
bars={[
|
|
134
|
-
{ key: "a", grow: 22 },
|
|
135
|
-
{ key: "b", height: 12 },
|
|
136
|
-
]}
|
|
137
|
-
/>,
|
|
138
|
-
);
|
|
139
|
-
expect(bySlot(html, "site-bars")[0]?.attributes["aria-hidden"]).toBe("true");
|
|
140
|
-
const bars = bySlot(html, "site-bars-bar");
|
|
141
|
-
expect(bars.map((bar) => bar.attributes["data-tone"])).toEqual(["strong", "strong"]);
|
|
142
|
-
expect(bars[0]?.attributes.style).toBe("flex-grow:22");
|
|
143
|
-
expect(bars[1]?.attributes.style).toBe("height:12px");
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
describe("SampleRow", () => {
|
|
148
|
-
const row = (over = {}) => renderToStaticMarkup(<SampleRow name="Free" meta="On this computer" text="We save hours" playing={false} label="Listen to the free voice" {...over} />);
|
|
149
|
-
|
|
150
|
-
it("is one toggle naming what a press does, with the disc, the name, where it is made and the text", () => {
|
|
151
|
-
const html = row();
|
|
152
|
-
const button = bySlot(html, "site-sample")[0];
|
|
153
|
-
expect(button?.name).toBe("button");
|
|
154
|
-
expect(button?.attributes["aria-pressed"]).toBe("false");
|
|
155
|
-
expect(button?.attributes["aria-label"]).toBe("Listen to the free voice");
|
|
156
|
-
const order = ["site-sample-disc", "site-sample-name", "site-sample-meta", "site-sample-text"].map((slot) => html.indexOf(`data-slot="${slot}"`));
|
|
157
|
-
expect(order.every((at, i) => at > 0 && (i === 0 || at > (order[i - 1] ?? 0)))).toBe(true);
|
|
158
|
-
expect(unmarked(html)).toEqual([]);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it("puts the product's wave in the text's place while it plays", () => {
|
|
162
|
-
const html = row({ playing: true, playingMedia: <SiteWave levels={[0.3]} height={30} label="playing" /> });
|
|
163
|
-
expect(bySlot(html, "site-sample")[0]?.attributes["data-playing"]).toBe("true");
|
|
164
|
-
expect(bySlot(html, "site-sample-disc")[0]?.attributes["data-playing"]).toBe("true");
|
|
165
|
-
expect(bySlot(html, "site-sample-text")).toEqual([]);
|
|
166
|
-
expect(bySlot(html, "site-wave")).toHaveLength(1);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("cannot start while disabled, and can still stop when it is the one playing", () => {
|
|
170
|
-
expect(bySlot(row({ disabled: true }), "site-sample")[0]?.attributes.disabled).toBeDefined();
|
|
171
|
-
expect(bySlot(row({ disabled: true, playing: true }), "site-sample")[0]?.attributes.disabled).toBeUndefined();
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("stands in a list beside a display heading, one under the other below the medium tier", () => {
|
|
175
|
-
const html = renderToStaticMarkup(
|
|
176
|
-
<SplitSection heading="Hear free and premium" lede="Switch before you sign up.">
|
|
177
|
-
<SampleList>
|
|
178
|
-
<SampleRow name="Free" text="We save hours" playing={false} label="Listen" />
|
|
179
|
-
</SampleList>
|
|
180
|
-
</SplitSection>,
|
|
181
|
-
);
|
|
182
|
-
const section = bySlot(html, "site-split")[0];
|
|
183
|
-
const heading = bySlot(html, "site-display-heading")[0];
|
|
184
|
-
expect(section?.attributes["aria-labelledby"]).toBe(heading?.attributes.id);
|
|
185
|
-
expect(siteSplitStyle.base).toContain("@max-page-medium/page:grid-cols-1");
|
|
186
|
-
expect(unmarked(html)).toEqual([]);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe("NumberedSteps", () => {
|
|
191
|
-
it("numbers the steps in two digits and draws each card's picture, title and body, then the promises", () => {
|
|
192
|
-
const html = renderToStaticMarkup(
|
|
193
|
-
<NumberedSteps
|
|
194
|
-
heading="From notes to a ready presentation"
|
|
195
|
-
steps={[
|
|
196
|
-
{ key: "a", title: "Write notes", body: "From the slide.", media: <SiteBars bars={[{ key: "x", height: 8 }]} /> },
|
|
197
|
-
{ key: "b", title: "Make the voice", body: "Free or premium." },
|
|
198
|
-
]}
|
|
199
|
-
notes={[{ key: "n", label: "Never leaves your computer" }]}
|
|
200
|
-
noteMark={<svg data-slot="product-glyph" />}
|
|
201
|
-
/>,
|
|
202
|
-
);
|
|
203
|
-
expect(stepNumber(0)).toBe("01");
|
|
204
|
-
expect(stepNumber(11)).toBe("12");
|
|
205
|
-
expect(html).toContain(">01<");
|
|
206
|
-
expect(html).toContain(">02<");
|
|
207
|
-
expect(bySlot(html, "site-step")).toHaveLength(2);
|
|
208
|
-
expect(bySlot(html, "site-step-media")).toHaveLength(1);
|
|
209
|
-
expect(bySlot(html, "site-note")).toHaveLength(1);
|
|
210
|
-
expect(bySlot(html, "site-note-mark")[0]?.attributes["aria-hidden"]).toBe("true");
|
|
211
|
-
expect(bySlot(html, "site-steps-list")[0]?.name).toBe("ol");
|
|
212
|
-
expect(siteStepsListStyle.base).toContain("@max-page-medium/page:grid-cols-1");
|
|
213
|
-
expect(unmarked(html)).toEqual([]);
|
|
214
|
-
expect(tabStops(html)).toEqual([]);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("draws no promise line when there are none", () => {
|
|
218
|
-
const html = renderToStaticMarkup(<NumberedSteps heading="Steps" steps={[{ key: "a", title: "One", body: "First." }]} />);
|
|
219
|
-
expect(bySlot(html, "site-note-list")).toEqual([]);
|
|
220
|
-
});
|
|
221
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { bySlot, tagsOf, unmarked } from "../testing/markup";
|
|
5
|
-
import { SiteSpinner } from "./site-bits";
|
|
6
|
-
import { SiteFailure } from "./site-failure";
|
|
7
|
-
|
|
8
|
-
describe("SiteFailure", () => {
|
|
9
|
-
it("draws the mark, the one h1, the sentence and the ways on in that order, the actions at the large size", () => {
|
|
10
|
-
const html = renderToStaticMarkup(
|
|
11
|
-
<SiteFailure
|
|
12
|
-
mark={<svg data-slot="glyph" />}
|
|
13
|
-
title="We could not find this page"
|
|
14
|
-
body="The address may be mistyped."
|
|
15
|
-
actions={[
|
|
16
|
-
{ id: "home", label: "Go to the start", href: "/", tone: "primary" },
|
|
17
|
-
{ id: "help", label: "Open help", href: "/help", tone: "secondary" },
|
|
18
|
-
]}
|
|
19
|
-
/>,
|
|
20
|
-
);
|
|
21
|
-
expect(tagsOf(html)[0]?.attributes["data-slot"]).toBe("site-failure-mark");
|
|
22
|
-
expect(tagsOf(html)[0]?.attributes["aria-hidden"]).toBe("true");
|
|
23
|
-
expect(html.match(/<h1/g)).toHaveLength(1);
|
|
24
|
-
const at = ["site-failure-mark", "site-failure-title", "site-failure-text", "site-failure-actions"].map((slot) => html.indexOf(slot));
|
|
25
|
-
expect([...at].sort((a, b) => a - b)).toEqual(at);
|
|
26
|
-
expect(bySlot(html, "site-action").map((action) => [action.attributes["data-tone"], action.attributes["data-size"]])).toEqual([
|
|
27
|
-
["primary", "lg"],
|
|
28
|
-
["secondary", "lg"],
|
|
29
|
-
]);
|
|
30
|
-
expect(unmarked(html)).toEqual([]);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("marks the tone it is handed, quiet by default", () => {
|
|
34
|
-
const quiet = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} title="Not found" />);
|
|
35
|
-
const bad = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} tone="bad" title="This page could not be shown" />);
|
|
36
|
-
expect(bySlot(quiet, "site-failure-mark")[0]?.attributes["data-tone"]).toBe("quiet");
|
|
37
|
-
expect(bySlot(bad, "site-failure-mark")[0]?.attributes["data-tone"]).toBe("bad");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("marks the good tone for a done thing, the page a mail link opens", () => {
|
|
41
|
-
const good = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} tone="good" title="Your identity is checked" />);
|
|
42
|
-
expect(bySlot(good, "site-failure-mark")[0]?.attributes["data-tone"]).toBe("good");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("announces the sentence with the role it is handed, and with none when none is", () => {
|
|
46
|
-
const alert = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} title="Too many tries" body="Wait a little." live="alert" />);
|
|
47
|
-
const status = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} title="Checking your link" body="One moment." live="status" />);
|
|
48
|
-
const silent = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} title="Not found" body="The address may be mistyped." />);
|
|
49
|
-
expect(bySlot(alert, "site-failure-text")[0]?.attributes.role).toBe("alert");
|
|
50
|
-
expect(bySlot(status, "site-failure-text")[0]?.attributes.role).toBe("status");
|
|
51
|
-
expect(bySlot(silent, "site-failure-text")[0]?.attributes.role).toBeUndefined();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("holds a large wait ring in the mark while an answer is awaited, the small one elsewhere", () => {
|
|
55
|
-
const waiting = renderToStaticMarkup(<SiteFailure mark={<SiteSpinner size="lg" />} title="Checking your link" />);
|
|
56
|
-
expect(bySlot(waiting, "site-spinner")[0]?.attributes["data-size"]).toBe("lg");
|
|
57
|
-
expect(bySlot(renderToStaticMarkup(<SiteSpinner />), "site-spinner")[0]?.attributes["data-size"]).toBe("sm");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("draws no sentence and no action row when none is handed", () => {
|
|
61
|
-
const html = renderToStaticMarkup(<SiteFailure mark={<svg data-slot="glyph" />} title="Not found" />);
|
|
62
|
-
expect(bySlot(html, "site-failure-text")).toEqual([]);
|
|
63
|
-
expect(bySlot(html, "site-failure-actions")).toEqual([]);
|
|
64
|
-
});
|
|
65
|
-
});
|