test: add test id to frozen icon and streamline freeze functionality test#8619
Conversation
…onent for improved testing
…eractions and enhancing test clarity - Removed unnecessary component interactions and waits to streamline the test flow. - Updated assertions to ensure expected output values are validated correctly. - Improved timeout settings for better reliability in test execution.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA test identifier was added to the frozen icon in the frontend, and the freeze functionality test was streamlined. The test now focuses on freezing a single text input component and verifying output consistency, with unnecessary steps and interactions removed for simplicity. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant NodeComponent
participant Modal
User->>UI: Add "text input" component
User->>NodeComponent: Enter "hello world"
User->>UI: Inspect output
UI->>NodeComponent: Capture initial output
User->>NodeComponent: Change input to "goodbye world"
User->>UI: Open options modal
User->>Modal: Click "Freeze All"
Modal->>NodeComponent: Freeze node
UI->>NodeComponent: Wait for frozen icon
UI->>NodeComponent: Verify output unchanged
✨ Finishing Touches🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/frontend/tests/core/features/freeze.spec.ts (1)
65-69: Minor: preferexpect(locator).toBeVisible()overwaitForSelector
waitForSelectoris fine, but Playwright’sexpect(locator).toBeVisible()provides built-in waiting and clearer intent.No action required if the current pattern is consistent across the suite.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx(1 hunks)src/frontend/tests/core/features/freeze.spec.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: autofix
🔇 Additional comments (1)
src/frontend/src/CustomNodes/GenericNode/components/NodeOutputfield/index.tsx (1)
359-362:data-testidaddition looks good and is non-intrusiveThe attribute provides a stable selector for the tests without affecting runtime logic or styling. Naming is consistent with the other
data-testidvalues in this component.
| await page.getByTestId("output-inspection-output text-textinput").click(); | ||
|
|
||
| //fourth component | ||
|
|
||
| await page.getByTestId("sidebar-search-input").click(); | ||
| await page.getByTestId("sidebar-search-input").fill("Parser"); | ||
| await page.waitForSelector('[data-testid="processingParser"]', { | ||
| timeout: 1000, | ||
| }); | ||
|
|
||
| await page | ||
| .getByTestId("processingParser") | ||
| .dragTo(page.locator('//*[@id="react-flow-id"]'), { | ||
| targetPosition: { x: 50, y: 300 }, | ||
| }); | ||
|
|
||
| await page.getByTestId("zoom_out").click(); | ||
|
|
||
| //fifth component | ||
|
|
||
| await page.getByTestId("sidebar-search-input").click(); | ||
| await page.getByTestId("sidebar-search-input").fill("chat output"); | ||
| await page.waitForSelector('[data-testid="input_outputChat Output"]', { | ||
| timeout: 1000, | ||
| }); | ||
|
|
||
| await page | ||
| .getByTestId("input_outputChat Output") | ||
| .dragTo(page.locator('//*[@id="react-flow-id"]'), { | ||
| targetPosition: { x: 600, y: 200 }, | ||
| }); | ||
|
|
||
| await page.getByTestId("div-generic-node").nth(4).click(); | ||
|
|
||
| await page.getByTestId("more-options-modal").click(); | ||
|
|
||
| await page.getByTestId("expand-button-modal").click(); | ||
|
|
||
| await page.getByTestId("fit_view").click(); | ||
|
|
||
| let outdatedComponents = await page.getByTestId("update-button").count(); | ||
|
|
||
| while (outdatedComponents > 0) { | ||
| await page.getByTestId("update-button").first().click(); | ||
| await page.waitForSelector('[data-testid="update-button"]', { | ||
| timeout: 1000, | ||
| }); | ||
| outdatedComponents = await page.getByTestId("update-button").count(); | ||
| } | ||
|
|
||
| let filledApiKey = await page.getByTestId("remove-icon-badge").count(); | ||
| while (filledApiKey > 0) { | ||
| await page.getByTestId("remove-icon-badge").first().click(); | ||
| filledApiKey = await page.getByTestId("remove-icon-badge").count(); | ||
| } | ||
|
|
||
| await page.getByTestId("fit_view").click(); | ||
| await zoomOut(page, 2); | ||
|
|
||
| //connection 1 | ||
| await page | ||
| .getByTestId("handle-urlcomponent-shownode-extracted pages-right") | ||
| .nth(0) | ||
| .click(); | ||
| await page | ||
| .getByTestId("handle-splittext-shownode-data or dataframe-left") | ||
| .click(); | ||
|
|
||
| //connection 2 | ||
| await page | ||
| .getByTestId("handle-textinput-shownode-output text-right") | ||
| .nth(0) | ||
| .click(); | ||
| await page.getByTestId("handle-splittext-shownode-separator-left").click(); | ||
|
|
||
| //connection 3 | ||
| await page | ||
| .getByTestId("handle-splittext-shownode-chunks-right") | ||
| .nth(0) | ||
| .click(); | ||
| await page | ||
| .getByTestId("handle-parsercomponent-shownode-data or dataframe-left") | ||
| .click(); | ||
|
|
||
| //connection 4 | ||
| await page | ||
| .getByTestId("handle-parsercomponent-shownode-parsed text-right") | ||
| .nth(0) | ||
| .click(); | ||
| await page.getByTestId("handle-chatoutput-shownode-inputs-left").click(); | ||
|
|
||
| await page | ||
| .getByTestId("textarea_str_input_value") | ||
| .first() | ||
| .fill("lorem ipsum"); | ||
|
|
||
| await page | ||
| .getByTestId("inputlist_str_urls_0") | ||
| .fill("https://www.lipsum.com/feed/html"); | ||
|
|
||
| await runChatOutput(page); | ||
|
|
||
| await page.waitForSelector("text=built successfully", { | ||
| timeout: 30000 * 3, | ||
| }); | ||
|
|
||
| await page.waitForSelector( | ||
| '[data-testid="output-inspection-output message-chatoutput"]', | ||
| { | ||
| timeout: 1000, | ||
| }, | ||
| ); | ||
|
|
||
| await page | ||
| .getByTestId("output-inspection-output message-chatoutput") | ||
| .first() | ||
| .click(); | ||
|
|
||
| const firstRunWithoutFreezing = await page | ||
| .getByPlaceholder("Empty") | ||
| .textContent(); | ||
| const firstOutputText = await page.getByPlaceholder("Empty").textContent(); | ||
|
|
There was a problem hiding this comment.
Reading the output with .textContent() is unreliable for <textarea> – use .inputValue() instead
Locator.textContent() returns null for form controls (e.g. <textarea>, <input>), so the assertions will always fail or compare null/"". Switch to inputValue() (or evaluate(el => el.value)) which is guaranteed to return the control’s value.
-const firstOutputText = await page.getByPlaceholder("Empty").textContent();
+const firstOutputText = await page.getByPlaceholder("Empty").inputValue();
...
-const secondOutputText = await page.getByPlaceholder("Empty").textContent();
+const secondOutputText = await page.getByPlaceholder("Empty").inputValue();Also applies to: 76-79
🤖 Prompt for AI Agents
In src/frontend/tests/core/features/freeze.spec.ts around lines 45 to 48 and
also lines 76 to 79, the code uses textContent() to read the value of a
textarea, which returns null and causes assertions to fail. Replace all
instances of textContent() used on form controls like textarea or input with
inputValue() to reliably get their current value for assertions.
…ector for improved test reliability - Updated the test to use waitForSelector instead of a fixed timeout, enhancing the robustness of the test execution. - This change aims to ensure that the test waits for the specific element to be present before proceeding, reducing flakiness.
…itForSelector for improved test reliability" This reverts commit 42eccbf.
…ze button for better testing 🐛 (freeze.spec.ts): update test to use new data-testid for freeze button to ensure proper element selection
…hot when freezing all vertices in the flow.
…to ensure user can freeze components in the application and verify the frozen state with polling approach for better error handling.
…o use waitForSelector for improved reliability and error handling, replacing the previous polling approach.
…eliability and stability
…lication to ensure the functionality works as expected
Summary by CodeRabbit