Fix/login username registration (#2241)
* username update from getting-started when received as query param * Added test for onboarding username update * Now saving username saved in localStorage * remove username field * Removed wordlist * Implement checkoutUsername as api endpoint * Remove unused lib utils not empty Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
1a77e4046e
commit
3341074bb2
4 files changed
+99
-19
No files matched your search
@@ -1,8 +1,24 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
import prisma from "@lib/prisma";
|
||||
|
||||
test.describe("Onboarding", () => {
|
||||
test.use({ storageState: "playwright/artifacts/onboardingStorageState.json" });
|
||||
|
||||
// You want to always reset account completedOnboarding after each test
|
||||
test.afterEach(async () => {
|
||||
// Revert DB change
|
||||
await prisma.user.update({
|
||||
where: {
|
||||
email: "[email protected]",
|
||||
},
|
||||
data: {
|
||||
username: "onboarding",
|
||||
completedOnboarding: false,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("redirects to /getting-started after login", async ({ page }) => {
|
||||
await page.goto("/event-types");
|
||||
await page.waitForNavigation({
|
||||
@@ -11,4 +27,23 @@ test.describe("Onboarding", () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Onboarding", () => {
|
||||
test("update onboarding username via localstorage", async ({ page }) => {
|
||||
await page.addInitScript(() => {
|
||||
window.localStorage.setItem("username", "alwaysavailable");
|
||||
}, {});
|
||||
// Try to go getting started with a available username
|
||||
await page.goto("/getting-started");
|
||||
// Wait for useEffectUpdate to run
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
const updatedUser = await prisma.user.findUnique({
|
||||
where: { email: "[email protected]" },
|
||||
select: { id: true, username: true },
|
||||
});
|
||||
|
||||
expect(updatedUser?.username).toBe("alwaysavailable");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user