test(editor): reference dialog, filter and the owner journey, specs follow the dialog
This commit is contained in:
1 parent
7a64daf251
commit
8b42816270
20 files changed
+1546
-1171
No files matched your search
@@ -427,11 +427,58 @@ export async function openTab(page: Page, dict: Dict, tab: string) {
|
||||
).toBeVisible()
|
||||
}
|
||||
|
||||
/** The open finding dialog: the layer dialog that is not the citations sheet. */
|
||||
/** The open finding dialog: the layer dialog that is neither the sheet nor the reference form. */
|
||||
export const findingDialog = (page: Page): Locator =>
|
||||
page.locator('dialog[open][data-layer]').filter({
|
||||
hasNot: page.locator('[data-place="citations"], #reference-form-citation'),
|
||||
})
|
||||
|
||||
/** The open reference dialog (R2F-5): the layer dialog that holds the reference form. */
|
||||
export const referenceDialog = (page: Page): Locator =>
|
||||
page
|
||||
.locator('dialog[open][data-layer]')
|
||||
.filter({ hasNot: page.locator('[data-place="citations"]') })
|
||||
.filter({ has: page.locator('#reference-form-citation') })
|
||||
|
||||
/**
|
||||
* Waits for the history to settle on a view without the reference layer (or, with
|
||||
* `keepDialog`, with one): a close pops its entry from an effect, and a move made before
|
||||
* the pop lands would be undone by it (a user cannot be that quick, a script can).
|
||||
*/
|
||||
export async function referenceSettled(page: Page, keepDialog = false) {
|
||||
await page.waitForFunction((stays) => {
|
||||
const view = history.state?.usr?.editorEntry?.view
|
||||
if (!view) return true
|
||||
return stays ? view.reference !== null : view.reference === null
|
||||
}, keepDialog)
|
||||
}
|
||||
|
||||
/** Opens « Ajouter une référence » (the References tab is shown): the form is ready. */
|
||||
export async function startReference(page: Page, dict: Dict) {
|
||||
await libraryRoot(page)
|
||||
.getByRole('button', { name: dict['editor.references.add'] })
|
||||
.click()
|
||||
await expect(referenceDialog(page)).toBeVisible()
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a reference through the dialog and waits for every layer to be gone. The list
|
||||
* does not move and the focus goes back to « Ajouter » (R2F-5): nothing is focused on the
|
||||
* new tile.
|
||||
*/
|
||||
export async function addReference(
|
||||
page: Page,
|
||||
dict: Dict,
|
||||
citation: string,
|
||||
type = 'book',
|
||||
) {
|
||||
await startReference(page, dict)
|
||||
const form = referenceDialog(page)
|
||||
await form.locator('#reference-form-type').selectOption(type)
|
||||
await form.locator('#reference-form-citation').fill(citation)
|
||||
await form.getByRole('button', { name: dict['editor.reference.add'] }).click()
|
||||
await expectNoDialog(page)
|
||||
await referenceSettled(page)
|
||||
}
|
||||
|
||||
/** Waits until no modal dialog is open: nothing is typed or pressed before (LRN-111/116). */
|
||||
export const expectNoDialog = (page: Page) =>
|
||||
|
||||
Reference in new issue
Block a user