Skip to content

Unit tests for mutations #1783

@nicki182

Description

@nicki182

Terms

Issue

Summary

Implement comprehensive unit tests for mutation composables in folder frontend/app/composables/mutations.

Both use direct service calls and refresh Nuxt async/query data after mutations.

Requirements

  • Test each mutation handler: createFAQ, updateFAQ, reorderFAQs, deleteFAQ, uploadIconImage, refreshEventData, ext
  • Assert correct mutation behavior, service call invocations, state updates, and error propagation.
  • Mock all underlying service calls and cache refresh (refreshNuxtData).
  • Test error scenarios (service throws/returns error), check calls to showToastError and the correct reactive error state.
  • Verify loading transitions (true/false states before/after mutation runs).
  • Test edge cases: missing eventId or bad FAQ data, unexpected errors, handling for delete/add order, cache invalidation/refetch, ect
  • Test that refreshEventData always calls refreshNuxtData with the correct key after a mutation.
  • Cover reactivity (readonly states) for loading and error throughout all mutation methods.

Paths & code references`

  • Service helpers.

Implementation guidelines

  • Use Vitest/Jest and Vue/Nuxt test utils to mock service/composable dependencies and async behaviors
  • Place unit tests under frontend/testst/composables/mutations
  • Document any additional edge cases, helpers, or mutation patterns discovered during implementation
  • Link to parent and related subissues for review

Metadata

Metadata

Assignees

Labels

frontendRelates to the project frontendhelp wantedExtra attention is neededtypescriptRelates to TypeScript code

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions