Skip to content

Commit 13caa52

Browse files
committed
fix: Search for app by name instead of using hardcoded app ID
1 parent 3650a55 commit 13caa52

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

e2e/src/pages/AppCatalogPage.ts

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,55 @@ export class AppCatalogPage extends BasePage {
2525
this.logger.success('App Catalog page loaded successfully');
2626
}
2727

28+
/**
29+
* Search for app in catalog and navigate to its page
30+
*/
31+
private async searchAndNavigateToApp(appName: string): Promise<void> {
32+
this.logger.info(`Searching for app '${appName}' in catalog`);
33+
34+
await this.navigateToPath('/foundry/app-catalog', 'App catalog page');
35+
36+
const searchBox = this.page.getByRole('searchbox', { name: 'Search' });
37+
await searchBox.fill(appName);
38+
await this.page.keyboard.press('Enter');
39+
await this.page.waitForLoadState('networkidle');
40+
41+
const appLink = this.page.getByRole('link', { name: appName, exact: true });
42+
43+
try {
44+
await this.waiter.waitForVisible(appLink, {
45+
description: `App '${appName}' link in catalog`,
46+
timeout: 10000
47+
});
48+
this.logger.success(`Found app '${appName}' in catalog`);
49+
await this.smartClick(appLink, `App '${appName}' link`);
50+
await this.page.waitForLoadState('networkidle');
51+
} catch (error) {
52+
throw new Error(`Could not find app '${appName}' in catalog. Make sure the app is deployed.`);
53+
}
54+
}
55+
2856
/**
2957
* Check if app is installed
3058
*/
3159
async isAppInstalled(appName: string): Promise<boolean> {
3260
this.logger.step(`Check if app '${appName}' is installed`);
3361

34-
// Navigate to the app's specific catalog page first
35-
const appUrl = `/foundry/app-catalog/${this.appId}`;
36-
await this.navigateToPath(appUrl, `App catalog page for ${appName}`);
37-
await this.page.waitForLoadState('networkidle');
62+
// Search for and navigate to the app's catalog page
63+
await this.searchAndNavigateToApp(appName);
3864

3965
// Check for installation indicators on the app's page
4066
const installedText = this.page.locator('text=Installed').first();
41-
const openButton = this.page.getByRole('button', { name: /open|launch/i });
42-
const installButton = this.page.getByRole('button', { name: 'Install' });
67+
const notInstalledText = this.page.locator('text=Not installed').first();
68+
const installLink = this.page.getByRole('link', { name: 'Install now' });
4369

4470
const hasInstalledText = await this.elementExists(installedText, 2000);
45-
const hasOpenButton = await this.elementExists(openButton, 2000);
46-
const hasInstallButton = await this.elementExists(installButton, 2000);
71+
const hasNotInstalledText = await this.elementExists(notInstalledText, 2000);
72+
const hasInstallLink = await this.elementExists(installLink, 2000);
4773

48-
// If Install button exists, app is NOT installed
49-
// If Installed text or Open button exists, app IS installed
50-
const isInstalled = (hasInstalledText || hasOpenButton) && !hasInstallButton;
74+
// If "Not installed" text or "Install now" link exists, app is NOT installed
75+
// If "Installed" text exists and no install indicators, app IS installed
76+
const isInstalled = hasInstalledText && !hasNotInstalledText && !hasInstallLink;
5177
this.logger.info(`App '${appName}' installation status: ${isInstalled ? 'Installed' : 'Not installed'}`);
5278

5379
return isInstalled;

0 commit comments

Comments
 (0)