1
1
import { FullConfig } from '@playwright/test'
2
2
import dotenv from 'dotenv'
3
+ import * as fs from 'fs'
4
+ import * as path from 'path'
3
5
4
6
import { backupPath } from './utils/backupUtils'
5
7
@@ -18,4 +20,42 @@ export default function globalSetup(config: FullConfig) {
18
20
)
19
21
}
20
22
}
23
+
24
+ // Create default user by writing directly to users.json file
25
+ // This bypasses the API and ensures the user exists at filesystem level
26
+ // TODO: Remove this once the backend is fixed
27
+ try {
28
+ const testComfyuiDir = process . env . TEST_COMFYUI_DIR
29
+ if ( ! testComfyuiDir ) {
30
+ console . warn ( 'TEST_COMFYUI_DIR is not set' )
31
+ return
32
+ }
33
+ const usersJsonPath = path . join ( testComfyuiDir , 'user' , 'users.json' )
34
+
35
+ console . log ( 'Creating default user in users.json...' )
36
+
37
+ // Ensure user directory exists
38
+ const userDirPath = path . dirname ( usersJsonPath )
39
+ if ( ! fs . existsSync ( userDirPath ) ) {
40
+ fs . mkdirSync ( userDirPath , { recursive : true } )
41
+ }
42
+
43
+ // Create or update users.json with default user
44
+ let users = { }
45
+ if ( fs . existsSync ( usersJsonPath ) ) {
46
+ const existingContent = fs . readFileSync ( usersJsonPath , 'utf8' )
47
+ users = JSON . parse ( existingContent )
48
+ }
49
+
50
+ // Add default user if it doesn't exist
51
+ if ( ! users [ 'default' ] ) {
52
+ users [ 'default' ] = 'default'
53
+ fs . writeFileSync ( usersJsonPath , JSON . stringify ( users ) )
54
+ console . log ( 'Default user added to users.json successfully' )
55
+ } else {
56
+ console . log ( 'Default user already exists in users.json' )
57
+ }
58
+ } catch ( error ) {
59
+ console . warn ( 'Failed to create default user in users.json:' , error )
60
+ }
21
61
}
0 commit comments