Feature: Agent Workflow - Tool Usage and Multi-Round Conversation
As a user
I want to use an intelligent agent to search wiki content
So that I can get AI-powered explanations of wiki entries
Background:
Given I add test ai settings
# Start mock OpenAI server with no rules - rules will be added per scenario
And I have started the mock OpenAI server without rules
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"
# Navigate to agent workspace for all scenarios
And I click on "agent workspace button and new tab button" elements with selectors:
| element description | selector |
| agent workspace | [data-testid='workspace-agent'] |
| new tab button | [data-tab-id='new-tab-button'] |
@agent @mockOpenAI
Scenario: Wiki-search tool usage
# Add scenario-specific responses to the mock server
Given I add mock OpenAI responses:
| response | stream |
| {"workspaceName":"-VPTqPdNOEZHGO5vkwllY","filter":"[title[Index]]"} | false |
| 在 TiddlyWiki 中,Index 条目提供了编辑卡片的方法说明,点击右上角的编辑按钮可以开始对当前卡片进行编辑。此外,它还引导您访问中文教程页面和官方英文站点以获取更多信息。 | false |
# Proceed with agent workflow in main window
# Step 1: Click new tab button
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I should see a "search interface" element with selector ".aa-Autocomplete"
# Step 2: Click search box and wait for autocomplete
When I click on a "search input box" element with selector ".aa-Input"
And I should see an "autocomplete panel" element with selector ".aa-Panel"
# Step 3: Select agent from autocomplete (not new tab)
When I click on an "agent suggestion" element with selector '[data-autocomplete-source-id="agentsSource"] .aa-ItemWrapper'
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
# Step 4: Send message to agent - using generic steps combination
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "搜索 wiki 中的 index 条目并解释" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
Then I should see 4 messages in chat history
# Verify the last message contains the AI explanation about Index
And I should see "explanation in last message and explanation about edit" elements with selectors:
| element description | selector |
| explanation in last message | [data-testid='message-bubble']:has-text('Index') |
| explanation about edit | [data-testid='message-bubble']:has-text('编辑') |
@agent @mockOpenAI
Scenario: Wiki operation
# Add scenario-specific responses to the mock server
Given I add mock OpenAI responses:
| response | stream |
| 先测试失败情况{"workspaceName":"test-expected-to-fail","operation":"wiki-add-tiddler","title":"testNote","text":"test"} | false |
| 然后测试成功情况{"workspaceName":"wiki","operation":"wiki-add-tiddler","title":"test","text":"这是测试内容"}使用启动时自动创建的 wiki 工作区 | false |
| 已成功在工作区 wiki 中创建条目 "test"。 | false |
# Step 1: Start a fresh tab and run the two-round wiki operation flow
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I should see a "search interface" element with selector ".aa-Autocomplete"
# Step 2: Click search box and wait for autocomplete
When I click on a "search input box" element with selector ".aa-Input"
And I should see an "autocomplete panel" element with selector ".aa-Panel"
# Step 3: Select agent from autocomplete (not new tab)
When I click on an "agent suggestion" element with selector '[data-autocomplete-source-id="agentsSource"] .aa-ItemWrapper'
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
# First round: try create note using test-expected-to-fail workspace (expected to fail)
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "在 wiki 里创建一个新笔记,内容为 test" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
Then I should see 6 messages in chat history
# Verify error and success messages
And I should see "workspace not exist error and success in last message and wiki workspace in last message" elements with selectors:
| element description | selector |
| workspace not exist error | [data-testid='message-bubble']:has-text('test-expected-to-fail'):has-text('不存在') |
| success in last message | [data-testid='message-bubble']:has-text('已成功') |
| wiki workspace in last message | [data-testid='message-bubble']:has-text('wiki') |
@agent @mockOpenAI
Scenario: Remote memeloop node task completes through agent workspace
Given I add mock OpenAI responses:
| response | stream |
| {"nodeId":"remote-e2e-node","definitionId":"memeloop:code-assistant","message":"Create the file remote-output/task-result.txt with content 'created by remote worker'. Then report the exact file path and content."} | false |
| {"path":"remote-output/task-result.txt","content":"created by remote worker"} | false |
| Remote worker created remote-output/task-result.txt with content "created by remote worker". | false |
| 远程 node 已完成任务,remote-output/task-result.txt 已创建,内容为 created by remote worker。 | false |
And I have prepared a cloud-discovered remote memeloop test node backed by mock OpenAI
And I click on a "settings button" element with selector "#open-preferences-button"
And I switch to "preferences" window
And I click on a "sync section" element with selector "[data-testid='preference-section-sync']"
And I click on a "open node management button" element with selector "[data-testid='preferences-sync-open-node-management']"
And I switch to "nodeManagement" window
And I should see "cloud account card and cloud URL input and cloud login button and cloud load nodes button" elements with selectors:
| element description | selector |
| cloud account card | [data-testid='node-management-cloud-account'] |
| cloud URL input | [data-testid='node-management-cloud-url-input'] |
| cloud login button | [data-testid='node-management-cloud-login'] |
| cloud load nodes button | [data-testid='node-management-cloud-load-nodes'] |
When I type "http://127.0.0.1:43115" in "cloud URL input" element with selector "[data-testid='node-management-cloud-url-input']"
And I click on a "save cloud URL button" element with selector "[data-testid='node-management-cloud-url-save']"
And I type in "cloud email input and cloud password input" elements with selectors:
| text | selector |
| cloud-e2e@example.com | [data-testid='node-management-cloud-email-input'] |
| cloud-pass-123 | [data-testid='node-management-cloud-password-input'] |
And I click on a "cloud login button" element with selector "[data-testid='node-management-cloud-login']"
And I click on a "load cloud nodes button" element with selector "[data-testid='node-management-cloud-load-nodes']"
Then I should see "discovered cloud node card and discovered cloud node connect button" elements with selectors:
| element description | selector |
| discovered cloud node card | [data-testid^='node-management-cloud-node-']:has-text('remote-e2e-node') |
| discovered cloud node connect button | [data-testid^='node-management-cloud-connect-'] |
When I click on a "discovered cloud node connect button" element with selector "[data-testid^='node-management-cloud-connect-']"
Then I should see a "pair with PIN button" element with selector "button:has-text('Pair with PIN')"
And I switch to "main" window
And I click on "new tab button and create default agent button" elements with selectors:
| element description | selector |
| new tab button | [data-tab-id='new-tab-button'] |
| create default agent button | [data-testid='create-default-agent-button'] |
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "请让远程 memeloop node 创建 remote-output/task-result.txt,并告诉我结果。" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
Then I should see 4 messages in chat history
And I should see "remote tool result and final remote summary" elements with selectors:
| element description | selector |
| remote tool result | [data-testid='message-bubble']:has-text('remote-output/task-result.txt'):has-text('created by remote worker') |
| final remote summary | [data-testid='message-bubble']:has-text('远程 node 已完成任务') |
And the remote memeloop node should have file "remote-output/task-result.txt" with content "created by remote worker"
@agent
Scenario: Create default agent from New Tab quick access
When I click on "new tab button and create default agent button" elements with selectors:
| element description | selector |
| new tab button | [data-tab-id='new-tab-button'] |
| create default agent button | [data-testid='create-default-agent-button'] |
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
@agent
Scenario: Close all tabs then create default agent from fallback page
# Ensure starting from black/fallback page with no open tabs
# Open tab list dropdown and force-click all close buttons (they have opacity: 0)
Given I click on a "tab list button" element with selector "[data-testid='tab-list-button']"
And I should see a "tab list dropdown" element with selector "[data-testid='tab-list-dropdown']"
When I click all "tab close button" elements matching selector "[data-testid^='tab-close-']"
# When there is no active tab, this is "fallback new tab", it has same thing as new tab.
And I should see "new tab button and Create Default Agent" elements with selectors:
| element description | selector |
| new tab button | [data-tab-id='new-tab-button'] |
| Create Default Agent | [data-testid='create-default-agent-button'] |
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I should see a "Create Default Agent" element with selector "[data-testid='create-default-agent-button']"
When I click on a "create default agent button" element with selector "[data-testid='create-default-agent-button']"
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
# Open dropdown again and close all tabs
When I click on a "tab list button" element with selector "[data-testid='tab-list-button']"
And I should see a "tab list dropdown" element with selector "[data-testid='tab-list-dropdown']"
Then I click all "tab close button" elements matching selector "[data-testid^='tab-close-']"
@agent @mockOpenAI
Scenario: Streamed assistant response can be cancelled mid-stream and send button returns
# Add scenario-specific responses to the mock server
Given I add mock OpenAI responses:
| response | stream |
| partial_chunk_1partial_chunk_2partial_chunk_3partial_chunk_4 | true |
And I click on "new tab button and create default agent button" elements with selectors:
| element description | selector |
| new tab button | [data-tab-id='new-tab-button'] |
| create default agent button | [data-testid='create-default-agent-button'] |
And I should see a "message input box" element with selector "[data-testid='agent-message-input']"
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "Start long streaming" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
# Wait for streaming container to appear and contain the first chunk
Then I should see "assistant streaming container and partial assistant text and cancel icon" elements with selectors:
| element description | selector |
| assistant streaming container | [data-testid='assistant-streaming-text'] |
| partial assistant text | *:has-text('partial_chunk_1') |
| cancel icon | [data-testid='cancel-icon'] |
# Click cancel button mid-stream
When I click on a "cancel button" element with selector "[data-testid='agent-send-button']"
# Verify send button returned and stream stopped (no further chunks)
Then I should see "send icon and send button" elements with selectors:
| element description | selector |
| send icon | [data-testid='send-icon'] |
| send button | [data-testid='agent-send-button']|
And I should not see a "partial chunk 4 text" element with selector "text='partial_chunk_4'"