11// @ts -check
22///<reference path="../global.d.ts"/>
33
4- Cypress . _ . times ( import . meta. env . VITE_SI_CYPRESS_MULTIPLIER ? import . meta. env . VITE_SI_CYPRESS_MULTIPLIER : 1 , ( ) => {
4+ const SI_CYPRESS_MULTIPLIER = Cypress . env ( 'VITE_SI_CYPRESS_MULTIPLIER' ) || import . meta. env . VITE_SI_CYPRESS_MULTIPLIER || 1 ;
5+ const AUTH0_USERNAME = Cypress . env ( 'VITE_AUTH0_USERNAME' ) || import . meta. env . VITE_AUTH0_USERNAME ;
6+ const AUTH0_PASSWORD = Cypress . env ( 'VITE_AUTH0_PASSWORD' ) || import . meta. env . VITE_AUTH0_PASSWORD ;
7+ const AUTH_API_URL = Cypress . env ( 'VITE_AUTH_API_URL' ) || import . meta. env . VITE_AUTH_API_URL ;
8+ const SI_WORKSPACE_ID = Cypress . env ( 'VITE_SI_WORKSPACE_ID' ) || import . meta. env . VITE_SI_WORKSPACE_ID ;
9+ const SI_WORKSPACE_URL = Cypress . env ( 'VITE_SI_WORKSPACE_URL' ) || import . meta. env . VITE_SI_WORKSPACE_URL ;
10+ const UUID = Cypress . env ( 'VITE_UUID' ) || import . meta. env . VITE_UUID || "local" ;
11+
12+ Cypress . _ . times ( SI_CYPRESS_MULTIPLIER , ( ) => {
513 describe ( 'component' , ( ) => {
614 beforeEach ( function ( ) {
7- cy . loginToAuth0 ( import . meta . env . VITE_AUTH0_USERNAME , import . meta . env . VITE_AUTH0_PASSWORD ) ;
15+ cy . loginToAuth0 ( AUTH0_USERNAME , AUTH0_PASSWORD ) ;
816 } ) ;
917
1018 it ( 'value_propagation' , ( ) => {
11-
12- console . log ( import . meta. env . VITE_UUID ) ;
13- cy . log ( import . meta. env . VITE_UUID ) ;
19+ console . log ( UUID ) ;
20+ cy . log ( UUID ) ;
1421
1522 // Go to the Synthetic Workspace
16- cy . visit ( import . meta. env . VITE_SI_WORKSPACE_URL + '/w/' + import . meta. env . VITE_SI_WORKSPACE_ID + '/head' )
17- cy . sendPosthogEvent ( Cypress . currentTest . titlePath . join ( "/" ) , "test_uuid" , import . meta. env . VITE_UUID ? import . meta. env . VITE_UUID : "local" ) ;
18-
23+ cy . visit ( SI_WORKSPACE_URL + '/w/' + SI_WORKSPACE_ID + '/head' ) ;
24+ cy . sendPosthogEvent ( Cypress . currentTest . titlePath . join ( "/" ) , "test_uuid" , UUID ) ;
1925 cy . get ( '#vorm-input-3' , { timeout : 30000 } ) . should ( 'have.value' , 'Change Set 1' ) ;
2026
21- cy . get ( '#vorm-input-3' ) . clear ( ) . type ( import . meta . env . VITE_UUID ? import . meta . env . VITE_UUID : "local" ) ;
27+ cy . get ( '#vorm-input-3' ) . clear ( ) . type ( UUID ) ;
2228
23- cy . get ( '#vorm-input-3' , { timeout : 30000 } ) . should ( 'have.value' , import . meta . env . VITE_UUID ? import . meta . env . VITE_UUID : "local" ) ;
29+ cy . get ( '#vorm-input-3' , { timeout : 30000 } ) . should ( 'have.value' , UUID ) ;
2430
2531 cy . contains ( 'Create change set' , { timeout : 30000 } ) . click ( ) ;
2632
2733 // Give time to redirect onto the new changeset
2834 cy . url ( ) . should ( 'not.include' , 'head' , { timeout : 10000 } ) ;
2935
36+ // Find the AWS Credential
37+ cy . get ( 'div[class="tree-node"]' , { timeout : 30000 } ) . contains ( 'Region' ) . as ( 'awsRegion' ) ;
38+
39+ // Find the canvas to get a location to drag to
40+ cy . get ( 'canvas' ) . first ( ) . as ( 'konvaStage' ) ;
41+
42+ cy . intercept ( 'POST' , '/api/diagram/create_component' ) . as ( 'componentA' ) ;
43+ let componentIDA , componentIDB , bearertoken ;
44+
45+ // drag to the canvas
46+ cy . dragTo ( '@awsRegion' , '@konvaStage' ) ;
47+ cy . wait ( '@componentA' , { timeout : 60000 } ) . then ( async ( interception ) => {
48+ componentIDA = interception . response ?. body . componentId ;
49+ } ) ;
50+
51+ cy . wait ( 5000 ) ;
52+
53+ cy . get ( 'div[class="tree-node"]' , { timeout : 30000 } ) . contains ( 'EC2 Instance' ) . as ( 'awsEC2' ) ;
54+
55+ cy . intercept ( 'POST' , '/api/diagram/create_component' ) . as ( 'componentB' ) ;
56+ cy . dragTo ( '@awsEC2' , '@konvaStage' , 0 , 75 ) ;
57+
58+ cy . wait ( '@componentB' , { timeout : 60000 } ) . then ( async ( interception ) => {
59+ bearertoken = interception . request . headers . authorization ;
60+ componentIDB = interception . response ?. body . componentId ;
61+ } ) ;
62+
63+ // WE CANNOT FORCE A HOVER STATE INSIDE CANVAS
64+ // SO THE "PARENT" IS NOT SET DESPITE COMPONENT B BEING INSIDE THE FRAME
65+ // HACK
66+ cy . url ( ) . then ( currentUrl => {
67+ const parts = currentUrl . split ( '/' ) ;
68+ parts . pop ( ) ; // c
69+ const changeset = parts . pop ( ) ;
70+ cy . request ( {
71+ method : 'POST' ,
72+ url : '/api/diagram/connect_component_to_frame' ,
73+ body : JSON . stringify ( {
74+ childId : componentIDB ,
75+ parentId : componentIDA ,
76+ visibility_change_set_pk : changeset ,
77+ workspaceId : SI_WORKSPACE_ID
78+ } ) ,
79+ headers : { Authorization : bearertoken , "Content-Type" : 'application/json' }
80+ } ) ;
81+ } ) ;
82+
83+ cy . wait ( 2000 ) ;
84+
3085 cy . url ( ) . then ( currentUrl => {
3186 // Construct a new URL with desired query parameters for selecting
3287 // the attribute panel for a known component
3388 let newUrl = new URL ( currentUrl ) ;
34- newUrl . searchParams . set ( 's' , import . meta . env . VITE_SI_PROPAGATION_COMPONENT_A ) ;
89+ newUrl . searchParams . set ( 's' , 'c_' + componentIDA ) ;
3590 newUrl . searchParams . set ( 't' , 'attributes' ) ;
3691
3792 // Visit the new URL
93+ console . log ( newUrl . href ) ;
3894 cy . visit ( newUrl . href ) ;
3995 } ) ;
4096
4197 // Give the page a few seconds to load
4298 cy . wait ( 2000 ) ;
4399
44- // Generate a random number between 1 and 100 to insert into the
45- // attribute value for Integer
46- const randomNumber = Math . floor ( Math . random ( ) * 100 ) + 1 ;
47-
48100 cy . intercept ( 'POST' , '/api/component/update_property_editor_value' ) . as ( 'updatePropertyEditorValue' ) ;
49101
50102 // Find the attribute for the Integer Input
51- cy . get ( '.attributes-panel-item__input-wrap input[type="number"]' )
52- . clear ( )
53- . type ( randomNumber . toString ( ) + '{enter}' ) // type the new value
103+ cy . get ( '.attributes-panel-item__input-wrap select:first' )
104+ . select ( 'us-east-1' ) ;
54105
55106 // Intercept the API call and alias it
56107 cy . wait ( '@updatePropertyEditorValue' , { timeout : 60000 } ) . its ( 'response.statusCode' ) . should ( 'eq' , 200 ) ;
@@ -59,17 +110,17 @@ Cypress._.times(import.meta.env.VITE_SI_CYPRESS_MULTIPLIER ? import.meta.env.VIT
59110 // Construct a new URL with desired query parameters for selecting
60111 // the attribute panel for a known connected component
61112 let newUrl = new URL ( currentUrl ) ;
62- newUrl . searchParams . set ( 's' , import . meta . env . VITE_SI_PROPAGATION_COMPONENT_B ) ;
113+ newUrl . searchParams . set ( 's' , 'c_' + componentIDB ) ;
63114 newUrl . searchParams . set ( 't' , 'attributes' ) ;
64115 cy . visit ( newUrl . href ) ;
65116 } ) ;
66117
67118 // Wait for the values to propagate
68- cy . wait ( 60000 ) ;
119+ cy . wait ( 1000 ) ;
69120
70- // Validate that the value has propogated through the system
71- cy . get ( '.attributes-panel-item__input-wrap input[type="number"]' , { timeout : 30000 } )
72- . should ( 'have.value' , randomNumber . toString ( ) , { timeout : 30000 } ) ;
121+ // Validate that the value has propagated through the system
122+ cy . get ( '.attributes-panel-item__input-wrap input.region' )
123+ . should ( 'have.value' , 'us-east-1' ) ;
73124
74125 // Click the button to destroy changeset
75126 cy . get ( 'nav.navbar button.vbutton.--variant-ghost.--size-sm.--tone-action' )
@@ -83,6 +134,6 @@ Cypress._.times(import.meta.env.VITE_SI_CYPRESS_MULTIPLIER ? import.meta.env.VIT
83134 cy . get ( 'button.vbutton.--variant-solid.--size-md.--tone-destructive' )
84135 . click ( ) ;
85136
86- } )
87- } )
88- } ) ;
137+ } ) ;
138+ } ) ;
139+ } ) ;
0 commit comments