Skip to content

Commit

Permalink
testEntryUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
taranvohra committed Oct 11, 2024
1 parent 66f9526 commit c4c4af4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/gitbook/e2e/pages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getContentTestURL } from '../tests/utils';

interface Test {
name: string;
url: string; // URL to visit for testing
url: string | (() => Promise<string>); // URL to visit for testing
run?: (page: Page) => Promise<unknown>; // The test to run
fullPage?: boolean; // Whether the test should be fullscreened during testing
screenshot?: false; // Should a screenshot be stored
Expand Down Expand Up @@ -770,7 +770,7 @@ const testCases: TestsCase[] = [
tests: [
{
name: 'GitBook Docs',
url: await (async () => {
url: async () => {
const res = await fetch(
`https://api.gitbook.com/v1/urls/published?url=https://docs.gitbook.com`,
);
Expand All @@ -785,7 +785,7 @@ const testCases: TestsCase[] = [
}

return `~site/${published.site}?token=${published.apiToken}`;
})(),
},
run: waitForCookiesDialog,
},
],
Expand All @@ -797,7 +797,9 @@ for (const testCase of testCases) {
for (const testEntry of testCase.tests) {
const testFn = testEntry.only ? test.only : test;
testFn(testEntry.name, async ({ page, baseURL }) => {
const contentUrl = new URL(testEntry.url, testCase.baseUrl);
const testEntryUrl =
typeof testEntry.url === 'string' ? testEntry.url : await testEntry.url();
const contentUrl = new URL(testEntryUrl, testCase.baseUrl);
const url = getContentTestURL(contentUrl.toString(), baseURL);
await page.goto(url);
if (testEntry.run) {
Expand Down

0 comments on commit c4c4af4

Please sign in to comment.