chore: Remove all avatar/logo references (#14532)
* chore: Remove all avatar/logo references * Updated user profile to only use avatarUrl * fix: minor style issue * chore: Remove redundant includeTeamLogo * fix: Use right avatar default in event type list * fix: placeholder avatar team profile, target * chore: Add logoUrl/avatarUrl to JWT * fix: Bunch of org avatar issues, fix members list * Fix logoUrl on org pages * More type fixes * Hopefully final type fixes * Another round of type fixes * fix: UserForm ts * fix: Handle as return types, not input types * fix: Remove profile and add avatarUrl * fix: notFound as const * fix: Seeder avatarUrl params * revert: Migration changes for easier recovery * fix: Add explicit type to builder as avatar is now set * Add logoUrl to unpublished entity * Avatar test out of scope here * fix: Use the new avatarUrl after save * chore: Removed getOrgAvatarUrl/getTeamAvatarUrl * fix: Update sidebar image immediately after change * Unable to safe unnamed user, so default * fix: Unpublished page, add organization test * Add more tests
This commit is contained in:
1 parent
5695ba7c13
commit
d25c043046
73 files changed
+644
-770
No files matched your search
@@ -74,10 +74,6 @@ test.describe("Change username on settings", () => {
|
||||
});
|
||||
|
||||
expect(updatedUser.username).toBe("demo.username");
|
||||
|
||||
// Check if user avatar can be accessed and response headers contain 'image/' in the content type
|
||||
const response = await page.goto("/demo.username/avatar.png");
|
||||
expect(response?.headers()?.["content-type"]).toContain("image/");
|
||||
});
|
||||
|
||||
test("User can update to PREMIUM username", async ({ page, users }, testInfo) => {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import { expect } from "@playwright/test";
|
||||
import path from "path";
|
||||
|
||||
import { CAL_URL } from "@calcom/lib/constants";
|
||||
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({});
|
||||
test.describe("User Avatar", async () => {
|
||||
test("it can upload a user profile image", async ({ page, users }) => {
|
||||
const user = await users.create({ name: "John Doe" });
|
||||
await user.apiLogin();
|
||||
|
||||
let objectKey: string;
|
||||
|
||||
await test.step("Can upload an initial picture", async () => {
|
||||
await page.goto("/settings/my-account/profile");
|
||||
|
||||
@@ -26,8 +29,6 @@ test.describe("UploadAvatar", async () => {
|
||||
|
||||
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");
|
||||
|
||||
@@ -41,18 +42,165 @@ test.describe("UploadAvatar", async () => {
|
||||
},
|
||||
});
|
||||
|
||||
// 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]");
|
||||
objectKey = response.objectKey;
|
||||
|
||||
const src = await avatar.getAttribute("src");
|
||||
const avatarImage = page.getByTestId("profile-upload-avatar").locator("img");
|
||||
|
||||
await expect(src).toContain(response.objectKey);
|
||||
await expect(avatarImage).toHaveAttribute("src", new RegExp(`^\/api\/avatar\/${objectKey}\.png$`));
|
||||
|
||||
const urlResponse = await page.request.get(`/api/avatar/${response.objectKey}.png`, {
|
||||
const urlResponse = await page.request.get((await avatarImage.getAttribute("src")) || "", {
|
||||
maxRedirects: 0,
|
||||
});
|
||||
|
||||
await expect(urlResponse?.status()).toBe(200);
|
||||
});
|
||||
|
||||
await test.step("View avatar on the public page", async () => {
|
||||
await page.goto(`/${user.username}`);
|
||||
|
||||
await expect(page.locator(`img`)).toHaveAttribute(
|
||||
"src",
|
||||
new RegExp(`\/api\/avatar\/${objectKey}\.png$`)
|
||||
);
|
||||
// verify objectKey is passed to the OG image
|
||||
// yes, OG image URI encodes at multiple places.. don't want to mess with that.
|
||||
await expect(page.locator('meta[property="og:image"]')).toHaveAttribute(
|
||||
"content",
|
||||
new RegExp(
|
||||
encodeURIComponent(`meetingImage=${encodeURIComponent(`${CAL_URL}/api/avatar/${objectKey}.png`)}`)
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Team Logo", async () => {
|
||||
test("it can upload a team logo image", async ({ page, users }) => {
|
||||
const user = await users.create(undefined, { hasTeam: true });
|
||||
|
||||
const { team } = await user.getFirstTeamMembership();
|
||||
|
||||
await user.apiLogin();
|
||||
|
||||
await page.goto(`/settings/teams/${team.id}/profile`);
|
||||
|
||||
await test.step("Can upload an initial picture", async () => {
|
||||
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.getByText("Update").click();
|
||||
await page.waitForSelector("text=Your team has been updated successfully.");
|
||||
|
||||
const response = await prisma.avatar.findUniqueOrThrow({
|
||||
where: {
|
||||
teamId_userId_isBanner: {
|
||||
userId: 0,
|
||||
teamId: team.id,
|
||||
isBanner: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const avatarImage = page.getByTestId("profile-upload-logo").locator("img");
|
||||
|
||||
await expect(avatarImage).toHaveAttribute(
|
||||
"src",
|
||||
new RegExp(`^\/api\/avatar\/${response.objectKey}\.png$`)
|
||||
);
|
||||
|
||||
const urlResponse = await page.request.get((await avatarImage.getAttribute("src")) || "", {
|
||||
maxRedirects: 0,
|
||||
});
|
||||
|
||||
await expect(urlResponse?.status()).toBe(200);
|
||||
|
||||
await expect(
|
||||
page.getByTestId("tab-teams").locator(`img[src="/api/avatar/${response.objectKey}.png"]`)
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Organization Logo", async () => {
|
||||
test("it can upload a organization logo image", async ({ page, users, orgs }) => {
|
||||
const owner = await users.create(undefined, { hasTeam: true, isUnpublished: true, isOrg: true });
|
||||
const { team: org } = await owner.getOrgMembership();
|
||||
|
||||
await owner.apiLogin();
|
||||
await page.goto("/settings/organizations/profile");
|
||||
|
||||
let objectKey: string;
|
||||
|
||||
await test.step("Can upload an initial picture", async () => {
|
||||
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.getByText("Update").click();
|
||||
await page.waitForSelector("text=Your organization updated successfully");
|
||||
|
||||
const response = await prisma.avatar.findUniqueOrThrow({
|
||||
where: {
|
||||
teamId_userId_isBanner: {
|
||||
userId: 0,
|
||||
teamId: org.id,
|
||||
isBanner: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
objectKey = response.objectKey;
|
||||
|
||||
const avatarImage = page.getByTestId("profile-upload-logo").locator("img");
|
||||
|
||||
await expect(avatarImage).toHaveAttribute(
|
||||
"src",
|
||||
new RegExp(`^\/api\/avatar\/${response.objectKey}\.png$`)
|
||||
);
|
||||
|
||||
const urlResponse = await page.request.get((await avatarImage.getAttribute("src")) || "", {
|
||||
maxRedirects: 0,
|
||||
});
|
||||
|
||||
await expect(urlResponse?.status()).toBe(200);
|
||||
|
||||
// TODO: Implement the org logo updating in the sidebar
|
||||
// this should be done in the orgBrandingContext
|
||||
});
|
||||
|
||||
const requestedSlug = org.metadata?.requestedSlug;
|
||||
|
||||
await test.step("it shows the correct logo on the unpublished public page", async () => {
|
||||
await page.goto(`/org/${requestedSlug}`);
|
||||
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
|
||||
await expect(page.locator(`img`)).toHaveAttribute(
|
||||
"src",
|
||||
new RegExp(`^\/api\/avatar\/${objectKey}\.png$`)
|
||||
);
|
||||
});
|
||||
|
||||
// TODO: add test for published team.
|
||||
// unpublished works regardless of orgDomain but when it is published it does work
|
||||
});
|
||||
});
|
||||
@@ -9,7 +9,6 @@ test.describe.configure({ mode: "parallel" });
|
||||
const title = (name: string) => `${name} is unpublished`;
|
||||
const description = (entity: string) =>
|
||||
`This ${entity} link is currently not available. Please contact the ${entity} owner or ask them to publish it.`;
|
||||
const avatar = (slug: string, entity = "team") => `/${entity}/${slug}/avatar.png`;
|
||||
|
||||
test.afterAll(async ({ users }) => {
|
||||
await users.deleteAll();
|
||||
@@ -24,7 +23,7 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(team.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("team")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
|
||||
test("Regular team event type", async ({ page, users }) => {
|
||||
@@ -40,7 +39,7 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(team.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("team")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
|
||||
test("Organization profile", async ({ users, page }) => {
|
||||
@@ -52,7 +51,7 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(org.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("organization")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug, "org"));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
|
||||
test("Organization sub-team", async ({ users, page }) => {
|
||||
@@ -70,7 +69,7 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(org.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("organization")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug, "org"));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
|
||||
test("Organization sub-team event-type", async ({ users, page }) => {
|
||||
@@ -90,7 +89,7 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(org.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("organization")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug, "org"));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
|
||||
test("Organization user", async ({ users, page }) => {
|
||||
@@ -102,7 +101,7 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(org.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("organization")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug, "org"));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
|
||||
test("Organization user event-type", async ({ users, page }) => {
|
||||
@@ -115,6 +114,6 @@ test.describe("Unpublished", () => {
|
||||
expect(await page.locator('[data-testid="empty-screen"]').count()).toBe(1);
|
||||
expect(await page.locator(`h2:has-text("${title(org.name)}")`).count()).toBe(1);
|
||||
expect(await page.locator(`div:text("${description("organization")}")`).count()).toBe(1);
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", avatar(requestedSlug, "org"));
|
||||
await expect(page.locator(`img`)).toHaveAttribute("src", /.*/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user