Skip to content

Commit 62c6c9d

Browse files
author
Triona Doyle
committed
add Argocd version check and harden app health locators
Signed-off-by: Triona Doyle <tekton@example.com>
1 parent 17319d0 commit 62c6c9d

5 files changed

Lines changed: 54 additions & 7 deletions

File tree

test/ui-e2e/run-ui-tests.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ rm -f .auth/storageState.json || true
6666
#run Playwright
6767
echo " Starting Playwright tests..."
6868

69+
echo " "
70+
#get the installed gitops version
71+
GITOPS_VERSION=$(oc get csv -n openshift-gitops -o jsonpath='{.items[?(@.spec.displayName=="Red Hat OpenShift GitOps")].spec.version}' 2>/dev/null)
72+
if [ -z "$GITOPS_VERSION" ]; then
73+
GITOPS_VERSION="Unknown"
74+
fi
75+
76+
#get Argo CD version
77+
ARGO_API_VERSION=$(curl -s -k "$ARGOCD_URL/api/version" | grep -o '"Version":"[^"]*"' | cut -d'"' -f4)
78+
if [ -z "$ARGO_API_VERSION" ]; then
79+
ARGO_API_VERSION="Unknown"
80+
fi
81+
82+
echo " TARGETING GITOPS VERSION: v$GITOPS_VERSION"
83+
echo " TARGETING ARGO CD VERSION: $ARGO_API_VERSION"
84+
echo " "
85+
6986
# 2. Execute based on the environment
7087
if [ "$ENV" = "ci" ] || [ "$ENV" = "pipeline" ]; then
7188
echo "Running headlessly in automation ($ENV)..."

test/ui-e2e/src/fixtures.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ApplicationsPage } from './pages/ApplicationsPage';
55
//define custom fixture types
66
type MyFixtures = {
77
managedApp: string;
8+
argoVersion: string;
89
};
910

1011
export const test = base.extend<MyFixtures>({
@@ -30,6 +31,33 @@ export const test = base.extend<MyFixtures>({
3031
await use(page);
3132
},
3233

34+
//get target argocd version
35+
argoVersion: async ({ page }, use) => {
36+
try {
37+
//get version
38+
const response = await page.request.get('/api/version');
39+
40+
if (!response.ok()) {
41+
throw new Error(`API returned status: ${response.status()}`);
42+
}
43+
44+
const data = await response.json();
45+
const fullVersion = data.Version || 'Unknown';
46+
47+
//extract the major.minor version (e.g., "v2.10.1" -> "2.10")
48+
const match = fullVersion.match(/v(\d+\.\d+)/);
49+
const version = match ? match[1] : '3.0';
50+
51+
//for debugging/CI logs
52+
console.log(`TARGETING ARGO CD VERSION: ${fullVersion}`);
53+
54+
await use(version);
55+
} catch (error) {
56+
console.warn(`\n[warn] Failed to fetch Argo CD version from API. Defaulting to 3.0. Reason: ${error instanceof Error ? error.message : 'Unknown'}\n`);
57+
await use('3.0'); // Default to 3.0
58+
}
59+
},
60+
3361
managedApp: [ async ({ page }, use) => {
3462
const appName = `e2e-app-${Date.now()}`;
3563
const appsPage = new ApplicationsPage(page);

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ export class ApplicationDetailsPage {
2222
async verifyResourceTreeLoaded() {
2323
//wait tree to be visible
2424
await expect(this.resourceTreeContainer).toBeVisible({ timeout: 20000 });
25-
//wait for healthy status
26-
await expect(this.resourceTreeContainer.getByText('Healthy', { exact: true }).first()).toBeVisible({ timeout: 30000 });
27-
25+
26+
const appHealthBlock = this.page.locator('div')
27+
.filter({ has: this.page.getByText('APP HEALTH', { exact: true }) })
28+
.filter({ hasText: /Healthy/i })
29+
.last();
30+
31+
await expect(appHealthBlock).toBeVisible({ timeout: 30000 });
2832
}
2933

3034
async clickResourceNode(kind: string, name: string) {

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class ApplicationsPage {
131131

132132
const slideOutPanel = this.page.locator('.sliding-panel').filter({ visible: true });
133133

134-
// 🚀 SWAPPED: this.page is now slideOutPanel
134+
//slideOutPanel
135135
const allLink = slideOutPanel.getByRole('link', { name: 'all', exact: true });
136136
try {
137137
await allLink.waitFor({ state: 'visible', timeout: TIMEOUTS.modal });
@@ -145,10 +145,8 @@ export class ApplicationsPage {
145145
}
146146
}
147147

148-
// 🚀 SWAPPED: this.page is now slideOutPanel
149148
await expect(slideOutPanel.getByText(expectedResource).first()).toBeVisible({ timeout: TIMEOUTS.render });
150149

151-
// 🚀 SWAPPED: this.page is now slideOutPanel
152150
await slideOutPanel.getByRole('button', { name: /^synchronize$/i }).first().click();
153151

154152
//wait for the panel to close

test/ui-e2e/tests/resource-tree.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test.describe('Argo CD Resource Tree and Pod Logs', () => {
66

77
test.use({ storageState: '.auth/storageState.json' });
88

9-
test('Navigate to app details, open a Pod, and verify logs stream', async ({ page, managedApp }) => {
9+
test('Navigate to app details, open a Pod, and verify logs stream', async ({ page, managedApp, argoVersion }) => {
1010
test.setTimeout(120000);
1111

1212
const appsPage = new ApplicationsPage(page);

0 commit comments

Comments
 (0)