diff --git a/playwright/app.spec.ts b/playwright/app.spec.ts index 4a7e164..ecba0a8 100644 --- a/playwright/app.spec.ts +++ b/playwright/app.spec.ts @@ -9,4 +9,9 @@ test('renders the application', async ({ page }) => { await expect(counter).toBeVisible() await counter.click() await expect(page.getByRole('button', { name: 'Count is 1' })).toBeVisible() + + const reset = page.getByRole('button', { name: 'Reset' }) + await expect(reset).toBeVisible() + await reset.click() + await expect(page.getByRole('button', { name: 'Count is 0' })).toBeVisible() }) diff --git a/src/App.tsx b/src/App.tsx index 9b281fd..7349639 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -42,6 +42,25 @@ function App() { > Count is {count} +
diff --git a/src/__tests__/e2e/app.e2e.spec.ts b/src/__tests__/e2e/app.e2e.spec.ts index e0df1a9..bb27e33 100644 --- a/src/__tests__/e2e/app.e2e.spec.ts +++ b/src/__tests__/e2e/app.e2e.spec.ts @@ -53,5 +53,17 @@ describe('App bootstrap', () => { { component: 'App' }, { nextCount: 1 }, ) + + await page.getByRole('button', { name: 'Reset' }).click() + + await expect + .element(page.getByRole('button', { name: 'Count is 0' })) + .toBeInTheDocument() + + expect(telemetryMocks.telemetry.trackEvent).toHaveBeenCalledWith( + 'reset_button_clicked', + { component: 'App' }, + { previousCount: 1 }, + ) }) })