test: Disable popup in tests
This commit is contained in:
@@ -11,5 +11,6 @@ export const TID = {
|
||||
|
||||
export const C = {
|
||||
aiLiveEditor: 'ai_live_editor',
|
||||
editorChooserDismissedKey: 'mermaid-editor-chooser-dismissed',
|
||||
utmSource: 'mermaid_live_editor'
|
||||
} as const;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { C } from '$/constants';
|
||||
import { env } from '$/util/env';
|
||||
|
||||
const mermaidAiDomain = 'mermaid.ai';
|
||||
@@ -41,15 +42,13 @@ const hasPakoData = (): boolean => {
|
||||
);
|
||||
};
|
||||
|
||||
const editorChooserStorageKey = 'mermaid-editor-chooser-dismissed';
|
||||
|
||||
/**
|
||||
* Check if the editor chooser modal should be shown.
|
||||
* Shows for new users who haven't dismissed it and aren't viewing a shared link.
|
||||
*/
|
||||
export const shouldShowEditorChooser = (): boolean => {
|
||||
if (!env.isEnabledMermaidChartLinks) return false;
|
||||
if (window.localStorage.getItem(editorChooserStorageKey) === 'true') return false;
|
||||
if (window.localStorage.getItem(C.editorChooserDismissedKey) === 'true') return false;
|
||||
if (hasStoredUserData()) return false;
|
||||
if (hasPakoData()) return false;
|
||||
return true;
|
||||
@@ -59,5 +58,5 @@ export const shouldShowEditorChooser = (): boolean => {
|
||||
* Dismiss the editor chooser modal permanently
|
||||
*/
|
||||
export const dismissEditorChooser = (): void => {
|
||||
window.localStorage.setItem(editorChooserStorageKey, 'true');
|
||||
window.localStorage.setItem(C.editorChooserDismissedKey, 'true');
|
||||
};
|
||||
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
import { TID } from '$/constants';
|
||||
import { C, TID } from '$/constants';
|
||||
import { test as base, expect, type Locator, type Page } from '@playwright/test';
|
||||
import { verifyFileSizeGreaterThan, type EditorOptions } from './utils';
|
||||
|
||||
@@ -115,6 +115,10 @@ export class EditorPage {
|
||||
|
||||
export const test = base.extend<{ editPage: EditorPage }>({
|
||||
editPage: async ({ page }, use) => {
|
||||
// Dismiss the editor chooser modal so it doesn't block interactions
|
||||
await page.addInitScript((key) => {
|
||||
window.localStorage.setItem(key, 'true');
|
||||
}, C.editorChooserDismissedKey);
|
||||
const editorPage = new EditorPage(page);
|
||||
await editorPage.start();
|
||||
await editorPage.toggleSampleDiagrams();
|
||||
|
||||
Reference in New Issue
Block a user