From fdf325b01351dcc3de9489e3a048f6e8b1e4de4f Mon Sep 17 00:00:00 2001 From: YONGJAE LEE Date: Fri, 12 Jun 2026 22:29:34 +0900 Subject: [PATCH] test: fix always-passing e2e assertions and missing awaits - basic-auth: expect(locator).toBeTruthy() passes for any Locator object, so all three auth-failure tests verified nothing; converted to await expect(locator).toBeVisible(). The signup test asserted 'test@gmail.com' while signing up 'test2@gmail.com' - latent expected- value typo that the dead assertion never caught; corrected to the signed-up address. - custom-basepath + params: one-shot isVisible()/innerText()/page.url() reads converted to auto-retrying toBeVisible/toHaveText/toHaveURL (9 one-shot URL reads in params.spec.ts swept in the same pass) - solid transition: await six floating increase-button click() statements Same families exist in the solid/vue mirror suites; left untouched to keep this change reviewable. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../basic-file-based/tests/params.spec.ts | 18 +++++++++--------- e2e/react-start/basic-auth/tests/app.spec.ts | 6 +++--- .../custom-basepath/tests/navigation.spec.ts | 8 ++++---- .../basic-file-based/tests/transition.spec.ts | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/e2e/react-router/basic-file-based/tests/params.spec.ts b/e2e/react-router/basic-file-based/tests/params.spec.ts index a867696ff8..917523eecf 100644 --- a/e2e/react-router/basic-file-based/tests/params.spec.ts +++ b/e2e/react-router/basic-file-based/tests/params.spec.ts @@ -385,7 +385,7 @@ test.describe('Unicode params', () => { await fooLink.click() await page.waitForURL('/params-ps/named/foo%25%5C%2F%F0%9F%9A%80%EB%8C%80') - expect(page.url()).toBe( + await expect(page).toHaveURL( `${baseURL}/params-ps/named/foo%25%5C%2F%F0%9F%9A%80%EB%8C%80`, ) @@ -403,7 +403,7 @@ test.describe('Unicode params', () => { '/params-ps/named/foo%25%5C%2F%F0%9F%9A%80%EB%8C%80/%F0%9F%9A%80%252F%2Fabc%EB%8C%80', ) - expect(page.url()).toBe( + await expect(page).toHaveURL( `${baseURL}/params-ps/named/foo%25%5C%2F%F0%9F%9A%80%EB%8C%80/%F0%9F%9A%80%252F%2Fabc%EB%8C%80`, ) @@ -441,7 +441,7 @@ test.describe('Unicode params', () => { const headingRootEl = page.getByTestId('unicode-heading') - expect(await headingRootEl.innerText()).toBe('Hello "/대한민국"!') + await expect(headingRootEl).toHaveText('Hello "/대한민국"!') const latinLink = page.getByTestId(`l-to-${name}-latin`) const unicodeLink = page.getByTestId(`l-to-${name}-unicode`) @@ -453,7 +453,7 @@ test.describe('Unicode params', () => { await page.waitForURL(`${encodedChildRoutePath}/${latinParams}`) - expect(page.url()).toBe( + await expect(page).toHaveURL( `${baseURL}${encodedChildRoutePath}/${latinParams}`, ) @@ -463,10 +463,10 @@ test.describe('Unicode params', () => { const headingEl = page.getByTestId(`unicode-${name}-heading`) const paramsEl = page.getByTestId(`unicode-${name}-params`) - expect(await headingEl.innerText()).toBe( + await expect(headingEl).toHaveText( `Unicode ${pascalCaseName} Params`, ) - expect(await paramsEl.innerText()).toBe(latinParams) + await expect(paramsEl).toHaveText(latinParams) await unicodeLink.click() @@ -477,17 +477,17 @@ test.describe('Unicode params', () => { await page.waitForURL(`${encodedChildRoutePath}/${encodedParams}`) - expect(page.url()).toBe( + await expect(page).toHaveURL( `${baseURL}${encodedChildRoutePath}/${encodedParams}`, ) await expect(latinLink).not.toContainClass('font-bold') await expect(unicodeLink).toContainClass('font-bold') - expect(await headingEl.innerText()).toBe( + await expect(headingEl).toHaveText( `Unicode ${pascalCaseName} Params`, ) - expect(await paramsEl.innerText()).toBe(unicodeParams) + await expect(paramsEl).toHaveText(unicodeParams) }) }) }) diff --git a/e2e/react-start/basic-auth/tests/app.spec.ts b/e2e/react-start/basic-auth/tests/app.spec.ts index e96cb400b0..7d48fd24ab 100644 --- a/e2e/react-start/basic-auth/tests/app.spec.ts +++ b/e2e/react-start/basic-auth/tests/app.spec.ts @@ -38,17 +38,17 @@ test('Posts redirects to login when not authenticated', async ({ page }) => { test('Login fails with user not found', async ({ page }) => { await login(page, 'bad@gmail.com', 'badpassword') - expect(page.getByText('User not found')).toBeTruthy() + await expect(page.getByText('User not found')).toBeVisible() }) test('Login fails with incorrect password', async ({ page }) => { await signup(page, 'test@gmail.com', 'badpassword') - expect(page.getByText('Incorrect password')).toBeTruthy() + await expect(page.getByText('Incorrect password')).toBeVisible() }) test('Can sign up from a not found user', async ({ page }) => { await login(page, 'test2@gmail.com', 'badpassword', true) - expect(page.getByText('test@gmail.com')).toBeTruthy() + await expect(page.getByText('test2@gmail.com')).toBeVisible() }) test('Navigating to post after logging in', async ({ page }) => { diff --git a/e2e/react-start/custom-basepath/tests/navigation.spec.ts b/e2e/react-start/custom-basepath/tests/navigation.spec.ts index 49454e1b8e..69c6bedf30 100644 --- a/e2e/react-start/custom-basepath/tests/navigation.spec.ts +++ b/e2e/react-start/custom-basepath/tests/navigation.spec.ts @@ -49,16 +49,16 @@ test('client-side redirect', async ({ page, baseURL }) => { await page.getByTestId('link-to-throw-it').click() await page.waitForLoadState('networkidle') - expect(await page.getByTestId('post-view').isVisible()).toBe(true) - expect(page.url()).toBe(`${baseURL}/posts/1`) + await expect(page.getByTestId('post-view')).toBeVisible() + await expect(page).toHaveURL(`${baseURL}/posts/1`) }) test('server-side redirect', async ({ page, baseURL }) => { await page.goto('/redirect/throw-it') await page.waitForLoadState('networkidle') - expect(await page.getByTestId('post-view').isVisible()).toBe(true) - expect(page.url()).toBe(`${baseURL}/posts/1`) + await expect(page.getByTestId('post-view')).toBeVisible() + await expect(page).toHaveURL(`${baseURL}/posts/1`) // do not follow redirects since we want to test the Location header // first go to the route WITHOUT the base path, this will just add the base path diff --git a/e2e/solid-router/basic-file-based/tests/transition.spec.ts b/e2e/solid-router/basic-file-based/tests/transition.spec.ts index b777c52862..d8344e0700 100644 --- a/e2e/solid-router/basic-file-based/tests/transition.spec.ts +++ b/e2e/solid-router/basic-file-based/tests/transition.spec.ts @@ -20,7 +20,7 @@ test('transitions/count/create-resource should keep old values visible during na // 1 click - page.getByTestId('increase-button').click() + await page.getByTestId('increase-button').click() await expect(page.getByTestId('n-value')).toContainText('n: 1', { timeout: 2_000, @@ -40,8 +40,8 @@ test('transitions/count/create-resource should keep old values visible during na // 2 clicks - page.getByTestId('increase-button').click() - page.getByTestId('increase-button').click() + await page.getByTestId('increase-button').click() + await page.getByTestId('increase-button').click() await expect(page.getByTestId('n-value')).toContainText('n: 2', { timeout: 2000, @@ -61,9 +61,9 @@ test('transitions/count/create-resource should keep old values visible during na // 3 clicks - page.getByTestId('increase-button').click() - page.getByTestId('increase-button').click() - page.getByTestId('increase-button').click() + await page.getByTestId('increase-button').click() + await page.getByTestId('increase-button').click() + await page.getByTestId('increase-button').click() await expect(page.getByTestId('n-value')).toContainText('n: 4', { timeout: 2000,