Skip to content

Commit 8bf69d5

Browse files
authored
Prefer builtin NODE_ENV over custom Playwright environment variable (#7723)
Remove explicit Playwright environment variable
1 parent 55ab703 commit 8bf69d5

File tree

9 files changed

+12
-15
lines changed

9 files changed

+12
-15
lines changed

e2e/playwright/fixtures/fixtureSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class ElectronZoo {
134134
args: ['.', '--no-sandbox'],
135135
env: {
136136
...process.env,
137-
IS_PLAYWRIGHT: 'true',
137+
NODE_ENV: 'test',
138138
},
139139
...(process.env.ELECTRON_OVERRIDE_DIST_PATH
140140
? {

interface.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export interface IElectronAPI {
7272
}
7373
process: {
7474
env: {
75-
IS_PLAYWRIGHT: string
7675
VITE_KITTYCAD_API_BASE_URL: string
7776
VITE_KITTYCAD_API_WEBSOCKET_URL: string
7877
VITE_KITTYCAD_API_TOKEN: string

src/components/CommandBar/CommandBarPathInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function CommandBarPathInput({
7474

7575
// Fire on component mount, if outside of e2e test context
7676
useEffect(() => {
77-
window.electron.process.env.IS_PLAYWRIGHT !== 'true' &&
77+
window.electron.process.env.NODE_ENV !== 'test' &&
7878
toSync(pickFileThroughNativeDialog, reportRejection)()
7979
}, [])
8080

src/lib/desktop.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ const getAppFolderName = () => {
477477
}
478478

479479
export const getAppSettingsFilePath = async () => {
480-
const isTestEnv = window.electron.process.env.IS_PLAYWRIGHT === 'true'
480+
const isTestEnv = window.electron.process.env.NODE_ENV === 'test'
481481
const testSettingsPath = await window.electron.getAppTestProperty(
482482
'TEST_SETTINGS_FILE_KEY'
483483
)
@@ -499,7 +499,7 @@ export const getAppSettingsFilePath = async () => {
499499
return window.electron.path.join(fullPath, SETTINGS_FILE_NAME)
500500
}
501501
const getTokenFilePath = async () => {
502-
const isTestEnv = window.electron.process.env.IS_PLAYWRIGHT === 'true'
502+
const isTestEnv = window.electron.process.env.NODE_ENV === 'test'
503503
const testSettingsPath = await window.electron.getAppTestProperty(
504504
'TEST_SETTINGS_FILE_KEY'
505505
)
@@ -520,7 +520,7 @@ const getTokenFilePath = async () => {
520520
}
521521

522522
const getTelemetryFilePath = async () => {
523-
const isTestEnv = window.electron.process.env.IS_PLAYWRIGHT === 'true'
523+
const isTestEnv = window.electron.process.env.NODE_ENV === 'test'
524524
const testSettingsPath = await window.electron.getAppTestProperty(
525525
'TEST_SETTINGS_FILE_KEY'
526526
)
@@ -541,7 +541,7 @@ const getTelemetryFilePath = async () => {
541541
}
542542

543543
const getRawTelemetryFilePath = async () => {
544-
const isTestEnv = window.electron.process.env.IS_PLAYWRIGHT === 'true'
544+
const isTestEnv = window.electron.process.env.NODE_ENV === 'test'
545545
const testSettingsPath = await window.electron.getAppTestProperty(
546546
'TEST_SETTINGS_FILE_KEY'
547547
)
@@ -573,7 +573,7 @@ const getProjectSettingsFilePath = async (projectPath: string) => {
573573
}
574574

575575
export const getInitialDefaultDir = async () => {
576-
const isTestEnv = window.electron.process.env.IS_PLAYWRIGHT === 'true'
576+
const isTestEnv = window.electron.process.env.NODE_ENV === 'test'
577577
const testSettingsPath = await window.electron.getAppTestProperty(
578578
'TEST_SETTINGS_FILE_KEY'
579579
)

src/lib/exportSave.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const save_ = async (file: ModelingAppFile, toastId: string) => {
1515
extensions.push(extension)
1616
}
1717

18-
if (window.electron.process.env.IS_PLAYWRIGHT) {
18+
if (window.electron.process.env.NODE_ENV === 'test') {
1919
// Skip file picker, save to the test dir downloads directory
2020
const testSettingsPath = await window.electron.getAppTestProperty(
2121
'TEST_SETTINGS_FILE_KEY'

src/lib/isPlaywright.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { IS_PLAYWRIGHT_KEY } from '@src/lib/constants'
33
export function isPlaywright(): boolean {
44
// ? checks for browser
55
const electronRunTimePlaywright =
6-
window?.electron?.process?.env.IS_PLAYWRIGHT == 'true'
6+
window?.electron?.process?.env.NODE_ENV === 'test'
77
const browserRuntimePlaywright =
88
localStorage.getItem(IS_PLAYWRIGHT_KEY) === 'true'
99
return electronRunTimePlaywright || browserRuntimePlaywright

src/lib/routeLoaders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const fileLoader: LoaderFunction = async (
9494

9595
// If persistCode in localStorage is present, it'll persist that code
9696
// through *anything*. INTENDED FOR TESTS.
97-
if (window.electron.process.env.IS_PLAYWRIGHT) {
97+
if (window.electron.process.env.NODE_ENV === 'test') {
9898
code = codeManager.localStoragePersistCode() || code
9999
}
100100

src/main.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const args = parseCLIArgs(process.argv)
6363
// @ts-ignore: TS1343
6464
const viteEnv = import.meta.env
6565
const NODE_ENV = process.env.NODE_ENV || viteEnv.MODE
66-
const IS_PLAYWRIGHT = process.env.IS_PLAYWRIGHT
6766

6867
// dotenv override when present
6968
dotenv.config({ path: [`.env.${NODE_ENV}.local`, `.env.${NODE_ENV}`] })
@@ -96,7 +95,7 @@ if (process.defaultApp) {
9695
// Must be done before ready event.
9796
// Checking against this lock is needed for Windows and Linux, see
9897
// https://www.electronjs.org/docs/latest/tutorial/launch-app-from-url-in-another-app#windows-and-linux-code
99-
if (!singleInstanceLock && !IS_PLAYWRIGHT) {
98+
if (!singleInstanceLock && process.env.NODE_ENV !== 'test') {
10099
app.quit()
101100
} else {
102101
registerStartupListeners()
@@ -592,7 +591,7 @@ const getProjectPathAtStartup = async (
592591
// startup.
593592
// Since the args passed are always '.'
594593
// aka Forge for npm run tron:start live dev or playwright tests, but not dev packaged apps
595-
if (MAIN_WINDOW_VITE_DEV_SERVER_URL || IS_PLAYWRIGHT) {
594+
if (MAIN_WINDOW_VITE_DEV_SERVER_URL || process.env.NODE_ENV === 'test') {
596595
return null
597596
}
598597

src/preload.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ contextBridge.exposeInMainWorld('electron', {
293293
'VITE_KITTYCAD_API_TOKEN',
294294
'VITE_KITTYCAD_SITE_BASE_URL',
295295
'VITE_KITTYCAD_SITE_APP_URL',
296-
'IS_PLAYWRIGHT',
297296
'TEST',
298297
])
299298
),

0 commit comments

Comments
 (0)