Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update vitest version v0.34 to V2.11 #16676

Merged
merged 11 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions apps/web/test/lib/next-config.test.ts
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These dont need object containing as theyre exact matches

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ describe("next.config.js - Org Rewrite", () => {

describe("Rewrite", () => {
it("booking pages", () => {
expect(orgUserTypeRouteMatch("/user/type")?.params).toContain({
console.log(orgUserTypeRouteMatch("/user/type").params);
sean-brydon marked this conversation as resolved.
Show resolved Hide resolved
expect(orgUserTypeRouteMatch("/user/type")?.params).toEqual({
user: "user",
type: "type",
});
Expand All @@ -96,27 +97,27 @@ describe("next.config.js - Org Rewrite", () => {

expect(orgUserTypeRouteMatch("/abc")).toEqual(false);

expect(orgUserRouteMatch("/abc")?.params).toContain({
expect(orgUserRouteMatch("/abc")?.params).toEqual({
user: "abc",
});

// Tests that something that starts with 'd' which could accidentally match /d route is correctly identified as a booking page
expect(orgUserRouteMatch("/designer")?.params).toContain({
expect(orgUserRouteMatch("/designer")?.params).toEqual({
user: "designer",
});

// Tests that something that starts with 'apps' which could accidentally match /apps route is correctly identified as a booking page
expect(orgUserRouteMatch("/apps-conflict-possibility")?.params).toContain({
expect(orgUserRouteMatch("/apps-conflict-possibility")?.params).toEqual({
user: "apps-conflict-possibility",
});

// Tests that something that starts with '_next' which could accidentally match /_next route is correctly identified as a booking page
expect(orgUserRouteMatch("/_next-candidate")?.params).toContain({
expect(orgUserRouteMatch("/_next-candidate")?.params).toEqual({
user: "_next-candidate",
});

// Tests that something that starts with 'public' which could accidentally match /public route is correctly identified as a booking page
expect(orgUserRouteMatch("/public-person")?.params).toContain({
expect(orgUserRouteMatch("/public-person")?.params).toEqual({
user: "public-person",
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web/test/utils/bookingScenario/bookingScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1298,10 +1298,10 @@ export function enableEmailFeature() {

export function mockNoTranslations() {
log.silly("Mocking i18n.getTranslation to return identity function");
// @ts-expect-error FIXME
i18nMock.getTranslation.mockImplementation(() => {
return new Promise((resolve) => {
const identityFn = (key: string) => key;
// @ts-expect-error FIXME
resolve(identityFn);
});
});
Expand Down
8 changes: 4 additions & 4 deletions apps/web/test/utils/bookingScenario/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ const _testWithAndWithoutOrg = (
const t = mode === "only" ? test.only : mode === "skip" ? test.skip : test;
t(
`${description} - With org`,
async ({ emails, sms, meta, task, onTestFailed, expect, skip }) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta is no longer coming from the base vitest test -

async ({ emails, sms, task, onTestFailed, expect, skip, onTestFinished }) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to include onTestFinished now when expanding base fixtures

const org = await createOrganization({
name: "Test Org",
slug: "testorg",
});

await fn({
meta,
task,
onTestFailed,
expect,
Expand All @@ -34,23 +33,24 @@ const _testWithAndWithoutOrg = (
organization: org,
urlOrigin: `${WEBSITE_PROTOCOL}//${org.slug}.cal.local:3000`,
},
onTestFinished,
});
},
timeout
);

t(
`${description}`,
async ({ emails, sms, meta, task, onTestFailed, expect, skip }) => {
async ({ emails, sms, task, onTestFailed, expect, skip, onTestFinished }) => {
await fn({
emails,
sms,
meta,
task,
onTestFailed,
expect,
skip,
org: null,
onTestFinished,
});
},
timeout
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"test-e2e:embed-react": "yarn db-seed && yarn e2e:embed-react",
"test-playwright": "yarn playwright test --config=playwright.config.ts",
"test": "vitest run",
"test:ui": "vitest --ui",
"type-check": "turbo run type-check",
"type-check:ci": "turbo run type-check:ci --log-prefix=none",
"web": "yarn workspace @calcom/web",
Expand All @@ -85,8 +86,10 @@
"@playwright/test": "^1.45.3",
"@snaplet/copycat": "^4.1.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^16.0.1",
"@types/jsdom": "^21.1.3",
"@types/jsonwebtoken": "^9.0.3",
"@vitest/ui": "^2.1.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev dep to get a lovely UI for running tests https://vitest.dev/guide/ui

"c8": "^7.13.0",
"checkly": "latest",
"dotenv-checker": "^1.1.5",
Expand All @@ -104,9 +107,9 @@
"resize-observer-polyfill": "^1.5.1",
"tsc-absolute": "^1.0.0",
"typescript": "^4.9.4",
"vitest": "^0.34.6",
"vitest-fetch-mock": "^0.2.2",
"vitest-mock-extended": "^1.1.3"
"vitest": "^2.1.1",
"vitest-fetch-mock": "^0.3.0",
"vitest-mock-extended": "^2.0.2"
},
"dependencies": {
"@daily-co/daily-js": "^0.59.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,18 @@ describe("handleNewBooking", () => {

const createdBooking = await handleNewBooking(reqFollowingYear);

expect(createdBooking.responses).toContain({
email: booker.email,
name: booker.name,
});
expect(createdBooking.responses).toEqual(
expect.objectContaining({
email: booker.email,
name: booker.name,
})
);

expect(createdBooking).toContain({
location: "New York",
});
expect(createdBooking).toEqual(
expect.objectContaining({
location: "New York",
})
);

await expectBookingToBeInDatabase({
description: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,18 @@ describe("handleNewBooking", () => {
});

const createdBooking = await handleNewBooking(req);
expect(createdBooking.responses).toContain({
email: booker.email,
name: booker.name,
});
expect(createdBooking.responses).toEqual(
expect.objectContaining({
email: booker.email,
name: booker.name,
})
);

expect(createdBooking).toContain({
location: BookingLocations.CalVideo,
});
expect(createdBooking).toEqual(
expect.objectContaining({
location: BookingLocations.CalVideo,
})
);

await expectBookingToBeInDatabase({
description: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,18 @@ describe("handleNewBooking", () => {
});

const createdBooking = await handleNewBooking(req);
expect(createdBooking.responses).toContain({
email: booker.email,
name: booker.name,
});
expect(createdBooking.responses).toEqual(
expect.objectContaining({
email: booker.email,
name: booker.name,
})
);

expect(createdBooking).toContain({
location: BookingLocations.CalVideo,
});
expect(createdBooking).toEqual(
expect.objectContaining({
location: BookingLocations.CalVideo,
})
);

await expectBookingToBeInDatabase({
description: "",
Expand Down Expand Up @@ -308,14 +312,18 @@ describe("handleNewBooking", () => {
});

const createdBooking = await handleNewBooking(req);
expect(createdBooking.responses).toContain({
email: booker.email,
name: booker.name,
});
expect(createdBooking.responses).toEqual(
expect.objectContaining({
email: booker.email,
name: booker.name,
})
);

expect(createdBooking).toContain({
location: BookingLocations.CalVideo,
});
expect(createdBooking).toEqual(
expect.objectContaining({
location: BookingLocations.CalVideo,
})
);

await expectBookingToBeInDatabase({
description: "",
Expand Down
Loading
Loading