1+ import randomatic from "randomatic" ;
2+
13import { expect , test } from "../fixtures" ;
24import { waitForToast } from "../utils" ;
5+ import { waitForLoadingOverlayGone } from "../utils/waitForLoadingOverlayToDisappear" ;
6+ import { waitForMonacoEditorToLoad } from "../utils/waitForMonacoEditor" ;
37
48const varName = "nameVariable" ;
59
6- test . beforeEach ( async ( { dashboardPage, page } ) => {
7- await dashboardPage . createProjectFromMenu ( ) ;
10+ let projectId : string ;
11+
12+ test . beforeAll ( async ( { browser } ) => {
13+ const context = await browser . newContext ( ) ;
14+ const page = await context . newPage ( ) ;
15+
16+ await waitForLoadingOverlayGone ( page ) ;
17+ await page . goto ( "/" ) ;
18+ await page . locator ( 'nav[aria-label="Main navigation"] button[aria-label="New Project"]' ) . hover ( ) ;
19+ await page . locator ( 'nav[aria-label="Main navigation"] button[aria-label="New Project"]' ) . click ( ) ;
20+ await page . getByRole ( "button" , { name : "New Project From Scratch" } ) . hover ( ) ;
21+ await page . getByRole ( "button" , { name : "New Project From Scratch" } ) . click ( ) ;
22+ const projectName = randomatic ( "Aa" , 8 ) ;
23+ await page . getByPlaceholder ( "Enter project name" ) . fill ( projectName ) ;
24+ await page . getByRole ( "button" , { name : "Create" , exact : true } ) . click ( ) ;
25+ await expect ( page . locator ( 'button[aria-label="Open program.py"]' ) ) . toBeVisible ( ) ;
26+ await page . getByRole ( "button" , { name : "Open program.py" } ) . click ( ) ;
27+
28+ await expect ( page . getByRole ( "tab" , { name : "program.py Close file tab" } ) ) . toBeVisible ( ) ;
29+
30+ await waitForMonacoEditorToLoad ( page , 6000 ) ;
831
32+ await expect ( page . getByRole ( "heading" , { name : "Configuration" } ) ) . toBeVisible ( { timeout : 1200 } ) ;
33+
34+ projectId = page . url ( ) . match ( / \/ p r o j e c t s \/ ( [ ^ / ] + ) / ) ?. [ 1 ] || "" ;
35+
36+ await page . goto ( `/projects/${ projectId } /explorer/settings` ) ;
937 await page . locator ( 'button[aria-label="Add Variables"]' ) . click ( ) ;
1038
1139 await page . getByLabel ( "Name" , { exact : true } ) . click ( ) ;
@@ -16,6 +44,12 @@ test.beforeEach(async ({ dashboardPage, page }) => {
1644
1745 const toast = await waitForToast ( page , "Variable created successfully" ) ;
1846 await expect ( toast ) . toBeVisible ( ) ;
47+
48+ await context . close ( ) ;
49+ } ) ;
50+
51+ test . beforeEach ( async ( { page } ) => {
52+ await page . goto ( `/projects/${ projectId } /explorer/settings` ) ;
1953} ) ;
2054
2155test . describe ( "Project Variables Suite" , ( ) => {
@@ -89,15 +123,15 @@ test.describe("Project Variables Suite", () => {
89123 } ) ;
90124
91125 test ( "Modify variable with active deployment" , async ( { page } ) => {
92- await page . locator ( 'button[aria-label="Close Project Settings"]' ) . click ( ) ;
93-
94126 const deployButton = page . locator ( 'button[aria-label="Deploy project"]' ) ;
95127 await deployButton . click ( ) ;
96128
97- await page . locator ( 'button[aria-label="Config"]' ) . click ( ) ;
129+ const toast = await waitForToast ( page , "Project successfully deployed with 1 warning" ) ;
130+ await expect ( toast ) . toBeVisible ( ) ;
131+ await expect ( toast ) . not . toBeVisible ( { timeout : 5000 } ) ;
98132
99- const configureButtons = page . locator ( 'button[aria-label="Edit "]' ) ;
100- await configureButtons . first ( ) . click ( ) ;
133+ const configureButton = page . locator ( 'button[id="nameVariable-variable-configure-button "]' ) ;
134+ await configureButton . click ( ) ;
101135
102136 const okButton = page . locator ( 'button[aria-label="Ok"]' ) ;
103137 if ( await okButton . isVisible ( ) ) {
@@ -108,6 +142,8 @@ test.describe("Project Variables Suite", () => {
108142 await page . getByLabel ( "Value" ) . fill ( "newValueVariable" ) ;
109143 await page . locator ( 'button[aria-label="Save"]' ) . click ( ) ;
110144 await page . waitForURL ( / \/ p r o j e c t s \/ [ ^ / ] + \/ e x p l o r e r \/ s e t t i n g s / ) ;
145+ await page . locator ( 'button[aria-label="Config"]' ) . click ( ) ;
146+
111147 await page . locator ( "button[aria-label='Variable information for \"nameVariable\"']" ) . hover ( ) ;
112148 await expect ( page . getByText ( "newValueVariable" ) ) . toBeVisible ( ) ;
113149 } ) ;
0 commit comments