Skip to content

Commit c4c4af4

Browse files
committed
testEntryUrl
1 parent 66f9526 commit c4c4af4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/gitbook/e2e/pages.spec.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getContentTestURL } from '../tests/utils';
1515

1616
interface Test {
1717
name: string;
18-
url: string; // URL to visit for testing
18+
url: string | (() => Promise<string>); // URL to visit for testing
1919
run?: (page: Page) => Promise<unknown>; // The test to run
2020
fullPage?: boolean; // Whether the test should be fullscreened during testing
2121
screenshot?: false; // Should a screenshot be stored
@@ -770,7 +770,7 @@ const testCases: TestsCase[] = [
770770
tests: [
771771
{
772772
name: 'GitBook Docs',
773-
url: await (async () => {
773+
url: async () => {
774774
const res = await fetch(
775775
`https://api.gitbook.com/v1/urls/published?url=https://docs.gitbook.com`,
776776
);
@@ -785,7 +785,7 @@ const testCases: TestsCase[] = [
785785
}
786786

787787
return `~site/${published.site}?token=${published.apiToken}`;
788-
})(),
788+
},
789789
run: waitForCookiesDialog,
790790
},
791791
],
@@ -797,7 +797,9 @@ for (const testCase of testCases) {
797797
for (const testEntry of testCase.tests) {
798798
const testFn = testEntry.only ? test.only : test;
799799
testFn(testEntry.name, async ({ page, baseURL }) => {
800-
const contentUrl = new URL(testEntry.url, testCase.baseUrl);
800+
const testEntryUrl =
801+
typeof testEntry.url === 'string' ? testEntry.url : await testEntry.url();
802+
const contentUrl = new URL(testEntryUrl, testCase.baseUrl);
801803
const url = getContentTestURL(contentUrl.toString(), baseURL);
802804
await page.goto(url);
803805
if (testEntry.run) {

0 commit comments

Comments
 (0)