TidGi-Desktop/features/talkWithAI.feature
lin onetwo 1cd266d8fe test: implement scenario isolation for E2E tests
- Isolate each test scenario in test-artifacts/{scenarioSlug}/ directory
- Use dynamic ports for mock OpenAI server to avoid port conflicts
- Log VIEW_LOADED event via did-finish-load in main process (more reliable)
- Search all .log files when waiting for log markers
- Increase timeout for log marker steps to 15 seconds
- Fix ts-node cache issues by clearing cache before tests
- Move application launch to individual scenarios (required for mock server setup)

All 45 E2E test scenarios now pass consistently.
2026-01-17 01:19:53 +08:00

73 lines
5.1 KiB
Gherkin
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Feature: Talk with AI from Wiki Selection
As a user
I want to select text in wiki and talk with AI about it
So that I can get AI-powered explanations in a split view
Background:
Given I add test ai settings
@talkWithAI @mockOpenAI
Scenario: Talk with AI - complete workflow
Given I have started the mock OpenAI server
| response | stream |
| | false |
| | false |
| 访 | false |
| | false |
# Launch application after mock server is ready
Then I launch the TidGi application
And I wait for the page to load completely
And I should see a "page body" element with selector "body"
# Part 1: Create new split view from wiki selection
When I click on a "wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
# Wait for agent workspace to be created and activate it to ensure React components are mounted
Then I should see a "agent workspace button" element with selector "[data-testid='workspace-agent']"
When I click on "agent workspace button and wiki workspace button" elements with selectors:
| element description | selector |
| agent workspace button | [data-testid='workspace-agent'] |
| wiki workspace button | div[data-testid^='workspace-']:has-text('wiki') |
# Trigger "Talk with AI" - should create new split view
When I send ask AI with selection message with text "Click button on top-right of this card to start edit." and workspace "wiki"
Then I should see "split view container and wiki embed and chat input" elements with selectors:
| element description | selector |
| split view container | [data-testid='split-view-container'] |
| wiki embed | [data-testid='wiki-embed-view'] |
| chat input | [data-testid='agent-message-input'] |
And I confirm the "main" window browser view is positioned within visible window bounds
And I should see 2 messages in chat history
# Part 2: Reuse active split view - messages should accumulate (not reset)
When I send ask AI with selection message with text "How to edit?" and workspace "wiki"
Then I should see "split view container with 4 messages" elements with selectors:
| element description | selector |
| split view container with 4 messages| [data-testid='split-view-container'] |
# Should see 4 messages now (2 from part 1 + 2 new ones) - proves tab was reused
And I should see 4 messages in chat history
# Part 3: Create new tab when starting from regular chat
When I click on a "agent workspace button" element with selector "[data-testid='workspace-agent']"
When I click on "new tab button and search input and agent suggestion" elements with selectors:
| element description | selector |
| new tab button | [data-tab-id='new-tab-button'] |
| search input | .aa-Input |
| agent suggestion | [data-autocomplete-source-id="agentsSource"] .aa-ItemWrapper |
When I send ask AI with selection message with text "First question" and workspace "wiki"
Then I should see a "split view container" element with selector "[data-testid='split-view-container']"
# Should see only 2 messages (new tab was created, not reused)
And I should see 2 messages in chat history
# Part 4: Verify split view doesn't interfere with regular chat
# Create another regular chat tab
When I click on "new tab button and search input and agent suggestion" elements with selectors:
| element description | selector |
| new tab button | [data-tab-id='new-tab-button'] |
| search input | .aa-Input |
| agent suggestion | [data-autocomplete-source-id="agentsSource"] .aa-ItemWrapper |
# Now in regular chat tab - split view and browser view should not be visible
Then I should not see a "split view container" element with selector "[data-testid='split-view-container']"
And I confirm the "main" window browser view is not positioned within visible window bounds
# Switch to wiki workspace - browser view should exist for wiki
When I click on a "wiki workspace button" element with selector "div[data-testid^='workspace-']:has-text('wiki')"
Then I confirm the "main" window browser view is positioned within visible window bounds