@abyss-project/commons-front-core 18.1.0 → 18.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 (53) hide show
  1. package/CHANGELOG.md +92 -99
  2. package/catalog/pages/CookieConsent.tsx +112 -61
  3. package/catalog/pages/DeliveryHistory.tsx +66 -79
  4. package/catalog/pages/DeliverySubscriptions.tsx +110 -127
  5. package/catalog/pages/ScheduledTasks.tsx +117 -117
  6. package/catalog/specs/captures.spec.ts +145 -145
  7. package/catalog/specs/cookie-consent-modal.spec.ts +145 -5
  8. package/catalog/specs/write-capture-index.ts +81 -81
  9. package/dist/CookieConsentSettings-JQ9582_7.js +687 -0
  10. package/dist/{Surface-z5TuQzlh.js → Surface-dziv23sf.js} +40 -50
  11. package/dist/{Tabs-C4K0mLME.js → Tabs-_onUZBA-.js} +1 -1
  12. package/dist/components/business/CookieConsent/containing-block.d.ts +19 -0
  13. package/dist/components/business/CookieConsent/containing-block.spec.d.ts +1 -0
  14. package/dist/components/business/CookieConsent/use-banner-portal.d.ts +9 -0
  15. package/dist/components/business/Deliveries/DeliveryHistory.component.d.ts +3 -4
  16. package/dist/components/business/Deliveries/DeliverySubscriptionForm.d.ts +2 -3
  17. package/dist/components/business/Deliveries/deliveries.logic.d.ts +0 -11
  18. package/dist/components/business/Deliveries/deliveries.types.d.ts +4 -12
  19. package/dist/cookie-consent.js +2 -2
  20. package/dist/{design-theme-BFkCN7Nz.js → design-theme-B3C3z1gE.js} +1 -1
  21. package/dist/{editors-Eb3PHnxn.js → editors-BhQlONOy.js} +27 -27
  22. package/dist/editors.js +1 -1
  23. package/dist/hooks/use-rich-intl.hook.d.ts +2 -12
  24. package/dist/{index-CYBvIQsH.js → index-B6LMTOKG.js} +3 -3
  25. package/dist/{index-CUhMNEUo.js → index-B6w5_TeJ.js} +3 -3
  26. package/dist/{index-Dqm1dC1j.js → index-BBF-FvT6.js} +2 -2
  27. package/dist/{index-B76nCWpd.js → index-BGAZK8Vk.js} +2 -2
  28. package/dist/{index-CFDEfvCD.js → index-BGJobvxw.js} +1 -1
  29. package/dist/{index-CtkfWhK1.js → index-BTDlbjWW.js} +2 -2
  30. package/dist/{index-BKRudpMw.js → index-BcjlG5TB.js} +2 -2
  31. package/dist/{index-BcO-JFrs.js → index-BeMiREqf.js} +2 -2
  32. package/dist/{index-CWD0waD8.js → index-ByN6DcaL.js} +2 -2
  33. package/dist/{index-BaL2x2GW.js → index-CJI1dJrw.js} +3 -3
  34. package/dist/{index-BlOP01yA.js → index-D1mQgWN3.js} +2 -2
  35. package/dist/{index-z5ZOXlY8.js → index-DLlWMDxB.js} +4 -4
  36. package/dist/{index-Ckzcg8qD.js → index-DNd8NZnu.js} +4 -4
  37. package/dist/{index-Ckzmgx9X.js → index-Dakpr4C1.js} +3 -3
  38. package/dist/{index-CrZZo4r1.js → index-DkZAsKob.js} +2 -2
  39. package/dist/{index-CQ7z2zKY.js → index-DprTO7yi.js} +4 -4
  40. package/dist/{index-CtVoDSIn.js → index-N4BwXTyk.js} +2 -2
  41. package/dist/{index-Bw4XnSa0.js → index-V4F4Sk7y.js} +2 -2
  42. package/dist/{index-CRFGogWn.js → index-y-TnfE6Z.js} +2 -2
  43. package/dist/{index-2lNOK7eK.js → index-yFJTDKIX.js} +2 -2
  44. package/dist/{index-DRtBc440.js → index-ytgNPz5f.js} +2 -2
  45. package/dist/index.js +5790 -5880
  46. package/dist/legacy.js +6 -6
  47. package/dist/test/vitest-workers.d.ts +18 -0
  48. package/dist/test/vitest-workers.spec.d.ts +1 -0
  49. package/dist/translations/en.d.ts +1 -6
  50. package/dist/translations/fr.d.ts +1 -6
  51. package/package.json +3 -3
  52. package/vitest.config.ts +6 -0
  53. package/dist/CookieConsentSettings-DUoKKRMZ.js +0 -595
@@ -1,145 +1,145 @@
1
- import { resolve } from 'path';
2
- import { expect, test } from '@playwright/test';
3
- import type { Page } from '@playwright/test';
4
- import { CAPTURES, CAPTURES_DIR, VIEWPORT_HEIGHT } from '../captures-plan';
5
- import type { CaptureState } from '../captures-plan';
6
- import { openCatalogPage, settle } from './catalog-page';
7
-
8
- // Criterion 13: one PNG per component in light and dark at 1440 px, plus 390 px for the
9
- // components that change form below 768 px, and the two composed scenes at 1440 and 390 px.
10
-
11
- /** Opens the « Actions » menu of the first row of the page and picks the item named `item`. */
12
- const chooseRowAction = async (
13
- page: Page,
14
- item: string | RegExp,
15
- ): Promise<void> => {
16
- await page
17
- .getByRole('button', { name: /^Actions de / })
18
- .first()
19
- .click();
20
- await page.getByRole('menuitem', { name: item }).click();
21
- };
22
-
23
- /** How each state beyond arrival is reached, and what proves it is shown. */
24
- const REACH: Record<
25
- Exclude<CaptureState, 'arrival'>,
26
- (page: Page) => Promise<void>
27
- > = {
28
- 'sheet-open': async (page) => {
29
- await page
30
- .getByRole('button', { name: /avis-imposition-2026\.pdf/ })
31
- .click();
32
- await expect(
33
- page.getByRole('dialog', { name: 'avis-imposition-2026.pdf' }),
34
- ).toBeVisible();
35
- },
36
- 'list-open': async (page) => {
37
- await page.getByRole('combobox').first().click();
38
- await expect(page.getByRole('listbox')).toBeVisible();
39
- },
40
- 'calendar-open': async (page) => {
41
- await page
42
- .getByRole('button', { name: /Choisir une date/ })
43
- .first()
44
- .click();
45
- await expect(page.getByRole('dialog')).toBeVisible();
46
- },
47
- // The value of a list (six actions): the menu lists every action with its label.
48
- 'menu-open': async (page) => {
49
- await page.getByRole('button', { name: /Actions sur requestId/ }).click();
50
- const menu = page.getByRole('menu').or(page.getByRole('dialog'));
51
- await expect(menu).toBeVisible();
52
- await expect(menu.getByRole('menuitem')).toHaveCount(6);
53
- },
54
- // The delivery components: the first row's « Actions » menu, then the panel an action opens.
55
- 'form-open': async (page) => {
56
- await page
57
- .getByRole('button', { name: /^Nouvel(le)? (abonnement|tâche)$/ })
58
- .first()
59
- .click();
60
- await expect(
61
- page.getByRole('dialog', {
62
- name: /^Nouvel abonnement$|^Nouvelle tâche planifiée$/,
63
- }),
64
- ).toBeVisible();
65
- },
66
- 'secret-shown': async (page) => {
67
- await chooseRowAction(page, /Réinitialiser le secret|Régénérer le secret/);
68
- await page
69
- .getByRole('dialog')
70
- .getByRole('button', { name: /^(Réinitialiser|Régénérer)$/ })
71
- .click();
72
- await expect(
73
- page.getByText(/Ce secret n’est affiché qu’une seule fois/),
74
- ).toBeVisible();
75
- },
76
- 'delete-confirm': async (page) => {
77
- await chooseRowAction(page, 'Supprimer');
78
- await expect(
79
- page.getByRole('dialog', { name: /^Supprimer cet(te)? / }),
80
- ).toBeVisible();
81
- },
82
- 'detail-open': async (page) => {
83
- await chooseRowAction(page, 'Détail de la livraison');
84
- await expect(
85
- page.getByRole('dialog', { name: 'Détail de la livraison' }),
86
- ).toBeVisible();
87
- await expect(page.getByText('x-abyss-delivery-id').first()).toBeVisible();
88
- },
89
- 'runs-open': async (page) => {
90
- await chooseRowAction(page, 'Exécutions');
91
- await expect(
92
- page.getByRole('dialog', { name: /^Exécutions de / }),
93
- ).toBeVisible();
94
- await expect(page.getByText('Réussie').first()).toBeVisible();
95
- },
96
- // The cookie banner's settings: the banner leaves while the sheet is open.
97
- 'settings-open': async (page) => {
98
- await page.getByRole('button', { name: 'Personnaliser' }).click();
99
- await expect(
100
- page.getByRole('dialog', { name: 'Personnaliser mes cookies' }),
101
- ).toBeVisible();
102
- await expect(
103
- page.getByRole('dialog', { name: 'Vos préférences de cookies' }),
104
- ).toHaveCount(0);
105
- },
106
- // The first top bar trigger of the page: the notifications bell or the account avatar.
107
- 'panel-open': async (page) => {
108
- await page.locator('[aria-haspopup]').first().click();
109
- await expect(
110
- page.getByRole('dialog').or(page.getByRole('menu')),
111
- ).toBeVisible();
112
- },
113
- };
114
-
115
- for (const capture of CAPTURES) {
116
- test(`capture ${capture.file}`, async ({ page }) => {
117
- await openCatalogPage(page, capture.entry.name, capture.theme, {
118
- width: capture.width,
119
- height: VIEWPORT_HEIGHT[capture.width],
120
- });
121
-
122
- if (capture.state !== 'arrival') {
123
- await REACH[capture.state](page);
124
- await settle(page);
125
- }
126
-
127
- // A taller window rather than `fullPage`: the sticky sidebar (`100vh`) then spans the whole
128
- // page, as it does on screen while scrolling. A mobile frame (`100dvh`) is never taller.
129
- const documentHeight = await page.evaluate(
130
- () => document.documentElement.scrollHeight,
131
- );
132
- if (documentHeight > VIEWPORT_HEIGHT[capture.width]) {
133
- await page.setViewportSize({
134
- width: capture.width,
135
- height: documentHeight,
136
- });
137
- await settle(page);
138
- }
139
-
140
- await page.screenshot({
141
- path: resolve(CAPTURES_DIR, capture.file),
142
- animations: 'disabled',
143
- });
144
- });
145
- }
1
+ import { resolve } from 'path';
2
+ import { expect, test } from '@playwright/test';
3
+ import type { Page } from '@playwright/test';
4
+ import { CAPTURES, CAPTURES_DIR, VIEWPORT_HEIGHT } from '../captures-plan';
5
+ import type { CaptureState } from '../captures-plan';
6
+ import { openCatalogPage, settle } from './catalog-page';
7
+
8
+ // Criterion 13: one PNG per component in light and dark at 1440 px, plus 390 px for the
9
+ // components that change form below 768 px, and the two composed scenes at 1440 and 390 px.
10
+
11
+ /** Opens the « Actions » menu of the first row of the page and picks the item named `item`. */
12
+ const chooseRowAction = async (
13
+ page: Page,
14
+ item: string | RegExp,
15
+ ): Promise<void> => {
16
+ await page
17
+ .getByRole('button', { name: /^Actions de / })
18
+ .first()
19
+ .click();
20
+ await page.getByRole('menuitem', { name: item }).click();
21
+ };
22
+
23
+ /** How each state beyond arrival is reached, and what proves it is shown. */
24
+ const REACH: Record<
25
+ Exclude<CaptureState, 'arrival'>,
26
+ (page: Page) => Promise<void>
27
+ > = {
28
+ 'sheet-open': async (page) => {
29
+ await page
30
+ .getByRole('button', { name: /avis-imposition-2026\.pdf/ })
31
+ .click();
32
+ await expect(
33
+ page.getByRole('dialog', { name: 'avis-imposition-2026.pdf' }),
34
+ ).toBeVisible();
35
+ },
36
+ 'list-open': async (page) => {
37
+ await page.getByRole('combobox').first().click();
38
+ await expect(page.getByRole('listbox')).toBeVisible();
39
+ },
40
+ 'calendar-open': async (page) => {
41
+ await page
42
+ .getByRole('button', { name: /Choisir une date/ })
43
+ .first()
44
+ .click();
45
+ await expect(page.getByRole('dialog')).toBeVisible();
46
+ },
47
+ // The value of a list (six actions): the menu lists every action with its label.
48
+ 'menu-open': async (page) => {
49
+ await page.getByRole('button', { name: /Actions sur requestId/ }).click();
50
+ const menu = page.getByRole('menu').or(page.getByRole('dialog'));
51
+ await expect(menu).toBeVisible();
52
+ await expect(menu.getByRole('menuitem')).toHaveCount(6);
53
+ },
54
+ // The delivery components: the first row's « Actions » menu, then the panel an action opens.
55
+ 'form-open': async (page) => {
56
+ await page
57
+ .getByRole('button', { name: /^Nouvel(le)? (abonnement|tâche)$/ })
58
+ .first()
59
+ .click();
60
+ await expect(
61
+ page.getByRole('dialog', {
62
+ name: /^Nouvel abonnement$|^Nouvelle tâche planifiée$/,
63
+ }),
64
+ ).toBeVisible();
65
+ },
66
+ 'secret-shown': async (page) => {
67
+ await chooseRowAction(page, /Réinitialiser le secret|Régénérer le secret/);
68
+ await page
69
+ .getByRole('dialog')
70
+ .getByRole('button', { name: /^(Réinitialiser|Régénérer)$/ })
71
+ .click();
72
+ await expect(
73
+ page.getByText(/Ce secret n’est affiché qu’une seule fois/),
74
+ ).toBeVisible();
75
+ },
76
+ 'delete-confirm': async (page) => {
77
+ await chooseRowAction(page, 'Supprimer');
78
+ await expect(
79
+ page.getByRole('dialog', { name: /^Supprimer cet(te)? / }),
80
+ ).toBeVisible();
81
+ },
82
+ 'detail-open': async (page) => {
83
+ await chooseRowAction(page, 'Détail de la livraison');
84
+ await expect(
85
+ page.getByRole('dialog', { name: 'Détail de la livraison' }),
86
+ ).toBeVisible();
87
+ await expect(page.getByText('x-abyss-delivery-id').first()).toBeVisible();
88
+ },
89
+ 'runs-open': async (page) => {
90
+ await chooseRowAction(page, 'Exécutions');
91
+ await expect(
92
+ page.getByRole('dialog', { name: /^Exécutions de / }),
93
+ ).toBeVisible();
94
+ await expect(page.getByText('Réussie').first()).toBeVisible();
95
+ },
96
+ // The cookie banner's settings: the banner leaves while the sheet is open.
97
+ 'settings-open': async (page) => {
98
+ await page.getByRole('button', { name: 'Personnaliser' }).click();
99
+ await expect(
100
+ page.getByRole('dialog', { name: 'Personnaliser mes cookies' }),
101
+ ).toBeVisible();
102
+ await expect(
103
+ page.getByRole('dialog', { name: 'Vos préférences de cookies' }),
104
+ ).toHaveCount(0);
105
+ },
106
+ // The first top bar trigger of the page: the notifications bell or the account avatar.
107
+ 'panel-open': async (page) => {
108
+ await page.locator('[aria-haspopup]').first().click();
109
+ await expect(
110
+ page.getByRole('dialog').or(page.getByRole('menu')),
111
+ ).toBeVisible();
112
+ },
113
+ };
114
+
115
+ for (const capture of CAPTURES) {
116
+ test(`capture ${capture.file}`, async ({ page }) => {
117
+ await openCatalogPage(page, capture.entry.name, capture.theme, {
118
+ width: capture.width,
119
+ height: VIEWPORT_HEIGHT[capture.width],
120
+ });
121
+
122
+ if (capture.state !== 'arrival') {
123
+ await REACH[capture.state](page);
124
+ await settle(page);
125
+ }
126
+
127
+ // A taller window rather than `fullPage`: the sticky sidebar (`100vh`) then spans the whole
128
+ // page, as it does on screen while scrolling. A mobile frame (`100dvh`) is never taller.
129
+ const documentHeight = await page.evaluate(
130
+ () => document.documentElement.scrollHeight,
131
+ );
132
+ if (documentHeight > VIEWPORT_HEIGHT[capture.width]) {
133
+ await page.setViewportSize({
134
+ width: capture.width,
135
+ height: documentHeight,
136
+ });
137
+ await settle(page);
138
+ }
139
+
140
+ await page.screenshot({
141
+ path: resolve(CAPTURES_DIR, capture.file),
142
+ animations: 'disabled',
143
+ });
144
+ });
145
+ }
@@ -39,6 +39,21 @@ const boxOf = async (page: Page, name: string) => {
39
39
  return box;
40
40
  };
41
41
 
42
+ /** Whether the topmost element at the middle of `box` is, or sits in, the button of that name. */
43
+ const isButtonAt = (
44
+ page: Page,
45
+ name: string,
46
+ box: { x: number; y: number; width: number; height: number },
47
+ ): Promise<boolean> =>
48
+ page
49
+ .getByRole('button', { name, exact: true })
50
+ .evaluate(
51
+ (button, point) =>
52
+ document.elementFromPoint(point.x, point.y)?.closest('button') ===
53
+ button,
54
+ { x: box.x + box.width / 2, y: box.y + box.height / 2 },
55
+ );
56
+
42
57
  const overlaps = (
43
58
  a: { x: number; y: number; width: number; height: number },
44
59
  b: { x: number; y: number; width: number; height: number },
@@ -78,14 +93,139 @@ for (const viewport of VIEWPORTS) {
78
93
  expect(banner).not.toBeNull();
79
94
  expect(overlaps(next, banner!)).toBe(false);
80
95
  // 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');
96
+ expect(await isButtonAt(page, 'Suivant', next)).toBe(true);
86
97
  });
87
98
  }
88
99
 
100
+ // The banner is `position: fixed`. A surface that carries `backdrop-filter` (the legacy theme's
101
+ // dialog paper), `filter`, `transform`... becomes the box that fixed element is laid out in: the
102
+ // banner then sticks to the bottom of the surface and covers « Suivant ». The catalog's own theme
103
+ // has none, so these dialogs carry the property by hand.
104
+ const SURFACE_EFFECTS = [
105
+ { label: 'backdrop-filter', opener: 'Ouvrir la fenêtre à fond flouté' },
106
+ { label: 'filter', opener: 'Ouvrir la fenêtre à filtre' },
107
+ ] as const;
108
+
109
+ for (const effect of SURFACE_EFFECTS) {
110
+ for (const viewport of [
111
+ { width: 1440, height: 900 },
112
+ { width: 390, height: 844 },
113
+ ]) {
114
+ test(`the banner sticks to the bottom of the window and leaves « Suivant » free over a dialog with ${effect.label} at ${viewport.width}px`, async ({
115
+ page,
116
+ }) => {
117
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, viewport);
118
+ await page.getByRole('button', { name: effect.opener }).click();
119
+ await expect(
120
+ page.getByRole('dialog', { name: 'Assistant à surface spéciale' }),
121
+ ).toBeVisible();
122
+ await settle(page);
123
+
124
+ // The property that anchored the banner to the paper is switched off while it is hosted.
125
+ const computed = await page
126
+ .locator('.MuiDialog-paper')
127
+ .evaluate(
128
+ (paper, property) =>
129
+ getComputedStyle(paper).getPropertyValue(property),
130
+ effect.label,
131
+ );
132
+ expect(computed).toBe('none');
133
+
134
+ const banner = await page
135
+ .getByRole('dialog', { name: 'Vos préférences de cookies' })
136
+ .boundingBox();
137
+ expect(banner).not.toBeNull();
138
+ // Stuck to the bottom of the window (an 8 to 24 px offset), not to the bottom of the paper.
139
+ const gap = viewport.height - (banner!.y + banner!.height);
140
+ expect(gap).toBeGreaterThanOrEqual(0);
141
+ expect(gap).toBeLessThanOrEqual(32);
142
+
143
+ const next = await boxOf(page, 'Suivant');
144
+ expect(overlaps(next, banner!)).toBe(false);
145
+ expect(await isButtonAt(page, 'Suivant', next)).toBe(true);
146
+ });
147
+ }
148
+ }
149
+
150
+ // The panel of a bottom sheet follows the finger with an inline `translateY` and no transition.
151
+ // The banner must not freeze it: only what a stylesheet gives is switched off, never an inline style.
152
+ test('the sheet keeps following the finger while the banner is shown', async ({
153
+ page,
154
+ }) => {
155
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, {
156
+ width: 390,
157
+ height: 844,
158
+ });
159
+ await page.getByRole('button', { name: "Ouvrir l'assistant" }).click();
160
+ const panel = page.getByRole('dialog', { name: 'Assistant de démarrage' });
161
+ await expect(panel).toBeVisible();
162
+ await settle(page);
163
+
164
+ const before = await panel.boundingBox();
165
+ const grip = await page.getByTestId('bottom-sheet-drag-zone').boundingBox();
166
+ expect(before).not.toBeNull();
167
+ expect(grip).not.toBeNull();
168
+ const x = grip!.x + grip!.width / 2;
169
+ const y = grip!.y + grip!.height / 2;
170
+ await page.mouse.move(x, y);
171
+ await page.mouse.down();
172
+ // Less than the commit ratio, so that the sheet stays open under the finger.
173
+ for (let step = 1; step <= 4; step += 1) {
174
+ await page.mouse.move(x, y + step * 10);
175
+ await page.waitForTimeout(30);
176
+ }
177
+ const dragged = await panel.boundingBox();
178
+ expect(dragged).not.toBeNull();
179
+ expect(dragged!.y - before!.y).toBeGreaterThan(30);
180
+ await page.mouse.up();
181
+ });
182
+
183
+ // A drawer closes by sliding out. The banner must not hold it on screen: nothing writes over the
184
+ // transform the exit transition drives.
185
+ test('a drawer closes by sliding out while the banner is shown, and does not come back', async ({
186
+ page,
187
+ }) => {
188
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, {
189
+ width: 1440,
190
+ height: 900,
191
+ });
192
+ await page.getByRole('button', { name: "Ouvrir l'aperçu" }).click();
193
+ const drawer = page.getByRole('dialog', { name: 'Aperçu' });
194
+ await expect(drawer).toBeVisible();
195
+ await settle(page);
196
+ expect(await inAccessibilityTree(page, BANNER_BUTTON)).toBe(true);
197
+
198
+ // Every inline transform the drawer paper goes through. A frame sampler would depend on the
199
+ // runner's load: a starved main thread paints no frame between the exit and the unmount.
200
+ await page.evaluate(() => {
201
+ const transforms: string[] = [];
202
+ (window as unknown as { drawerTransforms: string[] }).drawerTransforms =
203
+ transforms;
204
+ const paper = document.querySelector<HTMLElement>('.MuiDrawer-paper');
205
+ if (paper === null) {
206
+ return;
207
+ }
208
+ new MutationObserver(() => {
209
+ transforms.push(paper.style.transform);
210
+ }).observe(paper, { attributes: true, attributeFilter: ['style'] });
211
+ });
212
+ await page.keyboard.press('Escape');
213
+ await expect(drawer).toHaveCount(0);
214
+
215
+ const transforms = await page.evaluate(
216
+ () =>
217
+ (window as unknown as { drawerTransforms: string[] }).drawerTransforms,
218
+ );
219
+ // MUI wrote the exit transform, and nothing wrote over it afterwards.
220
+ const firstExit = transforms.findIndex((value) =>
221
+ value.startsWith('translate'),
222
+ );
223
+ expect(firstExit).toBeGreaterThanOrEqual(0);
224
+ transforms.slice(firstExit).forEach((value) => {
225
+ expect(value).toMatch(/^translate/);
226
+ });
227
+ });
228
+
89
229
  test('the banner is not aria-hidden over a drawer and the drawer stops above it', async ({
90
230
  page,
91
231
  }) => {
@@ -1,81 +1,81 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
- import { resolve } from 'path';
3
- import { CAPTURES, CAPTURES_DIR } from '../captures-plan';
4
- import type { Capture, CaptureState } from '../captures-plan';
5
- import type { CatalogFamily } from '../catalog-entries';
6
-
7
- // Global teardown of the catalog run: writes `index.md` next to the screenshots, from the capture
8
- // plan, listing only the files present on disk.
9
-
10
- const FAMILY_TITLES: Record<CatalogFamily, string> = {
11
- scenes: 'Scènes composées (à regarder en premier)',
12
- structure: 'Structure',
13
- mobile: 'Mobile',
14
- states: 'États',
15
- data: 'Données',
16
- meaning: 'Sens',
17
- business: 'Métier',
18
- layers: 'Couches',
19
- navigation: 'Navigation',
20
- inputs: 'Saisie',
21
- };
22
-
23
- const STATE_LABEL: Record<CaptureState, string> = {
24
- arrival: '',
25
- 'sheet-open': ', feuille ouverte',
26
- 'list-open': ', liste ouverte',
27
- 'calendar-open': ', calendrier ouvert',
28
- 'panel-open': ', panneau ouvert',
29
- 'menu-open': ', menu ouvert',
30
- 'settings-open': ', réglages ouverts',
31
- 'form-open': ', formulaire ouvert',
32
- 'secret-shown': ', secret affiché une fois',
33
- 'delete-confirm': ', confirmation de suppression',
34
- 'detail-open': ', détail ouvert',
35
- 'runs-open': ', exécutions ouvertes',
36
- };
37
-
38
- const describe = (capture: Capture): string =>
39
- `${capture.theme === 'dark' ? 'sombre' : 'clair'}, ${capture.width} px${
40
- STATE_LABEL[capture.state]
41
- }`;
42
-
43
- const writeCaptureIndex = (): void => {
44
- mkdirSync(CAPTURES_DIR, { recursive: true });
45
- const present = CAPTURES.filter((capture) =>
46
- existsSync(resolve(CAPTURES_DIR, capture.file)),
47
- );
48
- const families = Object.keys(FAMILY_TITLES) as CatalogFamily[];
49
- const sections = families
50
- .map((family) => {
51
- const lines = present
52
- .filter((capture) => capture.entry.family === family)
53
- .map(
54
- (capture) =>
55
- `- \`${capture.file}\` : ${capture.entry.name}, ${describe(
56
- capture,
57
- )}`,
58
- );
59
- return lines.length === 0
60
- ? ''
61
- : `## ${FAMILY_TITLES[family]}\n\n${lines.join('\n')}\n`;
62
- })
63
- .filter((section) => section !== '');
64
- const missing = CAPTURES.length - present.length;
65
- const content = [
66
- '# Captures du catalogue du core (#286)',
67
- '',
68
- 'Produites par `pnpm --filter @abyss-project/commons-front-core catalog:test` (`catalog/specs/captures.spec.ts`).',
69
- 'Chaque composant en clair et en sombre à 1440 px ; à 390 px aussi ceux qui changent de forme sous 768 px ;',
70
- 'le shell et la scène bureau aussi à 768 px (rail d’icônes).',
71
- '',
72
- `${present.length} fichiers${
73
- missing > 0 ? `, ${missing} manquants (lancement partiel)` : ''
74
- }.`,
75
- '',
76
- ...sections,
77
- ].join('\n');
78
- writeFileSync(resolve(CAPTURES_DIR, 'index.md'), content);
79
- };
80
-
81
- export default writeCaptureIndex;
1
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ import { CAPTURES, CAPTURES_DIR } from '../captures-plan';
4
+ import type { Capture, CaptureState } from '../captures-plan';
5
+ import type { CatalogFamily } from '../catalog-entries';
6
+
7
+ // Global teardown of the catalog run: writes `index.md` next to the screenshots, from the capture
8
+ // plan, listing only the files present on disk.
9
+
10
+ const FAMILY_TITLES: Record<CatalogFamily, string> = {
11
+ scenes: 'Scènes composées (à regarder en premier)',
12
+ structure: 'Structure',
13
+ mobile: 'Mobile',
14
+ states: 'États',
15
+ data: 'Données',
16
+ meaning: 'Sens',
17
+ business: 'Métier',
18
+ layers: 'Couches',
19
+ navigation: 'Navigation',
20
+ inputs: 'Saisie',
21
+ };
22
+
23
+ const STATE_LABEL: Record<CaptureState, string> = {
24
+ arrival: '',
25
+ 'sheet-open': ', feuille ouverte',
26
+ 'list-open': ', liste ouverte',
27
+ 'calendar-open': ', calendrier ouvert',
28
+ 'panel-open': ', panneau ouvert',
29
+ 'menu-open': ', menu ouvert',
30
+ 'settings-open': ', réglages ouverts',
31
+ 'form-open': ', formulaire ouvert',
32
+ 'secret-shown': ', secret affiché une fois',
33
+ 'delete-confirm': ', confirmation de suppression',
34
+ 'detail-open': ', détail ouvert',
35
+ 'runs-open': ', exécutions ouvertes',
36
+ };
37
+
38
+ const describe = (capture: Capture): string =>
39
+ `${capture.theme === 'dark' ? 'sombre' : 'clair'}, ${capture.width} px${
40
+ STATE_LABEL[capture.state]
41
+ }`;
42
+
43
+ const writeCaptureIndex = (): void => {
44
+ mkdirSync(CAPTURES_DIR, { recursive: true });
45
+ const present = CAPTURES.filter((capture) =>
46
+ existsSync(resolve(CAPTURES_DIR, capture.file)),
47
+ );
48
+ const families = Object.keys(FAMILY_TITLES) as CatalogFamily[];
49
+ const sections = families
50
+ .map((family) => {
51
+ const lines = present
52
+ .filter((capture) => capture.entry.family === family)
53
+ .map(
54
+ (capture) =>
55
+ `- \`${capture.file}\` : ${capture.entry.name}, ${describe(
56
+ capture,
57
+ )}`,
58
+ );
59
+ return lines.length === 0
60
+ ? ''
61
+ : `## ${FAMILY_TITLES[family]}\n\n${lines.join('\n')}\n`;
62
+ })
63
+ .filter((section) => section !== '');
64
+ const missing = CAPTURES.length - present.length;
65
+ const content = [
66
+ '# Captures du catalogue du core (#286)',
67
+ '',
68
+ 'Produites par `pnpm --filter @abyss-project/commons-front-core catalog:test` (`catalog/specs/captures.spec.ts`).',
69
+ 'Chaque composant en clair et en sombre à 1440 px ; à 390 px aussi ceux qui changent de forme sous 768 px ;',
70
+ 'le shell et la scène bureau aussi à 768 px (rail d’icônes).',
71
+ '',
72
+ `${present.length} fichiers${
73
+ missing > 0 ? `, ${missing} manquants (lancement partiel)` : ''
74
+ }.`,
75
+ '',
76
+ ...sections,
77
+ ].join('\n');
78
+ writeFileSync(resolve(CAPTURES_DIR, 'index.md'), content);
79
+ };
80
+
81
+ export default writeCaptureIndex;