Conversation
To switch to AI tab in embed upon posting a new message
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive E2E test coverage for the GitBook Embed feature in standalone mode (widget button), assistant+docs mode, and docs-only mode. The changes include adding test identifiers throughout the embed and AI chat components, implementing new E2E tests for various embed configurations and APIs, and exporting the standalone module from the embed package for type-safe usage in tests.
- Added extensive E2E test cases covering embed modes (standalone, assistant+docs, docs-only) and configuration APIs (button customization, suggested questions, action buttons, custom tools, navigation)
- Added
data-testidattributes to enable reliable test selectors for AI chat components (greeting, suggested questions, tool confirmations, tool summaries) - Moved
data-testid="ai-chat"from the outer container to the main frame element for more accurate targeting in embed contexts
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/gitbook/e2e/internal.spec.ts | Added comprehensive E2E tests for embed widget functionality including standalone UX, configuration APIs, tab switching, navigation, and custom tools |
| packages/gitbook/e2e/util.ts | Updated TOC scrolling helper to skip operation when testing embed demo iframes |
| packages/gitbook/src/components/AIChat/AIChat.tsx | Moved data-testid="ai-chat" from outer container to EmbeddableFrameMain and updated greeting test ID |
| packages/gitbook/src/components/AIChat/AIChatSuggestedQuestions.tsx | Added test IDs for suggested questions container and individual question buttons |
| packages/gitbook/src/components/AIChat/AIChatToolConfirmations.tsx | Added test ID for tool confirmation buttons |
| packages/gitbook/src/components/AI/server-actions/AIToolCallsSummary.tsx | Added test ID for tool call summary display |
| packages/gitbook/src/components/Embeddable/EmbeddableFrame.tsx | Modified EmbeddableFrameMain to accept and spread additional props including data-testid |
| packages/gitbook/src/components/Embeddable/EmbeddableAIChat.tsx | Added data-testid to EmbeddableFrameMain for AI chat identification |
| packages/gitbook/src/components/Embeddable/EmbeddableDocsPage.tsx | Added data-testid to EmbeddableFrameMain for docs page identification |
| packages/gitbook/src/components/Embeddable/EmbeddableDocsPageControlButtons.tsx | Added test ID for open-in-new-tab button |
| packages/gitbook/src/components/Embeddable/EmbeddableIframeAPI.tsx | Added test ID for embed action buttons |
| packages/gitbook/src/components/Header/HeaderMobileMenu.tsx | Added test ID for TOC button |
| packages/embed/src/index.ts | Exported standalone module for type-safe API usage in tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gregberge
approved these changes
Jan 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds E2E test coverage for GitBook Embed (standalone, assistant+docs, docs-only modes) and their configuration APIs.
Important
Cloudflare can only run a subset of these tests due to a URL issue in preview mode. In short, when loading the
~gitbook/embed/demoroute, we load the embed script from the maingitbook-open-v2-preview.gitbook.workers.devdomain instead of the branch-specificxxxxxxxx-gitbook-open-v2-preview.gitbook.workers.devdomain. This means an outdated version of the embed is loaded. It seems pretty inherent to the preview route, so not worth fixing in this release since the Vercel tests work well. We might be able to enable these tests in the future when the embed is more stable.internal.spec.tscovering embed modes and configuration APIs (button label/icon, suggested questions, action buttons, custom tools, navigation)data-testidattributes for AI chat elements (container, greeting, suggested questions, tool confirmations)data-testid="ai-chat"from outer container to main frame elementdata-testid="ai-chat-greeting-title"standalonemodule from embed package for type-safe API usage in tests