forked from dubinc/dub
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
81 additions
and
9 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { IntegrationHarness } from "../utils/integration"; | ||
|
||
const poweredBy = "Dub.co - Link management for modern marketing teams"; | ||
const fetchOptions: RequestInit = { | ||
cache: "no-store", | ||
redirect: "manual", | ||
headers: { | ||
"dub-no-track": "true", | ||
}, | ||
}; | ||
|
||
describe.sequential("Link Redirects", async () => { | ||
const h = new IntegrationHarness(); | ||
|
||
test("root", async () => { | ||
const response = await fetch(h.baseUrl, fetchOptions); | ||
|
||
expect(response.headers.get("location")).toBe("https://dub.co/"); | ||
expect(response.headers.get("x-powered-by")).toBe(poweredBy); | ||
expect(response.status).toBe(301); | ||
}); | ||
|
||
test("regular", async () => { | ||
const response = await fetch(`${h.baseUrl}/checkly-check`, fetchOptions); | ||
|
||
expect(response.headers.get("location")).toBe("https://www.checklyhq.com/"); | ||
expect(response.headers.get("x-powered-by")).toBe(poweredBy); | ||
expect(response.status).toBe(302); | ||
}); | ||
|
||
test("with slash", async () => { | ||
const response = await fetch(`${h.baseUrl}/checkly/check`, fetchOptions); | ||
|
||
expect(response.headers.get("location")).toBe("https://www.checklyhq.com/"); | ||
expect(response.headers.get("x-powered-by")).toBe(poweredBy); | ||
expect(response.status).toBe(302); | ||
}); | ||
|
||
test("with passthrough query", async () => { | ||
const response = await fetch( | ||
`${h.baseUrl}/checkly-check-passthrough?utm_source=checkly`, | ||
fetchOptions, | ||
); | ||
|
||
expect(response.headers.get("location")).toBe( | ||
"https://www.checklyhq.com/?utm_source=checkly&utm_medium=social&utm_campaign=checks", | ||
); | ||
expect(response.headers.get("x-powered-by")).toBe(poweredBy); | ||
expect(response.status).toBe(302); | ||
}); | ||
|
||
test("with complex query", async () => { | ||
const response = await fetch( | ||
`${h.baseUrl}/checkly-check-query`, | ||
fetchOptions, | ||
); | ||
|
||
expect(response.headers.get("location")).toBe( | ||
"https://guides.apple.com/?ug=CglEVUIgR3VpZGUSDgjZMhDEo%2BGA%2BZKqpJUBEg4I2TIQw7y33%2B%2B6ifL%2BARIOCNkyEJC988jqgIrQjQESDgjZMhCB%2B7XSiPTwrfUBEg4I2TIQ5J25xZOynPDxARINCNkyENuVr4POz8aMcBIOCMI7EK36pfjQuerJ0gESDQjCOxDSuurnjM6T7mASDQjCOxD3vr%2F%2Fkq%2FLqUwSDQjCOxCg9cK%2BjeOhnS4%3D", | ||
); | ||
expect(response.headers.get("x-powered-by")).toBe(poweredBy); | ||
expect(response.status).toBe(302); | ||
}); | ||
|
||
test("with password", async () => { | ||
const response = await fetch( | ||
`${h.baseUrl}/password/check?pw=dub`, | ||
fetchOptions, | ||
); | ||
|
||
expect(response.headers.get("location")).toBe("https://dub.co/"); | ||
expect(response.headers.get("x-powered-by")).toBe(poweredBy); | ||
expect(response.status).toBe(302); | ||
}); | ||
}); |
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