@@ -2,16 +2,29 @@ import { test, expect } from '@playwright/test';
22import { execSync } from 'node:child_process' ;
33
44test ( 'Log into Argo CD as local admin' , async ( { browser } ) => {
5- const rawOutput = execSync (
6- 'oc extract secret/openshift-gitops-cluster -n openshift-gitops --keys=admin.password --to=-'
7- ) . toString ( ) ;
5+ let rawOutput : string ;
6+ let routeUrl : string ;
7+
8+ try {
9+ rawOutput = execSync (
10+ 'oc extract secret/openshift-gitops-cluster -n openshift-gitops --keys=admin.password --to=-' ,
11+ { timeout : 15000 , stdio : 'pipe' }
12+ ) . toString ( ) ;
13+ } catch ( error ) {
14+ throw new Error ( "Failed to extract admin password. Please check your cluster connection and oc CLI." ) ;
15+ }
816
917 //get credentials
1018 const password = rawOutput . split ( '\n' ) . map ( l => l . trim ( ) ) . filter ( l => l && ! l . startsWith ( '#' ) ) [ 0 ] ;
1119
12- const routeUrl = execSync (
13- 'oc get route openshift-gitops-server -n openshift-gitops -o jsonpath="{.spec.host}"'
14- ) . toString ( ) . trim ( ) ;
20+ try {
21+ routeUrl = execSync (
22+ 'oc get route openshift-gitops-server -n openshift-gitops -o jsonpath="{.spec.host}"' ,
23+ { timeout : 15000 , stdio : 'pipe' }
24+ ) . toString ( ) . trim ( ) ;
25+ } catch ( error ) {
26+ throw new Error ( "Failed to fetch Argo CD route. Please check your cluster connection and oc CLI." ) ;
27+ }
1528
1629 //Fresh context to avoid any cached state issues
1730 const context = await browser . newContext ( {
@@ -24,7 +37,7 @@ test('Log into Argo CD as local admin', async ({ browser }) => {
2437 const loginUrl = `https://${ routeUrl } /login?dex=none` ;
2538 await page . goto ( loginUrl , { waitUntil : 'load' } ) ;
2639
27- const userField = page . getByRole ( 'textbox' ) . first ( ) ;
40+ const userField = page . getByLabel ( / u s e r n a m e / i ) ;
2841 await userField . waitFor ( { state : 'visible' , timeout : 20000 } ) ;
2942
3043 //Fill and Sign In
0 commit comments