test: reduce wait time, because most check already will wait for a while

This commit is contained in:
lin onetwo 2025-10-09 22:13:18 +08:00
parent 04c75ef1a6
commit 63a8eb9a64
6 changed files with 2 additions and 61 deletions

View file

@ -228,6 +228,7 @@ When('(Dont do this) I click on a specific button and wait for 2 seconds.', asyn
5. Streaming Support: Special handling for real-time updates in chat interfaces
6. **Don't think about adding new step definitions** or **change timeout duration**, unless human ask you to do. You should always reuse existing steps, and debug the fundamental reason that causes timeout. Timeout usually because of expected element not percent.
7. If you forget to run `pnpm run test:prepare-e2e` after modify code in `./src` folder, you may find expected elements missing.
8. Usually don't need to add wait time, because most check already will wait for a while. Even add wait, can't be more than 0.2s.
## Testing Library Best Practices

View file

@ -32,7 +32,6 @@ Feature: Agent Workflow - Tool Usage and Multi-Round Conversation
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
And I wait for 0.2 seconds
Then I should see 4 messages in chat history
# Verify the last message contains the AI explanation about Index
And I should see a "explanation in last message" element with selector "[data-testid='message-bubble']:last-child:has-text('Index')"
@ -58,7 +57,6 @@ Feature: Agent Workflow - Tool Usage and Multi-Round Conversation
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
And I wait for 0.2 seconds
Then I should see 6 messages in chat history
# Verify there's an error message about workspace not found (in one of the middle messages)
And I should see a "workspace not exist error" element with selector "[data-testid='message-bubble']:has-text('default'):has-text('')"
@ -69,7 +67,6 @@ Feature: Agent Workflow - Tool Usage and Multi-Round Conversation
@agent
Scenario: Create default agent from New Tab quick access
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I wait for 0.2 seconds
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']"
@ -78,15 +75,12 @@ Feature: Agent Workflow - Tool Usage and Multi-Round Conversation
Scenario: Close all tabs then create default agent from fallback page
# Ensure starting from black/fallback page with no open tabs
Given I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I wait for 0.2 seconds
When I click all "tab" elements matching selector "[data-testid='tab']"
When I click all "close tab button" elements matching selector "[data-testid='tab-close-button']"
And I wait for 0.2 seconds
And I should see a "new tab button" element with selector "[data-tab-id='new-tab-button']"
# When there is no active tab, this is "fallback new tab", it has same thing as new tab.
And I should see a "Create Default Agent" element with selector "[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 wait for 0.2 seconds
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']"
@ -102,16 +96,13 @@ Feature: Agent Workflow - Tool Usage and Multi-Round Conversation
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 wait for 0.3 seconds
And I press "Enter" key
# Wait for streaming container to appear and contain the first chunk
Then I should see a "assistant streaming container" element with selector "[data-testid='assistant-streaming-text']"
And I wait for 0.2 seconds
Then I should see a "partial assistant text" element with selector "*:has-text('partial_chunk_1')"
And I should see a "cancel icon" element with selector "[data-testid='cancel-icon']"
# Click cancel button mid-stream
When I click on a "cancel button" element with selector "[data-testid='agent-send-button']"
And I wait for 0.2 seconds
And I should see a "send icon" element with selector "[data-testid='send-icon']"
# Verify send button returned and stream stopped (no further chunks)
Then I should see a "send button" element with selector "[data-testid='agent-send-button']"

View file

@ -9,7 +9,6 @@ Feature: TidGi Default Wiki
# cross-env NODE_ENV=test pnpm dlx tsx scripts/developmentMkdir.ts
Given I cleanup test wiki
When I launch the TidGi application
And I wait for 0.5 seconds
And I wait for the page to load completely
And I should see a "page body" element with selector "body"
And the window title should contain ""

View file

@ -20,9 +20,7 @@ Feature: Create New Agent Workflow
| | false |
# Step 1: Open new tab and navigate to CreateNewAgent
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I wait for 0.2 seconds
When I click on a "create new agent button" element with selector "[data-testid='create-new-agent-button']"
And I wait for 0.1 seconds
# Step 2: Verify first step content (Setup Agent: Name + Template)
And I should see a "step title" element with selector "*:has-text('')"
And I should see a "search input" element with selector ".aa-Input"
@ -31,17 +29,14 @@ Feature: Create New Agent Workflow
When I click on a "search input" element with selector ".aa-Input"
And I should see an "autocomplete panel" element with selector ".aa-Panel"
When I click on a "agent suggestion" element with selector '[data-autocomplete-source-id="templateAgentsSource"] .aa-ItemWrapper'
And I wait for 0.2 seconds
# Fill in agent name while still in step 1
When I clear text in "agent name input" element with selector "[data-testid='agent-name-input-field']"
When I type "" in "agent name input" element with selector "[data-testid='agent-name-input-field']"
# Advance to step 2 (Edit Prompt)
When I click on a "next button" element with selector "[data-testid='next-button']"
And I wait for 0.2 seconds
# Step 4: Verify second step content (Edit Prompt)
And I should see a "edit prompt title" element with selector "*:has-text('')"
# Step 4.1: Wait for PromptConfigForm to load
And I wait for 0.2 seconds
# Verify the PromptConfigForm is present with our new test id
And I should see a "prompt config form" element with selector "[data-testid='prompt-config-form']"
# Step 4.2: Navigate to the correct tab and expand array items to edit prompt
@ -49,32 +44,28 @@ Feature: Create New Agent Workflow
And I should see a "config tabs" element with selector "[data-testid='prompt-config-form'] .MuiTabs-root"
# Click on the first tab (which should contain the system prompt)
When I click on a "first config tab" element with selector "[data-testid='prompt-config-form'] .MuiTab-root:first-of-type"
And I wait for 0.2 seconds
# Step 4.3: Expand the first array item (prompt item) by clicking the expand button
When I click on a "expand array item button" element with selector "[data-testid='prompt-config-form'] [role='tabpanel']:not([hidden]) button[title*=''], [data-testid='prompt-config-form'] [role='tabpanel']:not([hidden]) button svg[data-testid='ExpandMoreIcon']"
And I wait for 0.2 seconds
# Step 4.4: Now find and edit the system prompt text field (textarea)
When I click on a "system prompt text field" element with selector "[data-testid='prompt-config-form'] [role='tabpanel']:not([hidden]) textarea[id*='_text']:not([readonly])"
When I clear text in "system prompt text field" element with selector "[data-testid='prompt-config-form'] [role='tabpanel']:not([hidden]) textarea[id*='_text']:not([readonly])"
When I type "" in "system prompt text field" element with selector "[data-testid='prompt-config-form'] [role='tabpanel']:not([hidden]) textarea[id*='_text']:not([readonly])"
# Wait for form content save to backend
And I wait for 0.2 seconds
# Step 5: Advance to step 3 (Immediate Use)
When I click on a "next button" element with selector "[data-testid='next-button']"
And I wait for 0.2 seconds
# Step 6: Verify third step content (Immediate Use with chat interface)
And I should see a "immediate use title" element with selector "*:has-text('使')"
# Step 7: Test in the preview chat interface (part of step 3)
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " Hello World" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 0.1 seconds
# Verify the agent responds in the preview interface
Then I should see a "user message" element with selector "*:has-text(' Hello World')"
And I should see a "assistant message" element with selector "*:has-text('')"
And the last AI request should contain system prompt ""
# Step 8: Save and start using (after testing in step 3)
When I click on a "save and use button" element with selector "button:has-text('使')"
And I wait for 0.1 seconds
# Verify agent was created and separate chat tab opened
Then I should see a "message input box" element with selector "[data-testid='agent-message-input']"
@ -86,24 +77,19 @@ Feature: Create New Agent Workflow
| | false |
# Step 1: Open new tab to access create default agent card
When I click on a "new tab button" element with selector "[data-tab-id='new-tab-button']"
And I wait for 0.2 seconds
# Step 2: Right-click on create default agent card to open context menu
When I right-click on a "create default agent card" element with selector "[data-testid='create-default-agent-button']"
And I wait for 0.1 seconds
# Step 3: Click on edit definition option in context menu
When I click on a "edit definition menu item" element with selector "[data-testid='edit-definition-menu-item']"
And I wait for 0.2 seconds
# Step 4: Verify direct edit interface (no steps - all content visible)
And I should see a "edit agent title" element with selector "*:has-text('')"
And I should see a "basic info section" element with selector "*:has-text('')"
And I should see a "edit prompt section" element with selector "*:has-text('')"
And I should see a "immediate use section" element with selector "*:has-text('使')"
And I wait for 0.1 seconds
# Step 5: Edit agent name in the basic info section
And I should see a "agent name input" element with selector "[data-testid='edit-agent-name-input']"
When I clear text in "agent name input" element with selector "[data-testid='edit-agent-name-input-field']"
When I type "" in "agent name input" element with selector "[data-testid='edit-agent-name-input-field']"
And I wait for 0.1 seconds
# Step 6: Edit the prompt configuration - Wait for PromptConfigForm to load
# Verify the PromptConfigForm is present
And I should see a "prompt config form" element with selector "[data-testid='edit-agent-prompt-form']"
@ -112,22 +98,18 @@ Feature: Create New Agent Workflow
And I should see a "config tabs" element with selector "[data-testid='edit-agent-prompt-form'] .MuiTabs-root"
# Click on the first tab (which should contain the system prompt)
When I click on a "first config tab" element with selector "[data-testid='edit-agent-prompt-form'] .MuiTab-root:first-of-type"
And I wait for 0.1 seconds
# Step 6.2: Expand the first array item (prompt item) by clicking the expand button
When I click on a "expand array item button" element with selector "[data-testid='edit-agent-prompt-form'] [role='tabpanel']:not([hidden]) button[title*=''], [data-testid='edit-agent-prompt-form'] [role='tabpanel']:not([hidden]) button svg[data-testid='ExpandMoreIcon']"
And I wait for 0.1 seconds
# Step 6.3: Now find and edit the system prompt text field (textarea)
When I click on a "system prompt text field" element with selector "[data-testid='edit-agent-prompt-form'] [role='tabpanel']:not([hidden]) textarea[id*='_text']:not([readonly])"
When I clear text in "system prompt text field" element with selector "[data-testid='edit-agent-prompt-form'] [role='tabpanel']:not([hidden]) textarea[id*='_text']:not([readonly])"
When I type "" in "system prompt text field" element with selector "[data-testid='edit-agent-prompt-form'] [role='tabpanel']:not([hidden]) textarea[id*='_text']:not([readonly])"
And I wait for 0.1 seconds
# Step 7: Test in the immediate use section (embedded chat)
# The immediate use section should show an embedded chat interface
# Find a message input in the immediate use section and test the agent
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 0.1 seconds
# Verify the agent responds in the embedded chat
Then I should see a "user message" element with selector "*:has-text('')"
And I should see a "assistant message" element with selector "*:has-text('')"
@ -136,4 +118,3 @@ Feature: Create New Agent Workflow
# Step 8: Save the edited agent definition
And I should see a "save button" element with selector "[data-testid='edit-agent-save-button']"
When I click on a "save button" element with selector "[data-testid='edit-agent-save-button']"
And I wait for 0.2 seconds

View file

@ -13,7 +13,6 @@ Feature: TidGi Preference
Scenario: Configure AI provider and default model
# Step 1: Configure AI settings first - Open preferences window, wait a second so its URL settle down.
When I click on a "settings button" element with selector "#open-preferences-button"
And I wait for 0.2 seconds
When I switch to "preferences" window
# Step 2: Navigate to External Services section (wait for sidebar animation)
When I click on an "external services section" element with selector "[data-testid='preference-section-externalAPI']"
@ -23,31 +22,24 @@ Feature: TidGi Preference
When I type "TestProvider" in "provider name input" element with selector "[data-testid='new-provider-name-input']"
And I type "http://127.0.0.1:15121/v1" in "API endpoint input" element with selector "[data-testid='new-provider-base-url-input']"
When I click on an "add provider submit" element with selector "[data-testid='add-provider-submit-button']"
And I wait for 0.2 seconds
# Step 5: Select the new provider and add a model
When I click on a "provider tab" element with selector "button[role='tab']:has-text('TestProvider')"
When I click on an "add model button" element with selector "[data-testid='add-new-model-button']"
And I wait for 0.2 seconds
# Step 6: Add language model (will auto-fill as default language model)
When I type "test-model" in "model name input" element with selector "[data-testid='new-model-name-input']"
When I click on a "save model button" element with selector "[data-testid='save-model-button']"
And I wait for 0.2 seconds
# Step 7: Add embedding model (will auto-fill as default embedding model)
When I click on an "add model button" element with selector "[data-testid='add-new-model-button']"
And I wait for 0.2 seconds
When I type "test-embedding-model" in "model name input" element with selector "[data-testid='new-model-name-input']"
When I click on a "embedding feature checkbox" element with selector "[data-testid='feature-checkbox-embedding']"
When I click on a "save model button" element with selector "[data-testid='save-model-button']"
And I wait for 0.2 seconds
# Step 8: Add speech model (will auto-fill as default speech model)
When I click on an "add model button" element with selector "[data-testid='add-new-model-button']"
And I wait for 0.2 seconds
When I type "test-speech-model" in "model name input" element with selector "[data-testid='new-model-name-input']"
# Uncheck language feature first (it's checked by default)
When I click on a "language feature checkbox" element with selector "[data-testid='feature-checkbox-language']"
When I click on a "speech feature checkbox" element with selector "[data-testid='feature-checkbox-speech']"
When I click on a "save model button" element with selector "[data-testid='save-model-button']"
And I wait for 0.2 seconds
# Step 9: Verify auto-fill worked by checking that autocomplete inputs have the correct selected values
# MUI Autocomplete shows selected value in the input, we check by looking for the model name in the visible text
Then I should see a "default language model value test-model" element with selector "text='test-model'"
@ -65,28 +57,21 @@ Feature: TidGi Preference
Then I should see a "third autocomplete input with test-speech-model" element with selector "xpath=(//div[contains(@class,'MuiAutocomplete-root')]//input[@value='test-speech-model'])[1]"
# Step 10: Add ComfyUI provider with workflow path
When I click on an "add provider button" element with selector "[data-testid='add-new-provider-button']"
And I wait for 0.2 seconds
When I click on a "select from preset dropdown" element with selector "div[role='combobox']"
When I click on a "comfyui preset option" element with selector "li:has-text('comfyui')"
When I click on an "add provider submit" element with selector "[data-testid='add-provider-submit-button']"
And I wait for 0.2 seconds
When I click on a "provider tab" element with selector "button[role='tab']:has-text('comfyui')"
When I click on an "add model button" element with selector "[data-testid='add-new-model-button']"
And I wait for 0.2 seconds
When I type "test-flux" in "model name input" element with selector "[data-testid='new-model-name-input']"
When I click on a "language feature checkbox" element with selector "[data-testid='feature-checkbox-language']"
When I click on a "imageGeneration feature checkbox" element with selector "[data-testid='feature-checkbox-imageGeneration']"
When I type "C:/test/mock/workflow.json" in "workflow path input" element with selector "[data-testid='workflow-path-input']"
When I click on a "save model button" element with selector "[data-testid='save-model-button']"
And I wait for 0.2 seconds
Then I should see a "test-flux model chip" element with selector "[data-testid='model-chip-test-flux']"
# Verify workflow path was saved by clicking to edit
When I click on a "test-flux model chip" element with selector "[data-testid='model-chip-test-flux']"
And I wait for 0.2 seconds
Then I should see a "workflow path input with value" element with selector "[data-testid='workflow-path-input'][value='C:/test/mock/workflow.json']"
When I press "Escape" key
And I wait for 0.1 seconds
# Step 11: Close preferences window
When I close "preferences" window
And I wait for 0.1 seconds
And I ensure test ai settings exists

View file

@ -38,25 +38,21 @@ Feature: Vector Search - Embedding Generation and Semantic Search
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " wiki AI Agent Guide AI使" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 1 seconds
Then I should see 4 messages in chat history
# Step 3: Create second note
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " Vector Database Tutorial " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 1 seconds
Then I should see 8 messages in chat history
# Step 4: Update vector embeddings using agent tool
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " wiki " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 2 seconds
Then I should see 12 messages in chat history
# Step 5: Perform vector search
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "使 wiki 使AI" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 1 seconds
Then I should see 16 messages in chat history
# Verify the last message contains vector search results
And I should see a "search result in last message" element with selector "[data-testid='message-bubble']:last-child:has-text('Tiddler: AI Agent Guide')"
@ -78,22 +74,18 @@ Feature: Vector Search - Embedding Generation and Semantic Search
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " wiki Machine Learning Basics " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 1 seconds
Then I should see 4 messages in chat history
# Step 2: Open preferences and manually generate embeddings via UI
When I click on a "settings button" element with selector "#open-preferences-button"
And I wait for 0.3 seconds
When I switch to "preferences" window
# Navigate to Search section (which contains vector database settings)
When I click on a "search section" element with selector "[data-testid='preference-section-search']"
And I wait for 0.2 seconds
# Wait for workspace list to load
# The Search.tsx renders workspace cards with name, status, and buttons
And I should see a "wiki workspace card" element with selector "*:has-text('wiki')"
# Click the generate button - use button text "生成" instead of data-testid
# The button shows "生成" for initial generation, "更新嵌入" after generation
When I click on a "generate button with text" element with selector "button:has-text('')"
And I wait for 0.5 seconds
# Verify generation completed with detailed status information
# Should show: workspace name, embedding count, note count, last updated time
And I should see a "workspace name in status" element with selector "*:has-text('wiki')"
@ -108,14 +100,11 @@ Feature: Vector Search - Embedding Generation and Semantic Search
And I should see a "delete button after generation" element with selector "button:has-text('')"
# Close preferences
When I close "preferences" window
And I wait for 0.2 seconds
And I switch to "main" window
And I wait for 0.2 seconds
# Step 3: Perform vector search and verify results match agent workflow
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "使 wiki " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 1 seconds
Then I should see 8 messages in chat history
# Verify the last message contains vector search results
And I should see a "ML search result in last message" element with selector "[data-testid='message-bubble']:last-child:has-text('Tiddler: Machine Learning Basics')"
@ -146,28 +135,24 @@ Feature: Vector Search - Embedding Generation and Semantic Search
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " wiki AI Technology " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 0.5 seconds
Then I should see 4 messages in chat history
# Step 3: Create second note about ML
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " Machine Learning " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 0.5 seconds
Then I should see 8 messages in chat history
# Step 4: Update vector embeddings
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type " wiki " in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 2 seconds
Then I should see 12 messages in chat history
# Step 5: Search for unrelated content with high threshold (should find nothing)
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "使 wiki 0.7" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 0.5 seconds
Then I should see 16 messages in chat history
# Verify the 16th message contains "no results found" with threshold info
And I should see a "no results in 16th message" element with selector "[data-testid='message-bubble']:nth-child(16):has-text('')"
@ -177,7 +162,6 @@ Feature: Vector Search - Embedding Generation and Semantic Search
When I click on a "message input textarea" element with selector "[data-testid='agent-message-input']"
When I type "0.1" in "chat input" element with selector "[data-testid='agent-message-input']"
And I press "Enter" key
And I wait for 1 seconds
Then I should see 20 messages in chat history
# Verify the 20th message contains low-similarity result
And I should see a "AI Technology in 20th message" element with selector "[data-testid='message-bubble']:nth-child(20):has-text('Tiddler: AI Technology')"