Skip to content

🔧 Fix invalid email error message#2269

Closed
you-kimono wants to merge 1 commit into
fastapi:masterfrom
you-kimono:misc/fix-invalid-email-error-message
Closed

🔧 Fix invalid email error message#2269
you-kimono wants to merge 1 commit into
fastapi:masterfrom
you-kimono:misc/fix-invalid-email-error-message

Conversation

@you-kimono
Copy link
Copy Markdown

Hey!
I propose this change because it sets the correct message expected by playwright tests.
Prior to this change, the playwright tests checking user logging in or signing up with an incorrect email failed.

Fix the error message shown in Login and Signup forms when the user
inserts an invalid email address.
With this fix, all frontend tests pass.
@YuriiMotov
Copy link
Copy Markdown
Member

Prior to this change, the playwright tests checking user logging in or signing up with an incorrect email failed.

But tests on master currently pass.
Did you really see those tests failed or was it just your assumption?

@you-kimono
Copy link
Copy Markdown
Author

I did see it and I still see it under certain conditions.
Please bear in mind that my approach to these tests may be flawed.

In the following a describe 2 approaches that give me different results.
The first one generates the errors that are addressed by this PR.
The second one generates a different set of errors.

Given this inconsistency (and the fact that you see tests on master currently passing) I wonder what I'm doing wrong and if there may be some hidden discrepancy with local development.

APPROACH 1:
On a newly cloned repository (commit ID: 33fa827), I open two terminals.
Terminal 1: run docker compose watch
Terminal 2: run cd frontend and bunx playwright test

This is the failing output that I get:

[dotenv@17.3.1] injecting env (24) from ../.env -- tip: 🛡️ auth for agents: https://vestauth.com

Running 62 tests using 4 workers
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🤖 agentic secret storage: https://dotenvx.com/as2
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  override existing env vars with { override: true }
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🔐 prevent building .env in docker: https://dotenvx.com/prebuild
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🔐 prevent building .env in docker: https://dotenvx.com/prebuild
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  load multiple .env files with { path: ['.env.local', '.env'] }
  1) [chromium] › tests/login.spec.ts:53:1 › Log in with invalid email ─────────────────────────────

    Error: expect(locator).toBeVisible() failed

    Locator: getByText('Invalid email address')
    Expected: visible
    Timeout: 5000ms
    Error: element(s) not found

    Call log:
      - Expect "toBeVisible" with timeout 5000ms
      - waiting for getByText('Invalid email address')


      57 |   await page.getByRole("button", { name: "Log In" }).click()
      58 |
    > 59 |   await expect(page.getByText("Invalid email address")).toBeVisible()
         |                                                         ^
      60 | })
      61 |
      62 | test("Log in with invalid password", async ({ page }) => {
        at full-stack-fastapi-template/frontend/tests/login.spec.ts:59:57

    Error Context: test-results/login-Log-in-with-invalid-email-chromium/error-context.md

[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🛡️ auth for agents: https://vestauth.com
  2) [chromium] › tests/sign-up.spec.ts:58:1 › Sign up with invalid email ──────────────────────────

    Error: expect(locator).toBeVisible() failed

    Locator: getByText('Invalid email address')
    Expected: visible
    Timeout: 5000ms
    Error: element(s) not found

    Call log:
      - Expect "toBeVisible" with timeout 5000ms
      - waiting for getByText('Invalid email address')


      68 |   await page.getByRole("button", { name: "Sign Up" }).click()
      69 |
    > 70 |   await expect(page.getByText("Invalid email address")).toBeVisible()
         |                                                         ^
      71 | })
      72 |
      73 | test("Sign up with existing email", async ({ page }) => {
        at full-stack-fastapi-template/frontend/tests/sign-up.spec.ts:70:57

    Error Context: test-results/sign-up-Sign-up-with-invalid-email-chromium/error-context.md

[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  load multiple .env files with { path: ['.env.local', '.env'] }
  3) [chromium] › tests/sign-up.spec.ts:135:1 › Sign up with missing email ─────────────────────────

    Error: expect(locator).toBeVisible() failed

    Locator: getByText('Invalid email address')
    Expected: visible
    Timeout: 5000ms
    Error: element(s) not found

    Call log:
      - Expect "toBeVisible" with timeout 5000ms
      - waiting for getByText('Invalid email address')


      143 |   await page.getByRole("button", { name: "Sign Up" }).click()
      144 |
    > 145 |   await expect(page.getByText("Invalid email address")).toBeVisible()
          |                                                         ^
      146 | })
      147 |
      148 | test("Sign up with missing password", async ({ page }) => {
        at full-stack-fastapi-template/frontend/tests/sign-up.spec.ts:145:57

    Error Context: test-results/sign-up-Sign-up-with-missing-email-chromium/error-context.md

[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  specify custom .env file path with { path: '/custom/path/.env' }
  3 failed
    [chromium] › tests/login.spec.ts:53:1 › Log in with invalid email ──────────────────────────────
    [chromium] › tests/sign-up.spec.ts:58:1 › Sign up with invalid email ───────────────────────────
    [chromium] › tests/sign-up.spec.ts:135:1 › Sign up with missing email ──────────────────────────
  59 passed (29.1s)

APPROACH 2:
On a newly cloned repository (commit ID: 33fa827), I open two terminals.
Terminal 1: run docker compose up -d --wait backend
Terminal 2: run cd frontend and bunx playwright test

This is the failing output that I get:

dotenv@17.3.1] injecting env (24) from ../.env -- tip: ⚡️ secrets for agents: https://dotenvx.com/as2

Running 62 tests using 4 workers
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🔐 prevent committing .env to code: https://dotenvx.com/precommit
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  load multiple .env files with { path: ['.env.local', '.env'] }
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🔐 encrypt with Dotenvx: https://dotenvx.com
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  suppress all logs with { quiet: true }
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🔐 prevent building .env in docker: https://dotenvx.com/prebuild
  1) [chromium] › tests/reset-password.spec.ts:30:1 › User can reset password successfully using the link 

    Error: apiRequestContext.get: connect ECONNREFUSED ::1:1080
    Call log:
      - → GET http://localhost:1080/messages
        - user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.7632.6 Safari/537.36
        - accept: */*
        - accept-encoding: gzip,deflate,br

        at apiRequestContext.get: connect ECONNREFUSED ::1:1080
        at findEmail (full-stack-fastapi-template/frontend/tests/utils/mailcatcher.ts:16:34)
        at checkEmails (full-stack-fastapi-template/frontend/tests/utils/mailcatcher.ts:51:31)
        at findLastEmail (full-stack-fastapi-template/frontend/tests/utils/mailcatcher.ts:61:40)
        at full-stack-fastapi-template/frontend/tests/reset-password.spec.ts:47:27

    Error Context: test-results/reset-password-User-can-re-55787-successfully-using-the-link-chromium/error-context.md

  2) [chromium] › tests/reset-password.spec.ts:89:1 › Weak new password validation ─────────────────

    Error: apiRequestContext.get: connect ECONNREFUSED ::1:1080
    Call log:
      - → GET http://localhost:1080/messages
        - user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.7632.6 Safari/537.36
        - accept: */*
        - accept-encoding: gzip,deflate,br

        at apiRequestContext.get: connect ECONNREFUSED ::1:1080
        at findEmail (full-stack-fastapi-template/frontend/tests/utils/mailcatcher.ts:16:34)
        at checkEmails (full-stack-fastapi-template/frontend/tests/utils/mailcatcher.ts:51:31)
        at findLastEmail (full-stack-fastapi-template/frontend/tests/utils/mailcatcher.ts:61:40)
        at full-stack-fastapi-template/frontend/tests/reset-password.spec.ts:102:27

    Error Context: test-results/reset-password-Weak-new-password-validation-chromium/error-context.md

[dotenv@17.3.1] injecting env (0) from ../.env -- tip: ⚙️  write to custom object with { processEnv: myObject }
[dotenv@17.3.1] injecting env (0) from ../.env -- tip: 🤖 agentic secret storage: https://dotenvx.com/as2
  2 failed
    [chromium] › tests/reset-password.spec.ts:30:1 › User can reset password successfully using the link 
    [chromium] › tests/reset-password.spec.ts:89:1 › Weak new password validation ──────────────────
  60 passed (54.3s)

@github-actions github-actions Bot removed the waiting label May 23, 2026
@tiangolo
Copy link
Copy Markdown
Member

This seems to be passing without the change, so I'll pass on this. Thanks! ☕

@tiangolo tiangolo closed this May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants