Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add tests for dynamic parameters#18679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jaaydenh merged 20 commits intomainfromjaaydenh/dynamic-parameters-tests
Aug 11, 2025

Conversation

jaaydenh
Copy link
Contributor

@jaaydenhjaaydenh commentedJun 30, 2025
edited by coderabbitaibot
Loading

Summary by CodeRabbit

  • New Features

    • Added support for a new testing attribute to the multi-select combobox component, improving testability.
    • Expanded mock data for dynamic parameters, covering a wider range of input types and validation scenarios.
  • Bug Fixes

    • Improved loader and error handling on the experimental workspace creation page to better display WebSocket errors.
  • Tests

    • Introduced comprehensive tests for the experimental workspace creation page, including dynamic parameter updates, error handling, and form submission scenarios.

@jaaydenhjaaydenh self-assigned thisJun 30, 2025
@jaaydenhjaaydenh changed the titlefeat: initial commitfeat: add tests for dynamic parametersJun 30, 2025
@jaaydenhjaaydenhforce-pushed thejaaydenh/dynamic-parameters-tests branch from82e1666 to3d3ccc3CompareJuly 3, 2025 17:16
@jaaydenhjaaydenh requested a review fromEmyrkJuly 3, 2025 21:23
@jaaydenhjaaydenh marked this pull request as ready for reviewJuly 3, 2025 21:23
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJul 11, 2025
@Kira-PilotKira-Pilot requested review froma team andBrunoQuaresma and removed request fora team andEmyrkJuly 17, 2025 19:01
<title>{pageTitle(title)}</title>
</Helmet>
{!latestResponse||
{(!latestResponse&&!wsError)||
Copy link
Member

@Kira-PilotKira-PilotJul 17, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is an actual fix, right? Also, should we not guard against rendering if either one of these conditions is missing (regardless of whether they're missing together)?

Lastly, this boolean logic is getting difficult to reason about; I wonder if it's time to pull into a distinct boolean.

aslilac reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yes, this just makes things a bit more specific to only wait for the latestResponse if there is not a websocket error.

@Kira-Pilot
Copy link
Member

I think a 1000+ LOC testing PR is difficult to review thoroughly. Your websocket mock could be a PR by itself, as could your fixtures in theentities.ts. I would prefer to see this chunked up.

@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelJul 18, 2025
@jaaydenh
Copy link
ContributorAuthor

@CodeRabbit review

coderabbitai[bot] reacted with eyes emoji

@coderabbitaicoderabbitai
Copy link

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitaicoderabbitai
Copy link

coderabbitaibot commentedJul 21, 2025
edited
Loading

Walkthrough

The changes introduce a newdata-testid prop to theMultiSelectCombobox component for improved testability and update its usage in dynamic parameter forms. A comprehensive test suite for the experimental workspace creation page is added, including extensive mock data for various parameter types. Loader rendering logic is refined, and test helpers are expanded with detailed mock parameters.

Changes

File(s)Change Summary
site/src/components/MultiSelectCombobox/MultiSelectCombobox.tsxAdded optionaldata-testid prop toMultiSelectComboboxProps and passed it to the root element for testing purposes.
site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsxSet explicitinputProps={{ id: id }} and addeddata-testid attribute toMultiSelectCombobox for multi-select parameter fields.
site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsxAdded a comprehensive test suite for the experimental workspace creation page, including custom WebSocket mocks, UI interaction tests, validation, error handling, and navigation coverage.
site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsxRefactored loader display logic into a single booleanshouldShowLoader consolidating multiple loading and error conditions for cleaner rendering control.
site/src/testHelpers/entities.tsRefactored and expanded mockPreviewParameter data: added new mock parameters for dropdown, tag-select, switch, slider, multi-select, and validation scenarios, with comprehensive fields for each.

Sequence Diagram(s)

sequenceDiagram    participant User    participant TestSuite    participant MockWebSocket    participant CreateWorkspacePageExperimental    User->>TestSuite: Run test    TestSuite->>MockWebSocket: Create mock connection    MockWebSocket->>CreateWorkspacePageExperimental: Simulate open event    CreateWorkspacePageExperimental->>MockWebSocket: Listen for messages    MockWebSocket->>CreateWorkspacePageExperimental: Send dynamic parameter data    User->>CreateWorkspacePageExperimental: Interact with form fields    CreateWorkspacePageExperimental->>MockWebSocket: Send parameter updates    MockWebSocket->>CreateWorkspacePageExperimental: Simulate error/close events    CreateWorkspacePageExperimental->>TestSuite: Render error or loader based on wsError/latestResponse    User->>CreateWorkspacePageExperimental: Submit form    CreateWorkspacePageExperimental->>TestSuite: Navigate or display errors
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~90 minutes

Poem

In the garden of code, a new test suite grows,
With mock websockets and data that flows.
Comboboxes now boast a test ID,
Dynamic forms dance in full harmony.
Mock parameters bloom, each with their own flair—
A rabbit reviewer hops, finding bugs rare! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between39fda2f andba8794d.

📒 Files selected for processing (2)
  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx (1 hunks)
  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx
🧰 Additional context used
📓 Path-based instructions (4)
site/**/*.tsx

📄 CodeRabbit Inference Engine (.cursorrules)

All user-facing frontend code is developed in TypeScript using React and lives in thesite/ directory.

Files:

  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx
site/src/**/*.test.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursorrules)

React components and pages are organized in thesite/src/ directory, with Jest used for testing.

Files:

  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx
site/src/**/*.tsx

📄 CodeRabbit Inference Engine (site/CLAUDE.md)

site/src/**/*.tsx: MUI components are deprecated - migrate away from these when encountered
Use shadcn/ui components first - check site/src/components for existing implementations
Emotion CSS is deprecated. Use Tailwind CSS instead.
Responsive design - use Tailwind's responsive prefixes (sm:, md:, lg:, xl:)
Do not usedark: prefix for dark mode
Group related Tailwind classes
Prefer Tailwind utilities over custom CSS when possible
Use Tailwind classes for all new styling
Replace Emotioncss prop with Tailwind classes
Leverage custom color tokens: content-primary, surface-secondary, etc.
Use className with clsx for conditional styling
Don’t call component functions directly; render them via JSX. This keeps Hook rules intact and lets React optimize reconciliation.
After calling a setter you’ll still read the previous state during the same event; updates are queued and batched.
Use functional updates (setX(prev ⇒ …)) whenever next state depends on previous state.
Pass a function to useState(initialFn) for lazy initialization—it runs only on the first render.
If the next state is Object.is-equal to the current one, React skips the re-render.
An Effect takes a setup function and optional cleanup; React runs setup after commit, cleanup before the next setup or on unmount.
The dependency array must list every reactive value referenced inside the Effect, and its length must stay constant.
Effects run only on the client, never during server rendering.
Use Effects solely to synchronize with external systems; if you’re not “escaping React,” you probably don’t need one.
Every sibling element in a list needs a stable, unique key prop. Never use array indexes or Math.random(); prefer data-driven IDs.
Keys aren’t passed to children and must not change between renders; if you return multiple nodes per item, use
useRef stores a mutable .current without causing re-renders.
Avoid reading or mutating refs during render; access them in event handlers or Effects ...

Files:

  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx
site/src/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (site/CLAUDE.md)

site/src/**/*.{ts,tsx}: Use ES modules (import/export) syntax, not CommonJS (require)
Destructure imports when possible (eg. import { foo } from 'bar')
Preferfor...of overforEach for iteration
Components and custom Hooks must be pure and idempotent—same inputs → same output; move side-effects to event handlers or Effects.
Never mutate props, state, or values returned by Hooks. Always create new objects or use the setter from useState.
Only call Hooks at the top level of a function component or another custom Hook—never in loops, conditions, nested functions, or try / catch.
Only call Hooks from React functions. Regular JS functions, classes, event handlers, useMemo, etc. are off-limits.
Never pass Hooks around as values or mutate them dynamically. Keep Hook usage static and local to each component.
Don’t call Hooks (including useRef) inside loops, conditions, or map(). Extract a child component instead.

Files:

  • site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx
🧠 Learnings (2)
📓 Common learnings
Learnt from: CRPR: coder/coder#0File: .cursorrules:0-0Timestamp: 2025-07-21T14:32:43.035ZLearning: Applies to site/src/**/*.test.{ts,tsx,js,jsx} : React components and pages are organized in the `site/src/` directory, with Jest used for testing.
Learnt from: CRPR: coder/coder#0File: .cursorrules:0-0Timestamp: 2025-07-21T14:32:43.035ZLearning: Applies to coderdenttest/**/* : Enterprise features have dedicated test utilities in the `coderdenttest` package.
site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx (6)

Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.035Z
Learning: Applies to site/src/**/*.test.{ts,tsx,js,jsx} : React components and pages are organized in thesite/src/ directory, with Jest used for testing.

Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.034Z
Learning: Applies to site/**/*.tsx : All user-facing frontend code is developed in TypeScript using React and lives in thesite/ directory.

Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.919Z
Learning: Applies to site/src/**/*.{ts,tsx} : Use ES modules (import/export) syntax, not CommonJS (require)

Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.034Z
Learning: Applies to site/**/*.ts : All user-facing frontend code is developed in TypeScript using React and lives in thesite/ directory.

Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.919Z
Learning: Applies to site/src/**/*.tsx : After calling a setter you’ll still read the previous state during the same event; updates are queued and batched.

Learnt from: CR
PR: coder/coder#0
File: site/CLAUDE.md:0-0
Timestamp: 2025-07-21T14:33:50.919Z
Learning: Applies to site/src/**/*.tsx : Avoid reading or mutating refs during render; access them in event handlers or Effects after commit.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test-e2e
  • GitHub Check: chromatic
  • GitHub Check: lint
  • GitHub Check: gen
🔇 Additional comments (8)
site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.test.tsx (8)

1-23:Well-structured imports following ES modules best practices.

The imports are properly organized with clear separation between testing utilities, API types, mock data, and the component under test. Good use of destructuring and TypeScript type imports.


25-34:Clear and purposeful type definitions for WebSocket mocking.

The type definitions provide a clean interface for the WebSocket mock functionality with appropriate type safety.


160-185:Well-structured mock data for comprehensive testing scenarios.

The mock responses cover both success and error cases with realistic data structures that match the API schema.


187-246:Excellent test setup with proper mocking and cleanup.

The test setup follows best practices with comprehensive API mocking, proper WebSocket mock configuration, and clean resource management in the afterEach hook.


418-506:Comprehensive testing of dynamic parameter types.

The tests thoroughly cover different parameter types (dropdown, slider, switch, tag input, multi-select) with proper assertions and user interactions. The multi-select test correctly uses thedata-testid attribute for element selection.


541-644:Excellent validation error testing with realistic scenarios.

The validation tests cover both general diagnostic errors and specific min/max constraint violations with proper error message assertions and visual styling verification.


647-801:Thorough coverage of external authentication and URL parameter handling.

The tests properly cover external auth states, auto-creation prevention, fallback modes, and custom template version handling with appropriate assertions.


731-849:Well-implemented form submission and navigation tests.

The tests verify complete workflows including form submission with correct parameter values and proper navigation after workspace creation. Good use of router state verification.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branchjaaydenh/dynamic-parameters-tests

🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on oursupport 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as off-topic.

Copy link
Member

@aslilacaslilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

looking good!

some of the smaller rendering focused tests seem like they might be better off as storybook tests tho (and that might be a good opportunity to split this pr up just a little further as well)

other than that, mostly small comments. just gonna wait until michael's websocket pr is finalized and merged to give the stamp.

Comment on lines +277 to +282
constshouldShowLoader=
!templateQuery.data||
isLoadingFormData||
isLoadingExternalAuth||
autoCreateReady||
(!latestResponse&&!wsError);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this expression still hurts my head, but thank you for moving it to a variable!

jaaydenh reacted with thumbs up emoji
Parkreiner added a commit that referenced this pull requestAug 7, 2025
Needed for#19126 and#18679## Changes made- Moved `createWebSocket` to dedicated file and addressed edge cases formaking it a reliable mock- Added test cases to validate mock functionality
Base automatically changed frommes/socket-mock tomainAugust 7, 2025 20:54
@jaaydenhjaaydenhforce-pushed thejaaydenh/dynamic-parameters-tests branch fromc2526a5 tod760febCompareAugust 8, 2025 23:22
@jaaydenhjaaydenh requested a review fromaslilacAugust 8, 2025 23:23
@jaaydenh
Copy link
ContributorAuthor

@aslilac updated the tests to remove the queueMicrotask by moving the publish event outside of mockImplementation, below renderCreateWorkspacePageExperimental()

Copy link
Member

@aslilacaslilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

looks great! ty!

@jaaydenhjaaydenh merged commit0bfe0d6 intomainAug 11, 2025
27 checks passed
@jaaydenhjaaydenh deleted the jaaydenh/dynamic-parameters-tests branchAugust 11, 2025 19:43
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 11, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@ParkreinerParkreinerParkreiner left review comments

@aslilacaslilacaslilac approved these changes

@Kira-PilotKira-PilotAwaiting requested review from Kira-Pilot

+1 more reviewer

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@jaaydenhjaaydenh

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jaaydenh@Kira-Pilot@aslilac@Parkreiner

[8]ページ先頭

©2009-2025 Movatter.jp