Files
calendar/apps/web/playwright/settings/upload-avatar.e2e.ts
T
Udit TakkarandGitHub 0efe25feb4 fix: org banner (#14041)
* fix: org banner

* fix: type error
2024-03-11 12:16:27 +00:00

59 lines
1.8 KiB
TypeScript

import { expect } from "@playwright/test";
import path from "path";
import { prisma } from "@calcom/prisma";
import { test } from "../lib/fixtures";
test.describe("UploadAvatar", async () => {
test("can upload an image", async ({ page, users }) => {
const user = await users.create({});
await user.apiLogin();
await test.step("Can upload an initial picture", async () => {
await page.goto("/settings/my-account/profile");
await page.getByTestId("open-upload-avatar-dialog").click();
const [fileChooser] = await Promise.all([
// It is important to call waitForEvent before click to set up waiting.
page.waitForEvent("filechooser"),
// Opens the file chooser.
page.getByTestId("open-upload-image-filechooser").click(),
]);
await fileChooser.setFiles(`${path.dirname(__filename)}/../fixtures/cal.png`);
await page.getByTestId("upload-avatar").click();
await page.locator("input[name='name']").fill(user.email);
await page.getByText("Update").click();
await page.waitForSelector("text=Settings updated successfully");
const response = await prisma.avatar.findUniqueOrThrow({
where: {
teamId_userId_isBanner: {
userId: user.id,
teamId: 0,
isBanner: false,
},
},
});
// Wait for the avatar image with the http src to appear instead of the data uri
const avatar = page.getByTestId("profile-upload-avatar").locator("img[src^=http]");
const src = await avatar.getAttribute("src");
await expect(src).toContain(response.objectKey);
const urlResponse = await page.request.get(`/api/avatar/${response.objectKey}.png`, {
maxRedirects: 0,
});
await expect(urlResponse?.status()).toBe(200);
});
});
});