feat(editor): one tab order, vertical Plus list with the error count

This commit is contained in:
bchanot committed 2026-11-15 15:52:28 +01:00
1 parent b41c24b29d
commit ff21b0315e
11 files changed
+155 -75

No files matched your search

+28 -29
View File
@@ -345,13 +345,34 @@ export const TABS = [
/** The Annotations sections and the panel, in the order the overview offers them. */
export const SECTIONS = ['views', 'categories', 'regions'] as const
/** Below this width only the tabs of SHOWN_SMALL stay in the row, the others sit under « Plus ». */
const SMALL_TIER_WIDTH = 640
const SHOWN_SMALL = ['general', 'annotations']
/**
* Clicks a tab by role. The name is a pattern: the Vérification tab adds « n erreur(s) »
* to its name while the in-page check has errors.
* Clicks a tab by role, whatever the width: from 640 px the tab button, below it « Plus »
* opened and the tab picked in its list. The name is a pattern: the Vérification tab adds
* « n erreur(s) » to its name while the in-page check has errors.
*/
export async function selectTab(page: Page, dict: Dict, tab: string) {
const name = dict[`editor.tab.${tab}`]
await page.getByRole('tab', { name: new RegExp(`^${name}( |$)`) }).click()
const width = page.viewportSize()?.width ?? SMALL_TIER_WIDTH
const name = new RegExp(`^${dict[`editor.tab.${tab}`]}( |$)`)
if (width >= SMALL_TIER_WIDTH || SHOWN_SMALL.includes(tab)) {
await page.getByRole('tab', { name }).click()
return
}
const more = morePlus(page, dict)
if ((await more.getAttribute('aria-expanded')) !== 'true') await more.click()
await page.locator('#editor-tabs-more').getByRole('button', { name }).click()
// The dropdown fades out: wait for it to be gone before the next move.
await expect(page.locator('#editor-tabs-more')).toHaveCount(0)
}
/** « Plus », located without an exact name: it carries the Vérification error count. */
export function morePlus(page: Page, dict: Dict): Locator {
return page.getByRole('button', {
name: new RegExp(`^${dict['editor.tab.more']}( |$)`),
})
}
/** The visible place with this `data-place` name; a hidden copy never answers. */
@@ -395,34 +416,12 @@ export function libraryRoot(page: Page): Locator {
return place(page, 'references')
}
/** Below this width the tabs other than Annotations and Vérification sit under « Plus ». */
const SMALL_TIER_WIDTH = 640
/**
* Shows a tab whatever the width: the tab button from 640 px, below it « Plus » opened and
* the tab picked in its list. Waits for the tab's place to be visible (Annotations names
* its sections, so any of them).
* Shows a tab whatever the width (selectTab). Waits for the tab's place to be visible
* (Annotations names its sections, so any of them).
*/
export async function openTab(page: Page, dict: Dict, tab: string) {
const width = page.viewportSize()?.width ?? SMALL_TIER_WIDTH
const name = new RegExp(`^${dict[`editor.tab.${tab}`]}( |$)`)
const listed = ['annotations', 'verification'].includes(tab)
if (width < SMALL_TIER_WIDTH && !listed) {
const more = page.getByRole('button', {
name: dict['editor.tab.more'],
exact: true,
})
if ((await more.getAttribute('aria-expanded')) !== 'true')
await more.click()
await page
.locator('#editor-tabs-more')
.getByRole('button', { name })
.click()
// The dropdown fades out: wait for it to be gone before the next move.
await expect(page.locator('#editor-tabs-more')).toHaveCount(0)
} else {
await page.getByRole('tab', { name }).click()
}
await selectTab(page, dict, tab)
await expect(
tab === 'annotations'
? page.locator('[data-place^=annotations]:visible').first()