elixir-cloud-aai / cloud-components

Reusable components for the ELIXIR Cloud
https://cloud-components.2.rahtiapp.fi/
Apache License 2.0
8 stars 14 forks source link

Test/expand tests #389

Open SalihuDickson opened 5 days ago

SalihuDickson commented 5 days ago

Description

This PR aims to simplify and expand tests for the ecc-utils design form, it also sets a standard for how the other tests for how tests for the other components will be written.

Summary by Sourcery

Expand and refactor tests for the ecc-utils design form to cover a wider range of input types and field options, and improve test component modularity.

Enhancements:

Tests:

Chores:

changeset-bot[bot] commented 5 days ago

⚠️ No Changeset found

Latest commit: e1c448794c062be21083f19bb2b6e381bace2efc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elixir-cloud-components ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 25, 2024 2:30pm
sourcery-ai[bot] commented 5 days ago

Reviewer's Guide by Sourcery

This PR significantly refactors and expands the test suite for the ecc-utils-design form component. The changes focus on improving test organization, readability, and maintainability by introducing a new test structure and helper classes for handling different form field types.

Class diagram for EccUtilsDesignForm changes

classDiagram
    class EccUtilsDesignForm {
        +handleTusFileUpload(e: Event, field: Field): Promise<Record<string, string> | null>
        +renderInputTemplate(field: Field, path: string): TemplateResult
        +renderArrayTemplate(field: Field, path: string): TemplateResult
        +renderGroupTemplate(field: Field, path: string): TemplateResult
        +renderErrorTemplate(): TemplateResult
        +renderSuccessTemplate(): TemplateResult
    }

File-Level Changes

Change Details Files
Introduced new test helper classes for form field interactions
  • Created base Field class with common element interaction methods
  • Added specialized classes for Input, Select, and Button elements
  • Implemented type-specific methods like fill(), toggle(), and select()
  • Added support for both LitElement and standard DOM elements
packages/ecc-utils-design/src/internal/TestComponent.ts
Restructured test organization by form field type
  • Separated tests into logical sections by field type (input, select, file, etc.)
  • Added comprehensive tests for each field type's rendering and functionality
  • Improved test descriptions for better clarity
  • Added new test cases for field options and validation
packages/ecc-utils-design/src/components/form/tests/form.test.ts
Enhanced form component data handling and validation
  • Improved form data handling for empty fields
  • Added better support for field validation
  • Updated file upload handling with better error management
  • Enhanced form submission data processing
packages/ecc-utils-design/src/components/form/form.ts
Simplified test data and improved test identifiers
  • Removed complex test data structures in favor of simpler, focused examples
  • Updated data-testid attributes for better clarity
  • Removed redundant test IDs constant object
packages/ecc-utils-design/src/components/form/tests/testData.ts
packages/ecc-utils-design/src/components/form/tests/form.class.ts

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).