mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-01 17:59:52 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c4c4af40dd | |||
| 66f9526594 |
@@ -3,6 +3,7 @@ import {
|
|||||||
CustomizationHeaderPreset,
|
CustomizationHeaderPreset,
|
||||||
CustomizationIconsStyle,
|
CustomizationIconsStyle,
|
||||||
CustomizationLocale,
|
CustomizationLocale,
|
||||||
|
PublishedSiteContentLookup,
|
||||||
SiteCustomizationSettings,
|
SiteCustomizationSettings,
|
||||||
} from '@gitbook/api';
|
} from '@gitbook/api';
|
||||||
import { test, expect, Page } from '@playwright/test';
|
import { test, expect, Page } from '@playwright/test';
|
||||||
@@ -14,7 +15,7 @@ import { getContentTestURL } from '../tests/utils';
|
|||||||
|
|
||||||
interface Test {
|
interface Test {
|
||||||
name: string;
|
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
|
run?: (page: Page) => Promise<unknown>; // The test to run
|
||||||
fullPage?: boolean; // Whether the test should be fullscreened during testing
|
fullPage?: boolean; // Whether the test should be fullscreened during testing
|
||||||
screenshot?: false; // Should a screenshot be stored
|
screenshot?: false; // Should a screenshot be stored
|
||||||
@@ -763,6 +764,32 @@ const testCases: TestsCase[] = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'open.gitbook.com',
|
||||||
|
baseUrl: 'https://open.gitbook.com/',
|
||||||
|
tests: [
|
||||||
|
{
|
||||||
|
name: 'GitBook Docs',
|
||||||
|
url: async () => {
|
||||||
|
const res = await fetch(
|
||||||
|
`https://api.gitbook.com/v1/urls/published?url=https://docs.gitbook.com`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error('Failed to get published URL');
|
||||||
|
}
|
||||||
|
|
||||||
|
const published = await res.json<PublishedSiteContentLookup>();
|
||||||
|
if (!('site' in published)) {
|
||||||
|
throw new Error('Expected site for published URL');
|
||||||
|
}
|
||||||
|
|
||||||
|
return `~site/${published.site}?token=${published.apiToken}`;
|
||||||
|
},
|
||||||
|
run: waitForCookiesDialog,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const testCase of testCases) {
|
for (const testCase of testCases) {
|
||||||
@@ -770,7 +797,9 @@ for (const testCase of testCases) {
|
|||||||
for (const testEntry of testCase.tests) {
|
for (const testEntry of testCase.tests) {
|
||||||
const testFn = testEntry.only ? test.only : test;
|
const testFn = testEntry.only ? test.only : test;
|
||||||
testFn(testEntry.name, async ({ page, baseURL }) => {
|
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);
|
const url = getContentTestURL(contentUrl.toString(), baseURL);
|
||||||
await page.goto(url);
|
await page.goto(url);
|
||||||
if (testEntry.run) {
|
if (testEntry.run) {
|
||||||
|
|||||||
Reference in New Issue
Block a user