Skip to content

Commit c83ae7e

Browse files
committed
Add e2e tests for embed frame
1 parent f5ba352 commit c83ae7e

File tree

13 files changed

+324
-14
lines changed

13 files changed

+324
-14
lines changed

packages/embed/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './client';
2+
export * from './standalone';

packages/gitbook/e2e/internal.spec.ts

Lines changed: 297 additions & 3 deletions
Large diffs are not rendered by default.

packages/gitbook/e2e/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ export async function waitForIcons(page: Page) {
454454
*/
455455
async function waitForTOCScrolling(page: Page) {
456456
const viewport = await page.viewportSize();
457-
if (viewport && viewport.width >= 1024) {
457+
if (viewport && viewport.width >= 1024 && !page.url().includes('~gitbook')) {
458458
const toc = page.getByTestId('table-of-contents');
459459
await expect(toc).toBeVisible();
460460
await page.evaluate(() => {

packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ function ToolCallSummary(props: { toolCall: AIToolCall; context: GitBookSiteCont
3939
const { toolCall, context } = props;
4040

4141
return (
42-
<div className="mt-2 flex origin-top-left animate-blur-in-slow items-start gap-2 text-sm text-tint-subtle">
42+
<div
43+
data-testid="ai-chat-tool-summary"
44+
className="mt-2 flex origin-top-left animate-blur-in-slow items-start gap-2 text-sm text-tint-subtle"
45+
>
4346
<Icon
4447
icon={getIconForToolCall(toolCall)}
4548
className="mt-1 size-3 shrink-0 text-tint-subtle/8"

packages/gitbook/src/components/AIChat/AIChat.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export function AIChat() {
7070

7171
return (
7272
<div
73-
data-testid="ai-chat"
7473
className={tcls(
7574
'ai-chat inset-y-0 right-0 z-40 mx-auto flex max-w-3xl scroll-mt-36 px-4 py-4 transition-[width,opacity,margin,display] transition-discrete duration-300 sm:px-6 lg:fixed lg:w-80 lg:p-0 xl:w-96',
7675
chat.opened
@@ -79,7 +78,7 @@ export function AIChat() {
7978
)}
8079
>
8180
<EmbeddableFrame className="relative shrink-0 border-tint-subtle border-l to-tint-base transition-all duration-300 max-lg:circular-corners:rounded-3xl max-lg:rounded-corners:rounded-md max-lg:border lg:w-80 xl:w-96">
82-
<EmbeddableFrameMain>
81+
<EmbeddableFrameMain data-testid="ai-chat">
8382
<EmbeddableFrameHeader>
8483
<AIChatDynamicIcon trademark={config.trademark} />
8584
<EmbeddableFrameHeaderMain>
@@ -232,13 +231,14 @@ export function AIChatBody(props: {
232231
<h5
233232
className="animate-blur-in-slow font-bold text-lg text-tint-strong [@container(min-height:400px)]:text-center"
234233
style={{ animationDelay: '.5s' }}
235-
data-testid="ai-chat-time-greeting"
234+
data-testid="ai-chat-greeting-title"
236235
>
237236
{timeGreeting}
238237
</h5>
239238
<p
240239
className="animate-blur-in-slow text-tint [@container(min-height:400px)]:text-center"
241240
style={{ animationDelay: '.6s' }}
241+
data-testid="ai-chat-greeting-subtitle"
242242
>
243243
{t(language, 'ai_chat_assistant_description')}
244244
</p>

packages/gitbook/src/components/AIChat/AIChatSuggestedQuestions.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ export default function AIChatSuggestedQuestions(props: {
1717
} = props;
1818

1919
return (
20-
<div className="flex flex-col items-start gap-2 self-start">
20+
<div
21+
className="flex flex-col items-start gap-2 self-start"
22+
data-testid="ai-chat-suggested-questions"
23+
>
2124
{suggestions.map((question, index) => (
2225
<Button
26+
data-testid="ai-chat-suggested-question"
2327
key={question}
2428
variant="blank"
2529
size="medium"

packages/gitbook/src/components/AIChat/AIChatToolConfirmations.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function AIChatToolConfirmations(props: {
3737
style={{ animationDelay: `${0.5 + index * 0.1}s` }}
3838
>
3939
<Button
40+
data-testid="ai-chat-tool-confirmation"
4041
onClick={() => {
4142
tool.confirm();
4243
}}

packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function EmbeddableAIChat() {
6161
<EmbeddableIframeTabs active="assistant" />
6262
<EmbeddableIframeButtons />
6363
</EmbeddableFrameSidebar>
64-
<EmbeddableFrameMain>
64+
<EmbeddableFrameMain data-testid="ai-chat">
6565
<EmbeddableFrameHeader>
6666
<EmbeddableFrameHeaderMain>
6767
<EmbeddableFrameTitle>

packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function EmbeddableDocsPage(props: EmbeddableDocsPageProps) {
4343
<EmbeddableIframeTabs active="docs" />
4444
<EmbeddableIframeButtons />
4545
</EmbeddableFrameSidebar>
46-
<EmbeddableFrameMain>
46+
<EmbeddableFrameMain data-testid="embed-docs-page">
4747
<div className="relative flex not-hydrated:animate-blur-in-slow flex-col">
4848
<EmbeddableFrameHeader>
4949
<HeaderMobileMenu className="-ml-2 page-no-toc:hidden" />

packages/gitbook/src/components/Embeddable/EmbeddableDocsPageControlButtons.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function EmbeddableDocsPageControlButtons(props: { href: string }) {
1010
return (
1111
<Button
1212
icon="arrow-up-right-from-square"
13+
data-testid="embed-docs-page-open-in-new-tab"
1314
label={tString(language, 'open_in_new_tab')}
1415
href={href}
1516
target="_blank"

0 commit comments

Comments
 (0)