@abyss-project/commons-front-core 17.2.1 → 18.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +2 -1
  3. package/catalog/captures-plan.ts +120 -116
  4. package/catalog/catalog-entries.ts +149 -148
  5. package/catalog/pages/AppShell.tsx +18 -9
  6. package/catalog/pages/CookieConsent.tsx +54 -31
  7. package/catalog/pages/DeliveryHistory.tsx +14 -1
  8. package/catalog/pages/DeliverySubscriptions.tsx +17 -0
  9. package/catalog/pages/index.ts +166 -165
  10. package/catalog/playwright.ci.config.ts +4 -3
  11. package/catalog/specs/cookie-consent-modal.spec.ts +187 -0
  12. package/dist/CookieConsentSettings-DUoKKRMZ.js +595 -0
  13. package/dist/{Surface-BDfRxVLj.js → Surface-z5TuQzlh.js} +38 -23
  14. package/dist/{Tabs-DEY2HEqj.js → Tabs-C4K0mLME.js} +613 -591
  15. package/dist/components/business/CookieConsent/AbyssCookieConsentProvider.d.ts +11 -3
  16. package/dist/components/business/CookieConsent/CookieConsentBanner.d.ts +4 -3
  17. package/dist/components/business/CookieConsent/CookieConsentPreferences.d.ts +12 -0
  18. package/dist/components/business/CookieConsent/index.d.ts +2 -0
  19. package/dist/components/business/CookieConsent/use-banner-portal.d.ts +36 -0
  20. package/dist/components/business/Deliveries/DeliveryHistory.component.d.ts +4 -3
  21. package/dist/components/business/Deliveries/DeliverySubscriptionForm.d.ts +3 -2
  22. package/dist/components/business/Deliveries/deliveries.logic.d.ts +11 -0
  23. package/dist/components/business/Deliveries/deliveries.types.d.ts +12 -4
  24. package/dist/components/inputs/NumberField/NumberField.d.ts +18 -2
  25. package/dist/components/layers/Toast/toast-clearance.d.ts +5 -0
  26. package/dist/components/structure/AccountMenu/AccountMenu.d.ts +2 -1
  27. package/dist/components/structure/AppShell/SpaceSwitcher.d.ts +4 -2
  28. package/dist/components/structure/AppShell/app-shell.types.d.ts +5 -1
  29. package/dist/components/structure/FilterBar/FilterBar.d.ts +7 -2
  30. package/dist/cookie-consent.js +26 -17
  31. package/dist/{design-theme-Bd0pEPei.js → design-theme-BFkCN7Nz.js} +1 -1
  32. package/dist/{editors-CtkDomwX.js → editors-Eb3PHnxn.js} +27 -27
  33. package/dist/editors.js +1 -1
  34. package/dist/hooks/use-cookie-consent.hook.spec.d.ts +1 -0
  35. package/dist/hooks/use-rich-intl.hook.d.ts +14 -2
  36. package/dist/{index-DtncSsmw.js → index-2lNOK7eK.js} +2 -2
  37. package/dist/{index-CqgMX8kF.js → index-B76nCWpd.js} +2 -2
  38. package/dist/{index-Cl3hwdsZ.js → index-BKRudpMw.js} +2 -2
  39. package/dist/{index-DtpGwH5a.js → index-BaL2x2GW.js} +3 -3
  40. package/dist/{index-CSdO6zlX.js → index-BcO-JFrs.js} +2 -2
  41. package/dist/{index-CEjiERmo.js → index-BlOP01yA.js} +2 -2
  42. package/dist/{index-IVjoNq-p.js → index-Bw4XnSa0.js} +2 -2
  43. package/dist/{index-DnQguWf1.js → index-CFDEfvCD.js} +1 -1
  44. package/dist/{index-FUuoLSZ0.js → index-CQ7z2zKY.js} +4 -4
  45. package/dist/{index-DcV2fWbx.js → index-CRFGogWn.js} +2 -2
  46. package/dist/{index-B9avfa3r.js → index-CUhMNEUo.js} +3 -3
  47. package/dist/{index-psJ1Q-lU.js → index-CWD0waD8.js} +2 -2
  48. package/dist/{index-DKsvuaEj.js → index-CYBvIQsH.js} +3 -3
  49. package/dist/{index-DFZlN4E3.js → index-Ckzcg8qD.js} +4 -4
  50. package/dist/{index-mUtvzoSi.js → index-Ckzmgx9X.js} +3 -3
  51. package/dist/{index-D0EF36wh.js → index-CrZZo4r1.js} +2 -2
  52. package/dist/{index-DZbCUZUp.js → index-CtVoDSIn.js} +2 -2
  53. package/dist/{index-SN7FZBya.js → index-CtkfWhK1.js} +2 -2
  54. package/dist/{index-DVBqUPxf.js → index-DRtBc440.js} +2 -2
  55. package/dist/{index-Ch8JqU5w.js → index-Dqm1dC1j.js} +2 -2
  56. package/dist/{index-BcXqvMY8.js → index-z5ZOXlY8.js} +4 -4
  57. package/dist/index.js +6073 -5920
  58. package/dist/legacy.js +1728 -1707
  59. package/dist/translations/en.d.ts +7 -1
  60. package/dist/translations/fr.d.ts +7 -1
  61. package/dist/utils/cookie-consent-contract.d.ts +55 -0
  62. package/dist/utils/cookie-consent-contract.spec.d.ts +1 -0
  63. package/dist/utils/cookie-storage.utils.d.ts +1 -8
  64. package/dist/utils/index.d.ts +1 -0
  65. package/package.json +5 -5
  66. package/dist/CookieConsentSettings-CtLrSfve.js +0 -505
@@ -0,0 +1,187 @@
1
+ import { expect, test } from '@playwright/test';
2
+ import type { Page } from '@playwright/test';
3
+ import { ThemeMode } from '../../src/theme/tokens/primitives';
4
+ import { openCatalogPage, settle } from './catalog-page';
5
+
6
+ // #747: while a modal, a wizard or a drawer is open, the cookie banner is not `aria-hidden` (what
7
+ // MUI puts on the other children of `body`: the banner was in the page, not in the modal) and does
8
+ // not cover the modal's main action. jsdom has no layout and no accessibility tree: this is read
9
+ // from Chromium itself, through the DevTools protocol. It does NOT prove the placement in the
10
+ // `aria-modal` surface: Chromium keeps what is outside that surface in its tree, so a banner put
11
+ // elsewhere in the modal passes too. That placement is proved by CookieConsent.spec.tsx.
12
+
13
+ const BANNER_BUTTON = 'Tout accepter';
14
+
15
+ /** Whether Chromium's accessibility tree holds a button of that name that is not ignored (not aria-hidden). */
16
+ const inAccessibilityTree = async (
17
+ page: Page,
18
+ buttonName: string,
19
+ ): Promise<boolean> => {
20
+ const cdp = await page.context().newCDPSession(page);
21
+ await cdp.send('Accessibility.enable');
22
+ const { nodes } = await cdp.send('Accessibility.getFullAXTree');
23
+ await cdp.detach();
24
+ return nodes.some(
25
+ (node) =>
26
+ node.role?.value === 'button' &&
27
+ node.name?.value === buttonName &&
28
+ node.ignored !== true,
29
+ );
30
+ };
31
+
32
+ const boxOf = async (page: Page, name: string) => {
33
+ const box = await page
34
+ .getByRole('button', { name, exact: true })
35
+ .boundingBox();
36
+ if (box === null) {
37
+ throw new Error(`The button « ${name} » has no box.`);
38
+ }
39
+ return box;
40
+ };
41
+
42
+ const overlaps = (
43
+ a: { x: number; y: number; width: number; height: number },
44
+ b: { x: number; y: number; width: number; height: number },
45
+ ): boolean =>
46
+ a.x < b.x + b.width &&
47
+ b.x < a.x + a.width &&
48
+ a.y < b.y + b.height &&
49
+ b.y < a.y + a.height;
50
+
51
+ const VIEWPORTS = [
52
+ { label: 'dialog', width: 1440, height: 900 },
53
+ { label: 'bottom sheet', width: 390, height: 844 },
54
+ ] as const;
55
+
56
+ for (const viewport of VIEWPORTS) {
57
+ test(`the banner is not aria-hidden and clear of « Suivant » over a ${viewport.label}`, async ({
58
+ page,
59
+ }) => {
60
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, viewport);
61
+ expect(await inAccessibilityTree(page, BANNER_BUTTON)).toBe(true);
62
+
63
+ await page.getByRole('button', { name: "Ouvrir l'assistant" }).click();
64
+ await expect(
65
+ page.getByRole('dialog', { name: 'Assistant de démarrage' }),
66
+ ).toBeVisible();
67
+ await settle(page);
68
+
69
+ expect(await inAccessibilityTree(page, BANNER_BUTTON)).toBe(true);
70
+ await expect(
71
+ page.getByRole('button', { name: BANNER_BUTTON }),
72
+ ).toBeVisible();
73
+
74
+ const next = await boxOf(page, 'Suivant');
75
+ const banner = await page
76
+ .getByRole('dialog', { name: 'Vos préférences de cookies' })
77
+ .boundingBox();
78
+ expect(banner).not.toBeNull();
79
+ expect(overlaps(next, banner!)).toBe(false);
80
+ // The browser agrees: what is at the middle of « Suivant » is « Suivant ».
81
+ const hit = await page.evaluate(
82
+ ({ x, y }) => document.elementFromPoint(x, y)?.textContent ?? '',
83
+ { x: next.x + next.width / 2, y: next.y + next.height / 2 },
84
+ );
85
+ expect(hit).toContain('Suivant');
86
+ });
87
+ }
88
+
89
+ test('the banner is not aria-hidden over a drawer and the drawer stops above it', async ({
90
+ page,
91
+ }) => {
92
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, {
93
+ width: 1440,
94
+ height: 900,
95
+ });
96
+ await page.getByRole('button', { name: "Ouvrir l'aperçu" }).click();
97
+ await expect(page.getByRole('dialog', { name: 'Aperçu' })).toBeVisible();
98
+ await settle(page);
99
+
100
+ expect(await inAccessibilityTree(page, BANNER_BUTTON)).toBe(true);
101
+ const drawer = await page
102
+ .getByRole('dialog', { name: 'Aperçu' })
103
+ .boundingBox();
104
+ const banner = await page
105
+ .getByRole('dialog', { name: 'Vos préférences de cookies' })
106
+ .boundingBox();
107
+ expect(drawer).not.toBeNull();
108
+ expect(banner).not.toBeNull();
109
+ expect(overlaps(drawer!, banner!)).toBe(false);
110
+ });
111
+
112
+ test('the banner comes back to the page, not aria-hidden, when the modal closes', async ({
113
+ page,
114
+ }) => {
115
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Light, {
116
+ width: 1440,
117
+ height: 900,
118
+ });
119
+ await page.getByRole('button', { name: "Ouvrir l'assistant" }).click();
120
+ await page.getByRole('button', { name: 'Suivant' }).click();
121
+ await expect(
122
+ page.getByRole('dialog', { name: 'Assistant de démarrage' }),
123
+ ).toHaveCount(0);
124
+ await settle(page);
125
+ expect(await inAccessibilityTree(page, BANNER_BUTTON)).toBe(true);
126
+ });
127
+
128
+ // The modal's root stops above the banner, but its scrim stays the whole screen: the margin the
129
+ // banner sits in is dimmed like the rest, and nothing of the page behind is reachable through it.
130
+ const SCRIMS = [
131
+ { label: 'dialog', width: 1440, height: 900, opener: "Ouvrir l'assistant" },
132
+ {
133
+ label: 'bottom sheet',
134
+ width: 390,
135
+ height: 844,
136
+ opener: "Ouvrir l'assistant",
137
+ },
138
+ { label: 'drawer', width: 1440, height: 900, opener: "Ouvrir l'aperçu" },
139
+ ] as const;
140
+
141
+ for (const scrim of SCRIMS) {
142
+ test(`the scrim covers the margin around the banner over a ${scrim.label}: the page is not reachable`, async ({
143
+ page,
144
+ }) => {
145
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, {
146
+ width: scrim.width,
147
+ height: scrim.height,
148
+ });
149
+ await page.getByRole('button', { name: scrim.opener }).click();
150
+ await settle(page);
151
+
152
+ // Points in the gutters of the banner and under its bottom edge: what is there is the scrim.
153
+ const points = [
154
+ { x: 3, y: scrim.height - 100 },
155
+ { x: scrim.width - 3, y: scrim.height - 100 },
156
+ { x: scrim.width / 2, y: scrim.height - 3 },
157
+ ];
158
+ const hits = await page.evaluate(
159
+ (probe) =>
160
+ probe.map(({ x, y }) => {
161
+ const element = document.elementFromPoint(x, y);
162
+ return {
163
+ inPage: document.getElementById('root')?.contains(element) ?? true,
164
+ isScrim: element?.classList.contains('MuiBackdrop-root') ?? false,
165
+ };
166
+ }),
167
+ points,
168
+ );
169
+ for (const hit of hits) {
170
+ expect(hit).toEqual({ inPage: false, isScrim: true });
171
+ }
172
+
173
+ // A click there reaches nothing of the page behind.
174
+ await page.evaluate(() => {
175
+ (window as unknown as { pageClicks: number }).pageClicks = 0;
176
+ document.getElementById('root')?.addEventListener('click', () => {
177
+ (window as unknown as { pageClicks: number }).pageClicks += 1;
178
+ });
179
+ });
180
+ await page.mouse.click(points[0].x, points[0].y);
181
+ expect(
182
+ await page.evaluate(
183
+ () => (window as unknown as { pageClicks: number }).pageClicks,
184
+ ),
185
+ ).toBe(0);
186
+ });
187
+ }