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

open.gitbook.com e2e test #2515

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
testEntryUrl
taranvohra committed Oct 11, 2024

Verified

This commit was signed with the committer’s verified signature.
bkontur Branislav Kontur
commit c4c4af40dde5f2d5f44346b1061154cb25c9cdd1
10 changes: 6 additions & 4 deletions packages/gitbook/e2e/pages.spec.ts
Original file line number Diff line number Diff line change
@@ -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
@@ -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`,
);
@@ -785,7 +785,7 @@ const testCases: TestsCase[] = [
}

return `~site/${published.site}?token=${published.apiToken}`;
})(),
},
run: waitForCookiesDialog,
},
],
@@ -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) {