chore: reduce ux conflicts with toasts in playwright (#6367)

This commit is contained in:
Bijin A B
2025-12-09 23:11:16 +05:30
committed by GitHub
parent 879d2271b7
commit 4d1c3f9e52
4 changed files with 9 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import React from 'react';
import { Toaster } from 'react-hot-toast';
import { useTheme } from 'providers/Theme';
import { isPlaywright } from 'utils/common';
export const ToastContext = React.createContext();
@@ -8,7 +9,7 @@ export const ToastProvider = (props) => {
const { storedTheme } = useTheme();
const toastOptions = {
duration: 2000,
duration: isPlaywright() ? 500 : 2000,
style: {
// Break long word like file-path, URL etc. to prevent overflow
overflowWrap: 'anywhere'

View File

@@ -5,6 +5,10 @@ import fastJsonFormat from 'fast-json-format';
import { format, applyEdits } from 'jsonc-parser';
import { patternHasher } from '@usebruno/common/utils';
export const isPlaywright = () => {
return typeof window !== 'undefined' && window.isPlaywright === true;
};
// a customized version of nanoid without using _ and -
export const uuid = () => {
// https://github.com/ai/nanoid/blob/main/url-alphabet/index.js

View File

@@ -1,5 +1,7 @@
const { ipcRenderer, contextBridge, webUtils, shell } = require('electron');
contextBridge.exposeInMainWorld('isPlaywright', process.env.PLAYWRIGHT === 'true');
contextBridge.exposeInMainWorld('ipcRenderer', {
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
send: (channel, ...args) => ipcRenderer.send(channel, ...args),

View File

@@ -90,6 +90,7 @@ export const test = baseTest.extend<
...process.env,
ELECTRON_USER_DATA_PATH: userDataPath,
DISABLE_SAMPLE_COLLECTION_IMPORT: 'true',
PLAYWRIGHT: 'true',
...dotEnv
}
});