@abyss-project/commons-front-core 18.1.3 → 18.1.4
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/CHANGELOG.md +24 -0
- package/README.md +4 -0
- package/catalog/catalog-entries.ts +4 -0
- package/catalog/pages/Callout.tsx +9 -0
- package/catalog/pages/CodeEditor.tsx +52 -0
- package/catalog/pages/DeliveryHistory.tsx +79 -79
- package/catalog/pages/DeliverySubscriptions.tsx +127 -127
- package/catalog/pages/LineChart.tsx +21 -0
- package/catalog/pages/MarkdownEditor.tsx +1 -1
- package/catalog/pages/ScheduledTasks.tsx +117 -117
- package/catalog/pages/SessionErrorScreen.tsx +20 -0
- package/catalog/pages/Toast.tsx +59 -1
- package/catalog/pages/index.ts +4 -0
- package/catalog/playwright.ci.config.ts +2 -2
- package/catalog/specs/captures.spec.ts +145 -145
- package/catalog/specs/global-review-captures.spec.ts +154 -0
- package/catalog/specs/markdown-editor.spec.ts +107 -0
- package/catalog/specs/toast-dialog-foot.spec.ts +83 -0
- package/catalog/specs/write-capture-index.ts +81 -81
- package/dist/{CookieConsentSettings-CLB1Mlv5.js → CookieConsentSettings-D97TY138.js} +53 -53
- package/dist/{Surface-B_wIEB3b.js → Surface-CN1zQYLJ.js} +144 -121
- package/dist/{Tabs-g7OaInVW.js → Tabs-CxD9y18t.js} +235 -229
- package/dist/components/CodeEditor/CodeEditor.component.spec.d.ts +1 -0
- package/dist/components/business/CookieConsent/use-banner-portal.d.ts +0 -17
- package/dist/components/data/LineChart/LineChart.d.ts +21 -2
- package/dist/components/data/LineChart/line-chart-ticks.d.ts +5 -2
- package/dist/components/editors/MarkdownEditor/crepe-styles.d.ts +7 -0
- package/dist/components/editors/MarkdownEditor/crepe-styles.spec.d.ts +1 -0
- package/dist/components/layers/Modal/active-modal.d.ts +14 -0
- package/dist/components/layers/Toast/Toast.d.ts +1 -0
- package/dist/components/layers/Toast/dialog-foot-clearance.d.ts +19 -0
- package/dist/components/layers/Toast/toast-clearance.d.ts +11 -0
- package/dist/cookie-consent.js +2 -2
- package/dist/{design-theme-Bcu3EMIB.js → design-theme-GGVSCauN.js} +1 -1
- package/dist/{editors-DdGMdSh2.js → editors-CJ_6PXoL.js} +30129 -30094
- package/dist/editors.js +1 -1
- package/dist/hooks/use-rich-intl.hook.d.ts +18 -0
- package/dist/{index-cA9H4vaN.js → index-4MsOXuOU.js} +2 -2
- package/dist/{index-CNjQ-GTe.js → index-5BCfqxIs.js} +2 -2
- package/dist/{index-Be4u6vqC.js → index-5HFSSrP-.js} +1 -1
- package/dist/{index-CH4DiDpu.js → index-7M2xC_9h.js} +2 -2
- package/dist/{index-DBctH8lu.js → index-8o9jiKS2.js} +2 -2
- package/dist/{index-DMAlgOv6.js → index-B6QYagVk.js} +2 -2
- package/dist/{index-CYGd_IjS.js → index-BQFouU9U.js} +2 -2
- package/dist/{index-8LPOJLO8.js → index-BQLAeM_n.js} +2 -2
- package/dist/{index-CNx-Ok-t.js → index-BbbyRlLu.js} +2 -2
- package/dist/{index-BFZvgteF.js → index-Bbc0SjAt.js} +2 -2
- package/dist/{index-Cwo-CFS8.js → index-BcsTtdwQ.js} +4 -4
- package/dist/{index-DSIctaR0.js → index-Berc0QsZ.js} +4 -4
- package/dist/{index-DfGQhHnK.js → index-ByRUmH_4.js} +3 -3
- package/dist/{index-CH67WfFq.js → index-CXUHmTse.js} +2 -2
- package/dist/{index-zu64GUZu.js → index-Cl1UafyM.js} +2 -2
- package/dist/{index-BPF_Eb0U.js → index-DQgpUR1S.js} +3 -3
- package/dist/{index-CbH8XAvZ.js → index-Dh1lFi8d.js} +2 -2
- package/dist/{index-_7HwdzPE.js → index-Drwqi2Fr.js} +2 -2
- package/dist/{index-B12llGmk.js → index-Dtfo8fKg.js} +4 -4
- package/dist/{index-Vgp_uo0Y.js → index-VLxkKEWK.js} +3 -3
- package/dist/{index-CJ4-H8Ku.js → index-p3G-JM7E.js} +3 -3
- package/dist/index.js +5850 -5767
- package/dist/legacy.js +6 -6
- package/dist/translations/en.d.ts +9 -0
- package/dist/translations/fr.d.ts +9 -0
- package/package.json +1 -1
- package/dist/commons-front-core.css +0 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { dirname, resolve } from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { expect, test } from '@playwright/test';
|
|
4
|
+
import type { Page } from '@playwright/test';
|
|
5
|
+
import { ThemeMode } from '../../src/theme/tokens/primitives';
|
|
6
|
+
import type { CatalogTheme } from '../catalog-entries';
|
|
7
|
+
import { openCatalogPage, settle } from './catalog-page';
|
|
8
|
+
|
|
9
|
+
// The catalog side of the global review of AbyssMain (#286): each PNG of
|
|
10
|
+
// `e2e/screenshots/ds-286-revue-globale/catalogue-*` is produced here, after what it proves is
|
|
11
|
+
// asserted. Local only, like `captures.spec.ts`: the short editors load Monaco from its CDN.
|
|
12
|
+
|
|
13
|
+
const SHOTS_DIR = resolve(
|
|
14
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
15
|
+
'../../../../e2e/screenshots/ds-286-revue-globale',
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const THEMES: CatalogTheme[] = [ThemeMode.Light, ThemeMode.Dark];
|
|
19
|
+
const VIEWPORTS = [
|
|
20
|
+
{ name: 'desktop', size: { width: 1440, height: 900 } },
|
|
21
|
+
{ name: 'mobile', size: { width: 390, height: 844 } },
|
|
22
|
+
] as const;
|
|
23
|
+
const PHONE = VIEWPORTS[1].size;
|
|
24
|
+
|
|
25
|
+
/** Time Monaco takes to come from its CDN and start. */
|
|
26
|
+
const MONACO_TIMEOUT = 120_000;
|
|
27
|
+
|
|
28
|
+
/** Border of the frame: what may show between the editor and the bottom of the frame. */
|
|
29
|
+
const FRAME_BORDER = 1;
|
|
30
|
+
|
|
31
|
+
const shot = (page: Page, file: string) =>
|
|
32
|
+
page.screenshot({
|
|
33
|
+
path: resolve(SHOTS_DIR, `catalogue-${file}.png`),
|
|
34
|
+
animations: 'disabled',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const noPageScroll = async (page: Page) => {
|
|
38
|
+
const { scrollWidth, innerWidth } = await page.evaluate(() => ({
|
|
39
|
+
scrollWidth: document.documentElement.scrollWidth,
|
|
40
|
+
innerWidth: window.innerWidth,
|
|
41
|
+
}));
|
|
42
|
+
expect(scrollWidth).toBeLessThanOrEqual(innerWidth);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
for (const theme of THEMES) {
|
|
46
|
+
for (const { name: viewport, size } of VIEWPORTS) {
|
|
47
|
+
test(`Callout: a long pre scrolls inside it, ${viewport} ${theme}`, async ({
|
|
48
|
+
page,
|
|
49
|
+
}) => {
|
|
50
|
+
await openCatalogPage(page, 'Callout', theme, size);
|
|
51
|
+
const pre = page.getByTestId('callout-pre');
|
|
52
|
+
await pre.scrollIntoViewIfNeeded();
|
|
53
|
+
const { scrolls, rightOfPre, rightOfCallout } = await pre.evaluate(
|
|
54
|
+
(element) => {
|
|
55
|
+
// Only a box that scrolls moves: an overflow left visible stays at 0.
|
|
56
|
+
element.scrollLeft = 40;
|
|
57
|
+
const moved = element.scrollLeft > 0;
|
|
58
|
+
element.scrollLeft = 0;
|
|
59
|
+
return {
|
|
60
|
+
scrolls: moved,
|
|
61
|
+
rightOfPre: element.getBoundingClientRect().right,
|
|
62
|
+
rightOfCallout:
|
|
63
|
+
element.parentElement?.getBoundingClientRect().right ?? 0,
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
expect(scrolls).toBe(true);
|
|
68
|
+
expect(rightOfPre).toBeLessThanOrEqual(rightOfCallout);
|
|
69
|
+
await noPageScroll(page);
|
|
70
|
+
await shot(page, `callout-pre-${viewport}-${theme}`);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
for (const height of [100, 60]) {
|
|
74
|
+
test(`CodeEditor: nothing under an editor of ${height} px, ${viewport} ${theme}`, async ({
|
|
75
|
+
page,
|
|
76
|
+
}) => {
|
|
77
|
+
test.setTimeout(MONACO_TIMEOUT + 60_000);
|
|
78
|
+
await openCatalogPage(page, 'CodeEditor', theme, size);
|
|
79
|
+
const host = page.getByTestId(`code-editor-${height}`);
|
|
80
|
+
const monaco = host.locator('.monaco-editor');
|
|
81
|
+
await expect(monaco).toBeVisible({ timeout: MONACO_TIMEOUT });
|
|
82
|
+
await host.scrollIntoViewIfNeeded();
|
|
83
|
+
await settle(page);
|
|
84
|
+
await expect(
|
|
85
|
+
host.getByRole('button', { name: 'Ouvrir l’éditeur en plein écran' }),
|
|
86
|
+
).toHaveText('Plein écran');
|
|
87
|
+
const frame = await host.locator('.MuiPaper-root').boundingBox();
|
|
88
|
+
const drawn = await monaco.boundingBox();
|
|
89
|
+
if (frame === null || drawn === null) {
|
|
90
|
+
throw new Error('The frame or the editor has no box.');
|
|
91
|
+
}
|
|
92
|
+
expect(
|
|
93
|
+
frame.y + frame.height - (drawn.y + drawn.height),
|
|
94
|
+
).toBeLessThanOrEqual(FRAME_BORDER);
|
|
95
|
+
await noPageScroll(page);
|
|
96
|
+
await shot(page, `editeur-court-${height}-${viewport}-${theme}`);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
test(`MarkdownEditor: the block handle, ${viewport} ${theme}`, async ({
|
|
101
|
+
page,
|
|
102
|
+
}) => {
|
|
103
|
+
await openCatalogPage(page, 'MarkdownEditor', theme, size);
|
|
104
|
+
const editor = page.locator('.milkdown').first();
|
|
105
|
+
const block = editor.locator('.ProseMirror p').first();
|
|
106
|
+
if (viewport === 'mobile') {
|
|
107
|
+
// At the start of the line: its middle is a link, whose preview would cover the page.
|
|
108
|
+
await block.click({ position: { x: 8, y: 8 } });
|
|
109
|
+
} else {
|
|
110
|
+
await block.hover();
|
|
111
|
+
}
|
|
112
|
+
await settle(page);
|
|
113
|
+
const handle = editor.locator('.milkdown-block-handle');
|
|
114
|
+
if (viewport === 'mobile') {
|
|
115
|
+
await expect(handle).toBeHidden();
|
|
116
|
+
} else {
|
|
117
|
+
await expect(handle).toBeVisible();
|
|
118
|
+
}
|
|
119
|
+
await shot(page, `markdown-poignee-${viewport}-${theme}`);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
for (const { opener, dialogName, file } of [
|
|
124
|
+
{
|
|
125
|
+
opener: 'Dialogue plein écran',
|
|
126
|
+
dialogName: 'Nouvel événement',
|
|
127
|
+
file: 'dialogue-plein-ecran',
|
|
128
|
+
},
|
|
129
|
+
{ opener: 'Modal', dialogName: 'Nouveau projet', file: 'feuille' },
|
|
130
|
+
]) {
|
|
131
|
+
test(`Toast: above the foot of ${file}, ${theme}`, async ({ page }) => {
|
|
132
|
+
await openCatalogPage(page, 'Toast', theme, PHONE);
|
|
133
|
+
await page.getByRole('button', { name: opener, exact: true }).click();
|
|
134
|
+
await settle(page);
|
|
135
|
+
const create = page
|
|
136
|
+
.getByRole('dialog', { name: dialogName })
|
|
137
|
+
.getByRole('button', { name: 'Créer', exact: true });
|
|
138
|
+
await create.click();
|
|
139
|
+
await expect(
|
|
140
|
+
page.getByText('Création impossible : délai dépassé.').first(),
|
|
141
|
+
).toBeVisible();
|
|
142
|
+
await settle(page);
|
|
143
|
+
const region = await page
|
|
144
|
+
.locator('section[aria-live="polite"]')
|
|
145
|
+
.boundingBox();
|
|
146
|
+
const action = await create.boundingBox();
|
|
147
|
+
if (region === null || action === null) {
|
|
148
|
+
throw new Error('The toast region or the button has no box.');
|
|
149
|
+
}
|
|
150
|
+
expect(region.y + region.height).toBeLessThanOrEqual(action.y);
|
|
151
|
+
await shot(page, `toast-${file}-mobile-${theme}`);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { expect, test } from '@playwright/test';
|
|
2
|
+
import { ThemeMode } from '../../src/theme/tokens/primitives';
|
|
3
|
+
import { openCatalogPage, settle } from './catalog-page';
|
|
4
|
+
|
|
5
|
+
// jsdom has no layout: what the frame holds and where the block handle lands are read from Chromium.
|
|
6
|
+
|
|
7
|
+
const PHONE = { width: 390, height: 844 };
|
|
8
|
+
const DESKTOP = { width: 1440, height: 900 };
|
|
9
|
+
|
|
10
|
+
test("Crepe's stylesheet is in the page, before the styles of the theme, and holds its rules", async ({
|
|
11
|
+
page,
|
|
12
|
+
}) => {
|
|
13
|
+
await openCatalogPage(page, 'MarkdownEditor', ThemeMode.Light, DESKTOP);
|
|
14
|
+
await expect(page.locator('.ProseMirror').first()).toBeVisible();
|
|
15
|
+
const sheet = await page.evaluate(() => {
|
|
16
|
+
const style = document.head.querySelector('style[data-abyss-crepe-styles]');
|
|
17
|
+
return {
|
|
18
|
+
beforeTheme: Array.from(
|
|
19
|
+
document.head.querySelectorAll('style[data-emotion]'),
|
|
20
|
+
).every(
|
|
21
|
+
(theme) =>
|
|
22
|
+
style !== null &&
|
|
23
|
+
(style.compareDocumentPosition(theme) &
|
|
24
|
+
Node.DOCUMENT_POSITION_FOLLOWING) !==
|
|
25
|
+
0,
|
|
26
|
+
),
|
|
27
|
+
holdsRules: style?.textContent?.includes('.milkdown-slash-menu') ?? false,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
expect(sheet).toEqual({ beforeTheme: true, holdsRules: true });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('on a phone the frame grows with the placeholder, the only hint of « / » there', async ({
|
|
34
|
+
page,
|
|
35
|
+
}) => {
|
|
36
|
+
await openCatalogPage(page, 'MarkdownEditor', ThemeMode.Light, PHONE);
|
|
37
|
+
const placeholder = page.locator('.crepe-placeholder');
|
|
38
|
+
await expect(placeholder).toHaveCount(1);
|
|
39
|
+
await placeholder.scrollIntoViewIfNeeded();
|
|
40
|
+
const boxes = () =>
|
|
41
|
+
placeholder.evaluate((paragraph) => {
|
|
42
|
+
const frame = paragraph.closest('.milkdown');
|
|
43
|
+
return {
|
|
44
|
+
paragraphBottom: paragraph.getBoundingClientRect().bottom,
|
|
45
|
+
paragraphHeight: paragraph.getBoundingClientRect().height,
|
|
46
|
+
frameBottom: frame?.getBoundingClientRect().bottom ?? 0,
|
|
47
|
+
lineHeight: parseFloat(getComputedStyle(paragraph).lineHeight),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
const { paragraphBottom, paragraphHeight, frameBottom, lineHeight } =
|
|
51
|
+
await boxes();
|
|
52
|
+
// The text wraps on two lines at this width: the paragraph, hence the frame, holds both.
|
|
53
|
+
expect(paragraphHeight).toBeGreaterThanOrEqual(2 * lineHeight - 1);
|
|
54
|
+
expect(frameBottom).toBeGreaterThanOrEqual(paragraphBottom);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('typing replaces the placeholder, from the start of the line', async ({
|
|
58
|
+
page,
|
|
59
|
+
}) => {
|
|
60
|
+
await openCatalogPage(page, 'MarkdownEditor', ThemeMode.Light, PHONE);
|
|
61
|
+
const placeholder = page.locator('.crepe-placeholder');
|
|
62
|
+
const start = await placeholder.boundingBox();
|
|
63
|
+
await placeholder.click();
|
|
64
|
+
await page.keyboard.type('x');
|
|
65
|
+
await expect(page.locator('.crepe-placeholder')).toHaveCount(0);
|
|
66
|
+
const written = page.locator('.ProseMirror p', { hasText: /^x$/ });
|
|
67
|
+
const text = await written.evaluate((paragraph) => {
|
|
68
|
+
const range = document.createRange();
|
|
69
|
+
range.selectNodeContents(paragraph);
|
|
70
|
+
return range.getBoundingClientRect().left;
|
|
71
|
+
});
|
|
72
|
+
expect(text).toBeCloseTo(start?.x ?? 0, 0);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('under a mouse the block handle stays inside the frame, left of its block', async ({
|
|
76
|
+
page,
|
|
77
|
+
}) => {
|
|
78
|
+
await openCatalogPage(page, 'MarkdownEditor', ThemeMode.Light, DESKTOP);
|
|
79
|
+
const editor = page.locator('.milkdown').first();
|
|
80
|
+
const block = editor.locator('.ProseMirror p').first();
|
|
81
|
+
await block.hover();
|
|
82
|
+
await settle(page);
|
|
83
|
+
const handle = editor.locator('.milkdown-block-handle');
|
|
84
|
+
await expect(handle).toBeVisible();
|
|
85
|
+
const handleBox = await handle.boundingBox();
|
|
86
|
+
const frameBox = await editor.boundingBox();
|
|
87
|
+
const blockBox = await block.boundingBox();
|
|
88
|
+
if (handleBox === null || frameBox === null || blockBox === null) {
|
|
89
|
+
throw new Error('The handle, the frame or the block has no box.');
|
|
90
|
+
}
|
|
91
|
+
expect(handleBox.x).toBeGreaterThanOrEqual(frameBox.x);
|
|
92
|
+
expect(handleBox.x + handleBox.width).toBeLessThanOrEqual(blockBox.x);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('on a phone no block handle is drawn', async ({ page }) => {
|
|
96
|
+
await openCatalogPage(page, 'MarkdownEditor', ThemeMode.Light, PHONE);
|
|
97
|
+
const block = page.locator('.milkdown .ProseMirror p').first();
|
|
98
|
+
await block.click();
|
|
99
|
+
await settle(page);
|
|
100
|
+
const drawn = await page
|
|
101
|
+
.locator('.milkdown-block-handle')
|
|
102
|
+
.evaluateAll(
|
|
103
|
+
(handles) =>
|
|
104
|
+
handles.filter((handle) => handle.getClientRects().length > 0).length,
|
|
105
|
+
);
|
|
106
|
+
expect(drawn).toBe(0);
|
|
107
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
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 } from './catalog-page';
|
|
5
|
+
|
|
6
|
+
// Below `md` the toast region is full width at the bottom: it must keep above the actions of a
|
|
7
|
+
// dialog that reaches the bottom edge. jsdom has no layout: the boxes are read from Chromium.
|
|
8
|
+
|
|
9
|
+
const PHONE = { width: 390, height: 844 };
|
|
10
|
+
|
|
11
|
+
const FAILURE = 'Création impossible : délai dépassé.';
|
|
12
|
+
|
|
13
|
+
/** Bottom of the toast region, a child of `body`; found by `aria-live` since MUI hides it from roles. */
|
|
14
|
+
const regionBottom = async (page: Page): Promise<number> => {
|
|
15
|
+
const box = await page.locator('section[aria-live="polite"]').boundingBox();
|
|
16
|
+
return box === null ? 0 : box.y + box.height;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** The bottom of the toasts once the failure is shown and the top of the button that caused it. */
|
|
20
|
+
const boxesAfterFailure = async (page: Page, dialogName: string) => {
|
|
21
|
+
const dialog = page.getByRole('dialog', { name: dialogName });
|
|
22
|
+
const create = dialog.getByRole('button', { name: 'Créer', exact: true });
|
|
23
|
+
await create.click();
|
|
24
|
+
// By text: MUI puts `aria-hidden` on the region, a sibling of the open modal.
|
|
25
|
+
const failure = page.getByText(FAILURE).first();
|
|
26
|
+
await expect(failure).toBeVisible();
|
|
27
|
+
// The region is measured on the frame after the toast appears.
|
|
28
|
+
await page.waitForTimeout(100);
|
|
29
|
+
const action = await create.boundingBox();
|
|
30
|
+
if (action === null) {
|
|
31
|
+
throw new Error('The button has no box.');
|
|
32
|
+
}
|
|
33
|
+
return { toastBottom: await regionBottom(page), actionTop: action.y };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
for (const { label, opener, dialogName } of [
|
|
37
|
+
{
|
|
38
|
+
label: 'a full-screen MUI dialog',
|
|
39
|
+
opener: 'Dialogue plein écran',
|
|
40
|
+
dialogName: 'Nouvel événement',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: 'the bottom sheet of a Modal',
|
|
44
|
+
opener: 'Modal',
|
|
45
|
+
dialogName: 'Nouveau projet',
|
|
46
|
+
},
|
|
47
|
+
]) {
|
|
48
|
+
test(`a toast stays above the actions of ${label}`, async ({ page }) => {
|
|
49
|
+
await openCatalogPage(page, 'Toast', ThemeMode.Dark, PHONE);
|
|
50
|
+
await page.getByRole('button', { name: opener, exact: true }).click();
|
|
51
|
+
await page.waitForTimeout(400);
|
|
52
|
+
const { toastBottom, actionTop } = await boxesAfterFailure(
|
|
53
|
+
page,
|
|
54
|
+
dialogName,
|
|
55
|
+
);
|
|
56
|
+
expect(toastBottom).toBeLessThanOrEqual(actionTop);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
test('the toast is back at the corner once the dialog is closed', async ({
|
|
61
|
+
page,
|
|
62
|
+
}) => {
|
|
63
|
+
await openCatalogPage(page, 'Toast', ThemeMode.Dark, PHONE);
|
|
64
|
+
await page
|
|
65
|
+
.getByRole('button', { name: 'Dialogue plein écran', exact: true })
|
|
66
|
+
.click();
|
|
67
|
+
await page.waitForTimeout(400);
|
|
68
|
+
const { toastBottom, actionTop } = await boxesAfterFailure(
|
|
69
|
+
page,
|
|
70
|
+
'Nouvel événement',
|
|
71
|
+
);
|
|
72
|
+
expect(toastBottom).toBeLessThanOrEqual(actionTop);
|
|
73
|
+
await page
|
|
74
|
+
.getByRole('dialog', { name: 'Nouvel événement' })
|
|
75
|
+
.getByRole('button', { name: 'Annuler', exact: true })
|
|
76
|
+
.click();
|
|
77
|
+
await expect(
|
|
78
|
+
page.getByRole('dialog', { name: 'Nouvel événement' }),
|
|
79
|
+
).toHaveCount(0);
|
|
80
|
+
await expect
|
|
81
|
+
.poll(() => regionBottom(page))
|
|
82
|
+
.toBeGreaterThan(PHONE.height - 40);
|
|
83
|
+
});
|