Skip to content

Commit eacf342

Browse files
committed
Add 404 detection and retry for page entity endpoint after Open app click
After clicking "Open app" in the catalog, the /api2/ui-extensions/entities/pages/v1 endpoint sometimes returns 404 because the service hasn't registered the page yet. This adds a response listener that detects the 404 and retries with page reload up to 3 times, which resolves the intermittent navigation failures in CI.
1 parent 538333b commit eacf342

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

e2e/src/pages/CategoryBlockingPage.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,22 @@ export class CategoryBlockingPage extends BasePage {
156156

157157
const openAppButton = this.page.getByRole('button', { name: 'Open app' });
158158
await openAppButton.waitFor({ state: 'visible', timeout: 10000 });
159+
160+
// Set up response listener BEFORE clicking to capture the page entity response
161+
const pageEntityResponse = this.page.waitForResponse(
162+
(resp) => resp.url().includes('/api2/ui-extensions/entities/pages/v1'),
163+
{ timeout: 15000 }
164+
);
159165
await openAppButton.click();
160166
this.logger.success('Clicked "Open app" button from App Catalog');
161167

168+
// Wait for the page entity response and check for 404
169+
const response = await pageEntityResponse;
170+
if (response.status() === 404) {
171+
this.logger.warn('Page entity returned 404, retrying with reload...');
172+
await this.retryPageLoadAfter404();
173+
}
174+
162175
const iframe = this.page.locator('iframe');
163176
await iframe.waitFor({ state: 'visible', timeout: 30000 });
164177
await this.verifyPageLoaded();
@@ -169,6 +182,28 @@ export class CategoryBlockingPage extends BasePage {
169182
}
170183
}
171184

185+
/**
186+
* Retry page load after a 404 on the page entity endpoint.
187+
* The service sometimes needs a moment to register newly deployed pages.
188+
*/
189+
private async retryPageLoadAfter404(maxRetries = 3): Promise<void> {
190+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
191+
const retryResponse = this.page.waitForResponse(
192+
(resp) => resp.url().includes('/api2/ui-extensions/entities/pages/v1'),
193+
{ timeout: 15000 }
194+
);
195+
await this.page.reload();
196+
await this.page.waitForLoadState('domcontentloaded');
197+
198+
const response = await retryResponse;
199+
if (response.status() !== 404) {
200+
this.logger.success(`Page entity returned ${response.status()} on retry ${attempt}`);
201+
return;
202+
}
203+
this.logger.warn(`Page entity still 404 on retry ${attempt}/${maxRetries}`);
204+
}
205+
}
206+
172207
/**
173208
* Clean up any open modals (used in test cleanup)
174209
*/

0 commit comments

Comments
 (0)