2022-07-06 19:31:07 +00:00
|
|
|
import { expect } from "@playwright/test";
|
|
|
|
|
2022-08-17 17:38:21 +00:00
|
|
|
import stripe from "@calcom/features/ee/payments/server/stripe";
|
2022-07-06 19:31:07 +00:00
|
|
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
|
|
|
|
|
|
|
import { test } from "./lib/fixtures";
|
|
|
|
|
|
|
|
test.describe.configure({ mode: "parallel" });
|
|
|
|
|
|
|
|
const IS_STRIPE_ENABLED = !!(
|
|
|
|
process.env.STRIPE_CLIENT_ID &&
|
|
|
|
process.env.NEXT_PUBLIC_STRIPE_PUBLIC_KEY &&
|
|
|
|
process.env.STRIPE_PRIVATE_KEY
|
|
|
|
);
|
|
|
|
|
|
|
|
const IS_SELF_HOSTED = !(
|
|
|
|
new URL(WEBAPP_URL).hostname.endsWith(".cal.dev") || !!new URL(WEBAPP_URL).hostname.endsWith(".cal.com")
|
|
|
|
);
|
|
|
|
|
|
|
|
test.describe("Change username on settings", () => {
|
|
|
|
test.afterEach(async ({ users }) => {
|
|
|
|
await users.deleteAll();
|
|
|
|
});
|
|
|
|
|
2022-10-06 18:15:14 +00:00
|
|
|
/** TODO: Find out why it's timing out */
|
|
|
|
test.fixme("User can change username", async ({ page, users, prisma }) => {
|
2022-12-07 19:55:47 +00:00
|
|
|
const user = await users.create();
|
2022-07-06 19:31:07 +00:00
|
|
|
|
2023-06-06 18:02:32 +00:00
|
|
|
await user.apiLogin();
|
2022-07-06 19:31:07 +00:00
|
|
|
// Try to go homepage
|
2022-09-15 16:59:48 +00:00
|
|
|
await page.goto("/settings/my-account/profile");
|
2022-07-06 19:31:07 +00:00
|
|
|
// Change username from normal to normal
|
|
|
|
const usernameInput = page.locator("[data-testid=username-input]");
|
|
|
|
|
|
|
|
await usernameInput.fill("demousernamex");
|
2022-09-22 17:34:17 +00:00
|
|
|
await page.click("[data-testid=update-username-btn]");
|
2022-08-17 17:38:21 +00:00
|
|
|
await Promise.all([
|
2022-09-22 17:34:17 +00:00
|
|
|
page.click("[data-testid=save-username]"),
|
2022-08-17 17:38:21 +00:00
|
|
|
page.waitForResponse("**/viewer.updateProfile*"),
|
|
|
|
]);
|
|
|
|
|
2022-09-02 02:00:48 +00:00
|
|
|
const newUpdatedUser = await prisma.user.findUniqueOrThrow({
|
2022-07-06 19:31:07 +00:00
|
|
|
where: {
|
|
|
|
id: user.id,
|
|
|
|
},
|
|
|
|
});
|
2022-09-02 02:00:48 +00:00
|
|
|
expect(newUpdatedUser.username).toBe("demousernamex");
|
2022-07-06 19:31:07 +00:00
|
|
|
});
|
|
|
|
|
2022-12-07 19:55:47 +00:00
|
|
|
test("User can update to PREMIUM username", async ({ page, users }, testInfo) => {
|
2022-07-06 19:31:07 +00:00
|
|
|
// eslint-disable-next-line playwright/no-skipped-test
|
|
|
|
test.skip(!IS_STRIPE_ENABLED, "It should only run if Stripe is installed");
|
2023-06-06 11:59:57 +00:00
|
|
|
// eslint-disable-next-line playwright/no-skipped-test
|
2022-07-06 19:31:07 +00:00
|
|
|
test.skip(IS_SELF_HOSTED, "It shouldn't run on self hosted");
|
|
|
|
|
2022-12-07 19:55:47 +00:00
|
|
|
const user = await users.create();
|
|
|
|
await stripe.customers.create({ email: `${user?.username}@example.com` });
|
2022-07-06 19:31:07 +00:00
|
|
|
|
2023-06-06 18:02:32 +00:00
|
|
|
await user.apiLogin();
|
2022-09-15 16:59:48 +00:00
|
|
|
await page.goto("/settings/my-account/profile");
|
2022-07-06 19:31:07 +00:00
|
|
|
|
|
|
|
// Change username from normal to premium
|
|
|
|
const usernameInput = page.locator("[data-testid=username-input]");
|
|
|
|
|
|
|
|
await usernameInput.fill(`xx${testInfo.workerIndex}`);
|
|
|
|
|
|
|
|
// Click on save button
|
2022-09-15 16:59:48 +00:00
|
|
|
await page.click('button[type="submit"]');
|
2022-07-06 19:31:07 +00:00
|
|
|
|
|
|
|
// Validate modal text fields
|
|
|
|
const currentUsernameText = page.locator("[data-testid=current-username]").innerText();
|
|
|
|
const newUsernameText = page.locator("[data-testid=new-username]").innerText();
|
|
|
|
|
|
|
|
expect(currentUsernameText).not.toBe(newUsernameText);
|
|
|
|
|
|
|
|
// Click on Go to billing
|
|
|
|
await page.click("[data-testid=go-to-billing]", { timeout: 300 });
|
|
|
|
|
|
|
|
await page.waitForLoadState();
|
|
|
|
|
|
|
|
await expect(page).toHaveURL(/.*checkout.stripe.com/);
|
|
|
|
});
|
|
|
|
});
|