-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be53242
commit 5135fdd
Showing
13 changed files
with
258 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
packages/app-store/routing-forms/__tests__/getEventTypeRedirectUrl.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { describe, it, expect } from "vitest"; | ||
|
||
import { CAL_URL } from "@calcom/lib/constants"; | ||
|
||
import { getAbsoluteEventTypeRedirectUrl } from "../getEventTypeRedirectUrl"; | ||
|
||
console.log({ CAL_URL }); | ||
describe("getAbsoluteEventTypeRedirectUrl", () => { | ||
const defaultForm = { | ||
team: null, | ||
nonOrgUsername: null, | ||
nonOrgTeamslug: null, | ||
userOrigin: "https://user.cal.com", | ||
teamOrigin: "https://team.cal.com", | ||
}; | ||
|
||
const defaultParams = { | ||
eventTypeRedirectUrl: "user/event", | ||
form: defaultForm, | ||
allURLSearchParams: new URLSearchParams(), | ||
isEmbed: false, | ||
}; | ||
|
||
it("should return CAL_URL for non-migrated user", () => { | ||
const result = getAbsoluteEventTypeRedirectUrl({ | ||
...defaultParams, | ||
eventTypeRedirectUrl: "user/event", | ||
form: { ...defaultForm, nonOrgUsername: "user" }, | ||
}); | ||
expect(result).toBe(`${CAL_URL}/user/event?`); | ||
}); | ||
|
||
it("should return user origin for migrated user", () => { | ||
const result = getAbsoluteEventTypeRedirectUrl(defaultParams); | ||
expect(result).toBe("https://user.cal.com/user/event?"); | ||
}); | ||
|
||
it("should return CAL_URL for non-migrated team", () => { | ||
const result = getAbsoluteEventTypeRedirectUrl({ | ||
...defaultParams, | ||
eventTypeRedirectUrl: "team/team1/event", | ||
form: { ...defaultForm, nonOrgTeamslug: "team1" }, | ||
}); | ||
expect(result).toBe(`${CAL_URL}/team/team1/event?`); | ||
}); | ||
|
||
it("should return team origin for migrated team", () => { | ||
const result = getAbsoluteEventTypeRedirectUrl({ | ||
...defaultParams, | ||
eventTypeRedirectUrl: "team/team1/event", | ||
}); | ||
expect(result).toBe("https://team.cal.com/team/team1/event?"); | ||
}); | ||
|
||
it("should append URL search params", () => { | ||
const result = getAbsoluteEventTypeRedirectUrl({ | ||
...defaultParams, | ||
allURLSearchParams: new URLSearchParams("foo=bar&baz=qux"), | ||
}); | ||
expect(result).toBe("https://user.cal.com/user/event?foo=bar&baz=qux"); | ||
}); | ||
|
||
it("should append /embed for embedded views", () => { | ||
const result = getAbsoluteEventTypeRedirectUrl({ | ||
...defaultParams, | ||
allURLSearchParams: new URLSearchParams("foo=bar&baz=qux"), | ||
isEmbed: true, | ||
}); | ||
expect(result).toBe("https://user.cal.com/user/event/embed?foo=bar&baz=qux"); | ||
}); | ||
|
||
it.only("should throw an error if invalid team event redirect URL is provided", () => { | ||
expect(() => | ||
getAbsoluteEventTypeRedirectUrl({ | ||
...defaultParams, | ||
eventTypeRedirectUrl: "team/", | ||
}) | ||
).toThrow("eventTypeRedirectUrl must have username or teamSlug"); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...-forms/test/lib/jsonLogicToPrisma.test.ts → ...forms/__tests__/jsonLogicToPrisma.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.