Skip to content

Commit 12a433b

Browse files
committed
Update internal.spec.ts
1 parent 2d22f0a commit 12a433b

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

packages/gitbook/e2e/internal.spec.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ import type { GitBookStandalone } from '@gitbook/embed';
1313
import { expect } from '@playwright/test';
1414
import jwt from 'jsonwebtoken';
1515

16+
// Local type augmentation for window.GitBook in test context
17+
declare global {
18+
interface Window {
19+
GitBook?: GitBookStandalone;
20+
}
21+
}
22+
1623
import {
1724
VISITOR_TOKEN_COOKIE,
1825
getVisitorAuthCookieName,
@@ -1992,7 +1999,7 @@ const testCases: TestsCase[] = [
19921999
url: '',
19932000
run: async (page) => {
19942001
await page.evaluate(() => {
1995-
const GitBook = window.GitBook as unknown as GitBookStandalone;
2002+
const GitBook = window.GitBook as GitBookStandalone;
19962003
GitBook('navigateToPage', '/getting-started/quickstart');
19972004
});
19982005
await expect(page.locator('#gitbook-widget-window')).toBeVisible();
@@ -2009,7 +2016,7 @@ const testCases: TestsCase[] = [
20092016
url: '',
20102017
run: async (page) => {
20112018
await page.evaluate((aiPrompt) => {
2012-
const GitBook = window.GitBook as unknown as GitBookStandalone;
2019+
const GitBook = window.GitBook as GitBookStandalone;
20132020
GitBook('postUserMessage', aiPrompt);
20142021
}, AI_PROMPT);
20152022
const iframe = page.frameLocator('#gitbook-widget-iframe');
@@ -2024,7 +2031,7 @@ const testCases: TestsCase[] = [
20242031
url: '',
20252032
run: async (page) => {
20262033
await page.evaluate(() => {
2027-
const GitBook = window.GitBook as unknown as GitBookStandalone;
2034+
const GitBook = window.GitBook as GitBookStandalone;
20282035
GitBook('configure', {
20292036
button: {
20302037
label: 'Docs',
@@ -2044,7 +2051,7 @@ const testCases: TestsCase[] = [
20442051
url: '',
20452052
run: async (page) => {
20462053
await page.evaluate(() => {
2047-
const GitBook = window.GitBook as unknown as GitBookStandalone;
2054+
const GitBook = window.GitBook as GitBookStandalone;
20482055
GitBook('configure', {
20492056
suggestions: [
20502057
'What is GitBook?',
@@ -2070,14 +2077,14 @@ const testCases: TestsCase[] = [
20702077
url: '',
20712078
run: async (page) => {
20722079
await page.evaluate((aiPrompt) => {
2073-
const GitBook = window.GitBook as unknown as GitBookStandalone;
2080+
const GitBook = window.GitBook as GitBookStandalone;
20742081
GitBook('configure', {
20752082
actions: [
20762083
{
20772084
label: 'Open internal link',
20782085
icon: 'bolt',
20792086
onClick: () =>
2080-
(window.GitBook as unknown as GitBookStandalone)(
2087+
(window.GitBook as GitBookStandalone)(
20812088
'navigateToPage',
20822089
'/getting-started/quickstart'
20832090
),
@@ -2092,17 +2099,19 @@ const testCases: TestsCase[] = [
20922099
{
20932100
label: 'Post message',
20942101
icon: 'message',
2095-
onClick: () =>
2096-
(window.GitBook as unknown as GitBookStandalone)(
2097-
'postUserMessage',
2098-
aiPrompt
2099-
),
2102+
onClick: () => {
2103+
const GitBook = window.GitBook as GitBookStandalone;
2104+
GitBook('postUserMessage', aiPrompt);
2105+
GitBook('navigateToAssistant');
2106+
},
21002107
},
21012108
{
21022109
label: 'Close',
21032110
icon: 'xmark',
2104-
onClick: () =>
2105-
(window.GitBook as unknown as GitBookStandalone)('close'),
2111+
onClick: () => {
2112+
const GitBook = window.GitBook as GitBookStandalone;
2113+
GitBook('close');
2114+
},
21062115
},
21072116
],
21082117
});
@@ -2148,7 +2157,7 @@ const testCases: TestsCase[] = [
21482157
url: '',
21492158
run: async (page) => {
21502159
await page.evaluate(() => {
2151-
const GitBook = window.GitBook as unknown as GitBookStandalone;
2160+
const GitBook = window.GitBook as GitBookStandalone;
21522161
GitBook('configure', {
21532162
tools: [
21542163
{

0 commit comments

Comments
 (0)