Skip to content

Commit 3dc29b7

Browse files
author
Triona Doyle
committed
address Coderabbit PR review feedback
Signed-off-by: Triona Doyle <tekton@example.com>
1 parent 4c635a0 commit 3dc29b7

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

test/ui-e2e/.auth/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ setup('authenticate to OpenShift Cluster', async ({ page, baseURL }) => {
5656
await page.getByRole('button', { name: /Log in/i }).click();
5757

5858
// Save the auth state
59-
await page.waitForLoadState('networkidle');
59+
await expect(page.getByRole('navigation').first()).toBeVisible({ timeout: 15000 });
6060
await page.context().storageState({ path: authFile });
61+
6162
});

test/ui-e2e/src/fixtures.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ export const test = base.extend<MyFixtures>({
1313
page: async ({ page }, use) => {
1414
const loginPage = new LoginPage(page);
1515
await loginPage.goto();
16-
await loginPage.loginViaOpenShift();
16+
17+
// 1. Grab variables from the environment
18+
const user = process.env.CLUSTER_USER || 'kubeadmin';
19+
const pass = process.env.CLUSTER_PASSWORD;
20+
const idp = process.env.IDP || 'kube:admin';
21+
22+
// 2. Fail loudly if the password is missing
23+
if (!pass) {
24+
throw new Error('CLUSTER_PASSWORD environment variable is missing. Cannot authenticate.');
25+
}
26+
27+
// 3. Pass them into the login method
28+
await loginPage.loginViaOpenShift(user, pass, idp);
29+
1730
await use(page);
1831
},
1932

@@ -41,9 +54,9 @@ export const test = base.extend<MyFixtures>({
4154
headers: { 'Content-Type': 'application/json' }
4255
});
4356

44-
//ignore if missing or rbac locked
45-
if (response.status() === 404 || response.status() === 403) {
46-
if (response.status() === 403) console.log('warning: delete forbidden (RBAC) on this cluster; skipping cleanup');
57+
// 4. Update the teardown to only ignore 404s, treating 403s as failures
58+
if (response.status() === 404) {
59+
return;
4760
} else {
4861
expect(response.status()).toBeLessThan(400);
4962
}

test/ui-e2e/src/pages/ApplicationsPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class ApplicationsPage {
7676
await this.createButton.click();
7777
}
7878

79-
async syncApplication(appName: string) {
79+
async syncApplication(appName: string, expectedResource: string = 'spring-petclinic') {
8080
//search for app
8181
await this.page.getByPlaceholder(/Search applications/i).fill(appName);
8282

@@ -86,7 +86,7 @@ export class ApplicationsPage {
8686

8787
//slideout panel
8888
const resourcesSection = this.page.locator('.argo-form-row').filter({ hasText: 'SYNCHRONIZE RESOURCES' });
89-
await expect(resourcesSection).toContainText('spring-petclinic', { timeout: 15000 });
89+
await expect(resourcesSection).toContainText(expectedResource, { timeout: 15000 });
9090

9191
const validationWarning = resourcesSection.getByText('Select at least one resource');
9292

test/ui-e2e/src/pages/LoginPage.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export class LoginPage {
3737
}
3838

3939
//check if manual login is actually required
40-
const usernameInput = this.page.getByLabel(/Username/i);
40+
const usernameInput = this.page.getByLabel(/Username/i)
41+
.or(this.page.locator('input[name="username"]'))
42+
.or(this.page.getByPlaceholder(/Username/i));
43+
4144
const needsLogin = await usernameInput.waitFor({ state: 'visible', timeout: 5000 }).then(() => true).catch(() => false);
4245

4346
if (needsLogin && user && pass) {

0 commit comments

Comments
 (0)