Skip to content

refactor(web): move component tests into sibling __tests__ directories#33623

Merged
CodingOnStar merged 2 commits intomainfrom
fix/header-test
Mar 18, 2026
Merged

refactor(web): move component tests into sibling __tests__ directories#33623
CodingOnStar merged 2 commits intomainfrom
fix/header-test

Conversation

@CodingOnStar
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

refactor(web): move component tests into sibling tests directories

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

@CodingOnStar CodingOnStar requested a review from lyzno1 March 18, 2026 02:40
Copilot AI review requested due to automatic review settings March 18, 2026 02:40
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 18, 2026
@github-actions github-actions bot added the web This relates to changes on the web. label Mar 18, 2026
@dosubot dosubot bot added javascript Pull requests that update javascript code refactor labels Mar 18, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 18, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on reorganizing the test files within the web application. It moves component-level tests into __tests__ directories located in the same directory as the component source files. This change enhances project structure and test discoverability, aligning with best practices for maintainable testing strategies.

Highlights

  • Test File Restructuring: This PR refactors the web application's test suite by moving component tests into sibling __tests__ directories.
  • Updated Documentation: The documentation has been updated to reflect the new test file placement strategy.
  • Codebase Consistency: This change aims to improve the organization and maintainability of the codebase by enforcing a consistent test file structure.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes the web frontend’s unit test layout by moving component/hook/utility tests into sibling __tests__/ directories and updating docs and imports to match the new structure.

Changes:

  • Updated testing documentation/guidance to require sibling __tests__/ directories for component/hook/utility tests.
  • Adjusted many test imports/mocks to account for tests now living under __tests__/.
  • Added a new unit test suite for the Array.prototype.toSpliced polyfill behavior.

Reviewed changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated no comments.

Show a summary per file
File Description
web/docs/test.md Updates test placement/naming guidance to use sibling __tests__/ directories.
web/app/components/tools/workflow-tool/tests/utils.test.ts Fixes relative imports after moving tests under __tests__/.
web/app/components/rag-pipeline/components/tests/index.spec.tsx Tweaks act() usage around event callbacks to align with RTL expectations.
web/app/components/plugins/tests/use-plugins-with-latest-version.spec.ts Updates imports to reflect new __tests__/ placement.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/use-activate-credential.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/usage-priority-section.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/index.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/dropdown-content.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/dialog.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/credits-exhausted-alert.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/tests/api-key-section.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/tests/use-trial-credits.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/tests/use-credential-panel-state.spec.ts Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/tests/use-change-provider-priority.spec.ts Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/tests/system-quota-card.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/provider-added-card/tests/provider-card-actions.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/model-selector/tests/popover.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/model-selector/tests/model-selector-trigger.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/model-parameter-modal/tests/parameter-item.select.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/model-parameter-modal/tests/derive-trigger-status.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/model-modal/tests/dialog.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/tests/supports-credits.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/tests/index.non-cloud.spec.tsx Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/tests/derive-model-status.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/model-provider-page/tests/atoms.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/members-page/edit-workspace-modal/tests/dialog.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/header/account-setting/tests/menu-dialog.dialog.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/base/prompt-editor/plugins/workflow-variable-block/tests/use-llm-model-plugin-installed.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/base/markdown-with-directive/components/tests/with-icon-card-list.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/base/markdown-with-directive/components/tests/with-icon-card-item.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/base/markdown-with-directive/components/tests/markdown-with-directive-schema.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/base/markdown-with-directive/tests/index.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/base/file-uploader/tests/dynamic-pdf-preview.spec.tsx Updates imports (including dynamic import) due to __tests__/ directory relocation.
web/app/components/base/amplitude/tests/utils.spec.ts Updates imports/mocks due to __tests__/ directory relocation.
web/app/components/base/amplitude/tests/index.spec.ts Updates imports due to __tests__/ directory relocation.
web/app/components/base/amplitude/tests/AmplitudeProvider.spec.tsx Updates imports due to __tests__/ directory relocation.
web/app/components/tests/browser-initializer.spec.ts Adds tests for toSpliced polyfill behavior.
.agents/skills/frontend-testing/SKILL.md Updates agent testing skill doc to reflect sibling __tests__/ convention.
Comments suppressed due to low confidence (1)

web/app/components/tools/workflow-tool/tests/utils.test.ts:3

  • This file is named utils.test.ts while the surrounding sibling tests use the *.spec.ts(x) convention and the updated test guidelines in this PR also specify *.spec.*. To keep naming consistent and make test discovery predictable, rename this file to utils.spec.ts (and update any references if needed).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CodingOnStar CodingOnStar merged commit 6100acb into main Mar 18, 2026
26 checks passed
@CodingOnStar CodingOnStar deleted the fix/header-test branch March 18, 2026 02:49
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the test file structure by moving component tests into __tests__ subdirectories, co-locating them with their corresponding components. The changes primarily consist of moving files and updating import paths. The path changes appear correct across the numerous files. Additionally, the tests in web/app/components/rag-pipeline/components/__tests__/index.spec.tsx have been improved by correctly wrapping asynchronous updates in act, which should enhance test stability. Overall, this is a structural refactoring that improves test organization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants