mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 16:09:05 +00:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
21 lines
1002 B
JavaScript
21 lines
1002 B
JavaScript
// Sign Out stops on the drafts count dialog, or, when an editor with unsaved changes is open, on that editor's leave dialog instead.
|
|
export async function confirmDraftSignOut(page, timeout = 5000) {
|
|
const confirm = page.locator('[data-test="editor-draft-signout-confirm"]');
|
|
const discard = page
|
|
.locator('[data-test="editor-draft-leave-dialog"], [data-test="dashboard-panel-leave-dialog"]')
|
|
.locator('[data-test="o-dialog-neutral-btn"]')
|
|
.first();
|
|
// With no drafts and no dirty editor the app goes straight to /login, which ends the wait at once.
|
|
await Promise.race([
|
|
confirm.waitFor({ state: 'visible', timeout }),
|
|
discard.waitFor({ state: 'visible', timeout }),
|
|
page.waitForURL(/\/login/, { timeout }),
|
|
]).catch(() => {});
|
|
if (await confirm.isVisible().catch(() => false)) {
|
|
await confirm.click();
|
|
} else if (await discard.isVisible().catch(() => false)) {
|
|
await discard.click();
|
|
}
|
|
await page.waitForURL(/\/login/, { timeout }).catch(() => {});
|
|
}
|