Skip to content

Commit 7b94794

Browse files
committed
Add integration test assertions for stepCompleted with next field
Add didFireStepCompleted helper to the base OnboardingPage test page object and verify in both v3 and v4 full-flow tests that each step transition fires stepCompleted with the correct id and next fields. https://claude.ai/code/session_01JnUmv2xkXxdF12a3EDyVXR
1 parent 3a913cf commit 7b94794

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

special-pages/pages/onboarding/integration-tests/onboarding.page.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,24 @@ export class OnboardingPage {
294294
]);
295295
}
296296

297+
/**
298+
* Asserts that stepCompleted notifications were fired with the expected id and next fields.
299+
* @param {{ id: string, next: string | null }[]} expectedSteps
300+
*/
301+
async didFireStepCompleted(expectedSteps) {
302+
const calls = await this.mocks.outgoing({ names: ['stepCompleted'] });
303+
expect(calls).toMatchObject(
304+
expectedSteps.map(({ id, next }) => ({
305+
payload: {
306+
context: 'specialPages',
307+
featureName: 'onboarding',
308+
method: 'stepCompleted',
309+
params: { id, next },
310+
},
311+
})),
312+
);
313+
}
314+
297315
async keepInTaskbar() {
298316
const { page } = this;
299317
const locator = this.build.switch({

special-pages/pages/onboarding/integration-tests/onboarding.v3.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ test.describe('onboarding v3', () => {
206206
await page.getByRole('button', { name: 'Search & Duck.ai' }).click();
207207
await page.getByRole('button', { name: 'Search Only' }).click();
208208
await onboarding.startBrowsing();
209+
210+
// Verify stepCompleted was fired for each step with the correct next field
211+
await onboarding.didFireStepCompleted([
212+
{ id: 'welcome', next: 'getStarted' },
213+
{ id: 'getStarted', next: 'makeDefaultSingle' },
214+
{ id: 'makeDefaultSingle', next: 'systemSettings' },
215+
{ id: 'systemSettings', next: 'duckPlayerSingle' },
216+
{ id: 'duckPlayerSingle', next: 'customize' },
217+
{ id: 'customize', next: 'addressBarMode' },
218+
{ id: 'addressBarMode', next: null },
219+
]);
209220
});
210221

211222
test('shows v3 flow without system settings step', async ({ page }, workerInfo) => {

special-pages/pages/onboarding/integration-tests/onboarding.v4.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ test.describe('onboarding v4', () => {
204204
await page.getByRole('button', { name: 'Search & Duck.ai' }).click();
205205
await page.getByRole('button', { name: 'Search Only' }).click();
206206
await onboarding.startBrowsing();
207+
208+
// Verify stepCompleted was fired for each step with the correct next field
209+
await onboarding.didFireStepCompleted([
210+
{ id: 'welcome', next: 'getStarted' },
211+
{ id: 'getStarted', next: 'makeDefaultSingle' },
212+
{ id: 'makeDefaultSingle', next: 'systemSettings' },
213+
{ id: 'systemSettings', next: 'duckPlayerSingle' },
214+
{ id: 'duckPlayerSingle', next: 'customize' },
215+
{ id: 'customize', next: 'addressBarMode' },
216+
{ id: 'addressBarMode', next: null },
217+
]);
207218
});
208219

209220
test.describe('Given I am on the settings step with dock-instructions variant', () => {

0 commit comments

Comments
 (0)