Signup with token test

pull/11421/merge^2
Sean Brydon 2023-09-19 15:42:00 +01:00
parent 35e4cc122e
commit 6f27fa8063
2 changed files with 67 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { expect } from "@playwright/test";
import { randomBytes } from "crypto";
import { IS_CALCOM } from "@calcom/lib/constants";
@ -125,4 +126,69 @@ test.describe("Signup Flow Test", async () => {
// Check that the URL matches the expected URL
expect(page.url()).toContain("/auth/verify-email");
});
test("Signup with token prefils correct fields", async ({ page, users, prisma }) => {
//Create a user and create a token
const token = randomBytes(32).toString("hex");
// @shivram we can probably create a fixture for this logic.
const createdtoken = await prisma.verificationToken.create({
data: {
identifier: "rick-team@example.com",
token,
expires: new Date(new Date().setHours(168)), // +1 week
team: {
create: {
name: "Rick's Team",
slug: "ricks-team",
},
},
},
});
// create a user with the same email as the token
const rickTeamUser = await prisma.user.create({
data: {
email: "rick-team@example.com",
username: "rick-team",
},
});
// Create provitional membership
await prisma.membership.create({
data: {
teamId: createdtoken.teamId ?? -1,
userId: rickTeamUser.id,
role: "ADMIN",
accepted: false,
},
});
const signupUrlWithToken = `/signup?token=${token}`;
await page.goto(signupUrlWithToken);
const usernameField = page.locator('input[name="username"]');
const emailField = page.locator('input[name="email"]');
expect(await usernameField.inputValue()).toBe("rick-team");
expect(await emailField.inputValue()).toBe("rick-team@example.com");
// Clean up the user and token
await prisma.user.delete({
where: {
id: rickTeamUser.id,
},
});
await prisma.verificationToken.delete({
where: {
id: createdtoken.id,
},
});
await prisma.team.delete({
where: {
id: createdtoken.teamId ?? -1,
},
});
});
});

View File

@ -67,7 +67,7 @@
"cannot_repackage_codebase": "You can not repackage or sell the codebase",
"acquire_license": "Acquire a commercial license to remove these terms by emailing",
"terms_summary": "Summary of terms",
"signing_up_terms":"By signing up, you agree to our <1> Terms of Service </1> and <2>Privacy Policy</2>.",
"signing_up_terms":"By signing up, you agree to our <1>Terms of Service</1> and <2>Privacy Policy</2>.",
"open_env": "Open .env and agree to our License",
"env_changed": "I've changed my .env",
"accept_license": "Accept License",