test: Disable popup in tests

This commit is contained in:
Sidharth Vinod
2026-03-03 23:45:51 +05:30
parent 13e5e834a2
commit dabbf5700a
3 changed files with 9 additions and 5 deletions
+1
View File
@@ -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;
+3 -4
View File
@@ -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
View File
@@ -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();