test(internationalized-array): add test suite for _key migration#542
test(internationalized-array): add test suite for _key migration#542pedrobonamin wants to merge 7 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
@copilot can you fix the lint issues in this PR? |
|
@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. |
There was a problem hiding this comment.
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.
plugins/sanity-plugin-internationalized-array/src/components/AddButtons.test.ts
Outdated
Show resolved
Hide resolved
|
@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. |
65ba697 to
fe0de1b
Compare
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]>
2203aca to
aca1c2c
Compare
Description
Adds comprehensive test coverage to
sanity-plugin-internationalized-arrayin preparation for the_key→languagemigration.115 tests covering all
_keylanguage identification patterns:What to review
_keyusage patternstest-utils.tsFiles affected:
plugins/sanity-plugin-internationalized-array/src/__tests__/plugins/sanity-plugin-internationalized-array/src/schema/*.test.tsplugins/sanity-plugin-internationalized-array/src/utils/*.test.tsplugins/sanity-plugin-internationalized-array/src/components/*.test.tsplugins/sanity-plugin-internationalized-array/src/fieldActions/*.test.tsplugins/sanity-plugin-internationalized-array/vitest.config.tsTesting
All 115 tests pass locally with
pnpm vitest run.Test categories:
Notes for release
Not required - test infrastructure only, no user-facing changes.
🤖 Generated with Claude Code