1
- import { type BrowserContext , expect , type Page } from "@playwright/test" ;
1
+ import { type BrowserContext , expect , type Page , test } from "@playwright/test" ;
2
2
import axios from "axios" ;
3
3
import { type ChildProcess , exec , spawn } from "child_process" ;
4
4
import { randomUUID } from "crypto" ;
@@ -12,7 +12,13 @@ import type {
12
12
UpdateTemplateMeta ,
13
13
} from "api/typesGenerated" ;
14
14
import { TarWriter } from "utils/tar" ;
15
- import { agentPProfPort , coderPort , prometheusPort } from "./constants" ;
15
+ import {
16
+ agentPProfPort ,
17
+ coderMain ,
18
+ coderPort ,
19
+ enterpriseLicense ,
20
+ prometheusPort ,
21
+ } from "./constants" ;
16
22
import {
17
23
Agent ,
18
24
type App ,
@@ -25,6 +31,11 @@ import {
25
31
type RichParameter ,
26
32
} from "./provisionerGenerated" ;
27
33
34
+ // requiresEnterpriseLicense will skip the test if we're not running with an enterprise license
35
+ export function requiresEnterpriseLicense ( ) {
36
+ test . skip ( ! enterpriseLicense ) ;
37
+ }
38
+
28
39
// createWorkspace creates a workspace for a template.
29
40
// It does not wait for it to be running, but it does navigate to the page.
30
41
export const createWorkspace = async (
@@ -147,7 +158,7 @@ export const sshIntoWorkspace = async (
147
158
binaryArgs : string [ ] = [ ] ,
148
159
) : Promise < ssh . Client > => {
149
160
if ( binaryPath === "go" ) {
150
- binaryArgs = [ "run" , coderMainPath ( ) ] ;
161
+ binaryArgs = [ "run" , coderMain ] ;
151
162
}
152
163
const sessionToken = await findSessionToken ( page ) ;
153
164
return new Promise < ssh . Client > ( ( resolve , reject ) => {
@@ -229,7 +240,7 @@ export const startAgent = async (
229
240
page : Page ,
230
241
token : string ,
231
242
) : Promise < ChildProcess > => {
232
- return startAgentWithCommand ( page , token , "go" , "run" , coderMainPath ( ) ) ;
243
+ return startAgentWithCommand ( page , token , "go" , "run" , coderMain ) ;
233
244
} ;
234
245
235
246
// downloadCoderVersion downloads the version provided into a temporary dir and
@@ -358,18 +369,6 @@ const waitUntilUrlIsNotResponding = async (url: string) => {
358
369
) ;
359
370
} ;
360
371
361
- const coderMainPath = ( ) : string => {
362
- return path . join (
363
- __dirname ,
364
- ".." ,
365
- ".." ,
366
- "enterprise" ,
367
- "cmd" ,
368
- "coder" ,
369
- "main.go" ,
370
- ) ;
371
- } ;
372
-
373
372
// Allows users to more easily define properties they want for agents and resources!
374
373
type RecursivePartial < T > = {
375
374
[ P in keyof T ] ?: T [ P ] extends ( infer U ) [ ]
@@ -686,7 +685,7 @@ export const updateTemplate = async (
686
685
"go" ,
687
686
[
688
687
"run" ,
689
- coderMainPath ( ) ,
688
+ coderMain ,
690
689
"templates" ,
691
690
"push" ,
692
691
"--test.provisioner" ,
0 commit comments