@@ -7,6 +7,9 @@ import type {
77
88import { expect , test } from "@playwright/test" ;
99
10+ const baseURL = new URL ( process . env . BASE_URL as string ) ;
11+ baseURL . pathname = process . env . BASE_PATH ?? "/" ;
12+
1013test ( "Project bootstrap works" , async ( { page, baseURL } ) => {
1114 // Display any logs to terminal (for debug)
1215 page . on ( "console" , async ( msg ) => {
@@ -20,20 +23,23 @@ test("Project bootstrap works", async ({ page, baseURL }) => {
2023 expect ( baseURL ) . toBeDefined ( ) ;
2124
2225 const url = new URL ( baseURL as string ) ;
23- url . pathname = "/api/as-api/organisation/default" ;
26+ const basePath = url . pathname ;
27+
28+ url . pathname = basePath + "/api/as-api/organisation/default" ;
29+
2430 const defaultOrg : OrganisationGetDefaultResponse = await (
25- await page . request . get ( url . href )
31+ await page . request . get ( new URL ( url ) . href )
2632 ) . json ( ) ;
2733
2834 // Ensure default unit and associated projects and products doesn't exist
29- url . pathname = `/api/as-api/organisation/${ defaultOrg . id } /unit` ;
35+ url . pathname = basePath + `/api/as-api/organisation/${ defaultOrg . id } /unit` ;
3036 const units = ( ( await ( await page . request . get ( url . href ) ) . json ( ) ) as OrganisationUnitsGetResponse )
3137 . units ;
3238
3339 const personalUnit = units . find ( ( unit ) => unit . name === process . env . PW_USERNAME ) ;
3440
3541 if ( personalUnit ) {
36- url . pathname = "/api/as-api/product" ;
42+ url . pathname = basePath + "/api/as-api/product" ;
3743 const products = ( ( await ( await page . request . get ( url . href ) ) . json ( ) ) as ProductsGetResponse )
3844 . products ;
3945
@@ -44,14 +50,14 @@ test("Project bootstrap works", async ({ page, baseURL }) => {
4450 product . product . type === "DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION" ,
4551 ) ;
4652 const productPromises = productsToDelete . map ( async ( product ) => {
47- url . pathname = `/api/dm-api/project/${ product . claim ?. id } ` ;
53+ url . pathname = basePath + `/api/dm-api/project/${ product . claim ?. id } ` ;
4854 page . request . delete ( url . href ) ;
49- url . pathname = `/api/as-api/product/${ product . product . id } ` ;
55+ url . pathname = basePath + `/api/as-api/product/${ product . product . id } ` ;
5056 page . request . delete ( url . href ) ;
5157 } ) ;
5258 await Promise . allSettled ( productPromises ) ;
5359
54- url . pathname = "/api/as-api/unit" ;
60+ url . pathname = basePath + "/api/as-api/unit" ;
5561 const res = await page . request . delete ( url . href ) ;
5662
5763 const response = await res . json ( ) ;
0 commit comments