Skip to content

Commit e823338

Browse files
test(e2e): stabilize PhotoBuilder session-resumption flow in CI
test(e2e): stabilize PhotoBuilder session-resumption flow in CI Fix flaky PhotoBuilder e2e behavior by making “Start Over” test targeting deterministic instead of DOM-order dependent. Assign distinct test IDs to overlay vs main Start Over controls, update Playwright assertions/clicks to use the visible main control, and ignore root-level test-results artifacts to prevent accidental git noise.
1 parent 04bab57 commit e823338

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
env:
1313
ETFS_PROJECT_NAME: ci
1414
APP_IMAGE: ghcr.io/${{ github.repository }}/app:ci
15+
CACHE_REF: ghcr.io/${{ github.repository }}/app:buildcache
1516

1617
jobs:
1718
build-app-image:
@@ -37,8 +38,12 @@ jobs:
3738
file: docker/app/Dockerfile
3839
push: true
3940
tags: ${{ env.APP_IMAGE }}
40-
cache-from: type=gha
41-
cache-to: type=gha,mode=max
41+
cache-from: |
42+
type=gha
43+
type=registry,ref=${{ env.CACHE_REF }}
44+
cache-to: |
45+
type=gha,mode=max
46+
type=registry,ref=${{ env.CACHE_REF }},mode=max
4247
4348
build-frontend:
4449
name: Frontend build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public/workspaces/*
5555
# E2E Playwright (tests/End2End)
5656
/tests/End2End/playwright-report/
5757
/tests/End2End/test-results/
58+
/test-results/
5859

5960
# Generated conversation log viewer files (in project root)
6061
/conversation-log-*.html

src/PhotoBuilder/Presentation/Controller/PhotoBuilderController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function show(
116116

117117
$effectiveProvider = $project->getEffectivePhotoBuilderLlmModelProvider();
118118

119-
return $this->render('@photo_builder.presentation/photo_builder.twig', [
119+
$response = $this->render('@photo_builder.presentation/photo_builder.twig', [
120120
'workspace' => $workspace,
121121
'project' => $project,
122122
'pagePath' => $pagePath,
@@ -129,6 +129,9 @@ public function show(
129129
'supportsResolutionToggle' => $effectiveProvider === LlmModelProvider::Google,
130130
'existingSessionId' => $existingSession?->getId(),
131131
]);
132+
$response->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate');
133+
134+
return $response;
132135
}
133136

134137
/**

src/PhotoBuilder/Presentation/Resources/templates/photo_builder.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</p>
8484
<button {{ stimulus_target('photo-builder', 'startOverButton') }}
8585
{{ stimulus_action('photo-builder', 'startOver') }}
86-
data-test-id="photo-builder-start-over-button"
86+
data-test-id="photo-builder-start-over-button-overlay"
8787
type="button"
8888
class="hidden etfswui-button-secondary text-sm">
8989
{{ 'photo_builder.start_over'|trans }}
@@ -182,7 +182,7 @@ For each image, call the deliver_image_prompt tool with:
182182
</button>
183183
<button {{ stimulus_target('photo-builder', 'startOverButton') }}
184184
{{ stimulus_action('photo-builder', 'startOver') }}
185-
data-test-id="photo-builder-start-over-button"
185+
data-test-id="photo-builder-start-over-button-main"
186186
type="button"
187187
class="hidden etfswui-button-secondary gap-2">
188188
{{ 'photo_builder.start_over'|trans }}

tests/End2End/tests/photo-builder.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,20 @@ test.describe("photo builder session resumption", () => {
5252
// 6. Navigate away
5353
await page.goto("/en/projects");
5454

55-
// 7. Navigate back to the same photo builder URL
56-
await page.goto(photoBuilderUrl!);
55+
// 7. Navigate back to the same photo builder URL (cache-bust so we get fresh HTML with existingSessionId)
56+
const revisitUrl = photoBuilderUrl! + (photoBuilderUrl!.includes("?") ? "&" : "?") + "_=" + Date.now();
57+
await page.goto(revisitUrl);
5758

5859
// 8. "Start Over" buttons are visible (session was resumed)
5960
await expect(page.getByTestId("photo-builder-page")).toBeVisible();
60-
await expect(page.locator('[data-test-id="photo-builder-start-over-button"]').first()).toBeVisible({
61+
await expect(page.getByTestId("photo-builder-start-over-button-main")).toBeVisible({
6162
timeout: 10_000,
6263
});
6364

6465
// 9. Click "Start Over" → loading overlay shown, Start Over buttons hidden
65-
await page.locator('[data-test-id="photo-builder-start-over-button"]').first().click();
66+
await page.getByTestId("photo-builder-start-over-button-main").click();
6667
await expect(page.getByTestId("photo-builder-loading-overlay")).toBeVisible();
67-
await expect(page.locator('[data-test-id="photo-builder-start-over-button"]').first()).toBeHidden();
68+
await expect(page.getByTestId("photo-builder-start-over-button-main")).toBeHidden();
69+
await expect(page.getByTestId("photo-builder-start-over-button-overlay")).toBeHidden();
6870
});
6971
});

0 commit comments

Comments
 (0)