Skip to content

test(internationalized-array): add test suite for _key migration#542

Open
pedrobonamin wants to merge 7 commits intomainfrom
feat/internationalized-array-tests
Open

test(internationalized-array): add test suite for _key migration#542
pedrobonamin wants to merge 7 commits intomainfrom
feat/internationalized-array-tests

Conversation

@pedrobonamin
Copy link
Contributor

@pedrobonamin pedrobonamin commented Feb 4, 2026

Description

Adds comprehensive test coverage to sanity-plugin-internationalized-array in preparation for the _keylanguage migration.

115 tests covering all _key language identification patterns:

  • Validation logic (duplicate detection, invalid keys)
  • Patch creation and insertion ordering
  • Language presence checks
  • Button/action disabled states
  • Full language lifecycle workflows

What to review

  • Test file organization and naming conventions
  • Test coverage completeness for _key usage patterns
  • Mock implementations in test-utils.ts
  • Integration test scenarios

Files affected:

  • plugins/sanity-plugin-internationalized-array/src/__tests__/
  • plugins/sanity-plugin-internationalized-array/src/schema/*.test.ts
  • plugins/sanity-plugin-internationalized-array/src/utils/*.test.ts
  • plugins/sanity-plugin-internationalized-array/src/components/*.test.ts
  • plugins/sanity-plugin-internationalized-array/src/fieldActions/*.test.ts
  • plugins/sanity-plugin-internationalized-array/vitest.config.ts

Testing

All 115 tests pass locally with pnpm vitest run.

Test categories:

  • Unit tests for schema validation (22 tests)
  • Unit tests for utilities (27 tests)
  • Unit tests for components (27 tests)
  • Unit tests for field actions (8 tests)
  • Integration tests for workflows (23 tests)

Notes for release

Not required - test infrastructure only, no user-facing changes.


🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Feb 5, 2026 9:57am

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

⚠️ No Changeset found

Latest commit: aca1c2c

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

@pedrobonamin
Copy link
Contributor Author

@copilot can you fix the lint issues in this PR?

Copy link
Contributor

Copilot AI commented Feb 4, 2026

@pedrobonamin I've opened a new pull request, #544, to work on those changes. Once the pull request is ready, I'll request review from you.

@pedrobonamin pedrobonamin marked this pull request as ready for review February 4, 2026 14:26
Copilot AI review requested due to automatic review settings February 4, 2026 14:26
@pedrobonamin pedrobonamin changed the title test(internationalized-array): add comprehensive test suite for _key migration test(internationalized-array): add test suite for _key migration Feb 4, 2026
Copy link
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 adds a comprehensive test suite with 115 tests for the sanity-plugin-internationalized-array plugin in preparation for migrating from _key to language as the language identifier. The tests cover all critical patterns where _key is used to identify languages, ensuring that when the migration occurs, any breaking changes will be caught.

Changes:

  • Added vitest configuration with jsdom environment and global test settings
  • Created test utilities with mock factories for consistent test data
  • Added unit tests for schema validation, patch creation, and utility functions
  • Added integration tests for complete language lifecycle workflows

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vitest.config.ts Configured vitest with jsdom environment and test file patterns
src/tests/test-utils.ts Created mock factories and test fixtures for consistent testing
src/utils/createAddLanguagePatches.test.ts Tests patch creation with _key as language identifier
src/utils/checkAllLanguagesArePresent.test.ts Tests language presence checking via _key comparison
src/schema/object.test.ts Tests object schema with _key in preview configuration
src/schema/array.test.ts Tests validation logic for _key-based language identification
src/fieldActions/index.test.ts Tests field action disabled states using _key comparison
src/components/DocumentAddButtons.test.ts Tests document-level translation filtering by _key
src/components/AddButtons.test.ts Tests button disabled logic using _key comparison
src/tests/integration/validation-flow.test.ts Integration tests for complete validation workflows
src/tests/integration/language-lifecycle.test.ts Integration tests for language CRUD operations

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

Copy link
Contributor

Copilot AI commented Feb 4, 2026

@pedrobonamin I've opened a new pull request, #549, to work on those changes. Once the pull request is ready, I'll request review from you.

claude and others added 7 commits February 5, 2026 10:56
Add 115 tests covering all _key language identification patterns
in preparation for sanity_language migration.

Test files added:
- schema/array.test.ts (22 tests)
- schema/object.test.ts (7 tests)
- utils/createAddLanguagePatches.test.ts (14 tests)
- utils/checkAllLanguagesArePresent.test.ts (13 tests)
- components/AddButtons.test.ts (13 tests)
- components/DocumentAddButtons.test.ts (14 tests)
- fieldActions/index.test.ts (8 tests)
- integration/language-lifecycle.test.ts (7 tests)
- integration/validation-flow.test.ts (16 tests)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove unused imports (Value, createValue, Language)
- Move helper functions to outer scope (filterAlreadyTranslated,
  removeDuplicates, createInsertItem, getInitialValueForType,
  isButtonDisabled, runValidation)
- Add non-null assertions for array indexing
- Replace @ts-expect-error with proper type casts

All 115 tests pass, oxlint clean.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Remove unused @ts-expect-error directives (validation-flow.test.ts)
- Cast FormPatchJSONValue items to {_key: string} for type safety
- Use bracket notation for index signature properties (fields, refs, subtitle)
- Move helper functions to module scope for cleaner structure

All 115 tests pass, eslint clean.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Use type guard helper functions (getItemKey, getItemType) instead of
  unsafe type assertions for FormPatchJSONValue access
- Replace (schema.validation as Function) with proper type checking
- Create ObjectSchemaWithFields type for accessing fields property
- Remove _type property from test Value objects (not part of Value type)
- Use bracket notation for index signature property access

All 115 tests pass, lint clean.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…files (#544)

* Initial plan

* fix(internationalized-array): resolve lint errors in test files

- Replace dot notation with bracket notation for index signature properties (_key, _type)
- Add type guards for validation rule extraction
- Use proper type narrowing instead of unsafe type assertions
- Add ValidationResult type for better type safety in tests
- Suppress TypeScript errors for test mock implementations with @ts-expect-error
- Add type guards in test assertions to properly narrow union types

Co-authored-by: pedrobonamin <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: pedrobonamin <[email protected]>
* Initial plan

* fix: import MAX_COLUMNS from constants instead of duplicating

Co-authored-by: pedrobonamin <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: pedrobonamin <[email protected]>
@pedrobonamin pedrobonamin force-pushed the feat/internationalized-array-tests branch from 2203aca to aca1c2c Compare February 5, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants