Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sign up with existing email spec not working (and potential fix) #1400

Unanswered
pavgup asked this question in Questions
Discussion options

First Check

  • I added a very descriptive title here.
  • I used the GitHub search to find a similar question and didn't find it.
  • I searched in the documentation/README.
  • I already searched in Google "How to do X" and didn't find any information.
  • I already read and followed all the tutorial in the docs/README and didn't find an answer.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

The current spec has this code:
test("Sign up with existing email", async ({ page }) => {
 const fullName = "Test User"
 const email = randomEmail()
 const password = randomPassword()
 // Sign up with an email
 await page.goto("/signup")
 await fillForm(page, fullName, email, password, password)
 await page.getByRole("button", { name: "Sign Up" }).click()
 // Sign up again with the same email
 await page.goto("/signup")
 await fillForm(page, fullName, email, password, password)
 await page.getByRole("button", { name: "Sign Up" }).click()
 await page
 .getByText("The user with this email already exists in the system")
 .click()
})

Description

When the spec to test signing up with the same email address, the spec fails with an interesting problem:

  1. The backend produces a 500 error because the database is unable to insert the ix_user_email that is not unique. It means the backend, when it searched for the users to detect a duplicate, was not able to find this user somehow.
  2. This causes the spec to fail with a CORS error. This is super confusing, but after doing enough research, it's clear that 500 errors from fastapi result in CORS errors because they don't take the cors middleware configurations from the app.
  3. And as I played with this, it became clear that the spec might just be moving too quickly for the backend to process --

So, a potential fix might look like this:

test("Sign up with existing email", async ({ page }) => {
 const fullName = "Test User"
 const email = randomEmail()
 const password = randomPassword()
 // Sign up with an email
 await page.goto("/signup")
 await fillForm(page, fullName, email, password, password)
 await page.getByRole("button", { name: "Sign Up" }).click()
 await page
 .getByText("Your account has been created successfully")
 .click()
 
 // Sign up again with the same email
 await page.goto("/signup")
 await fillForm(page, fullName, email, password, password)
 await page.getByRole("button", { name: "Sign Up" }).click()
 await page
 .getByText("The user with this email already exists in the system")
 .click()
})```
### Operating System
macOS
### Operating System Details
M2 pro, sequoia 15.0.1
### Python Version
Python 3.11.10
### Additional Context
_No response_
You must be logged in to vote

Replies: 1 comment

Comment options

Can't reproduce this problem.
Do you mean this happens sometimes, not every time?
I ran tests 3 times and did not get any 500 errors

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested

AltStyle によって変換されたページ (->オリジナル) /