Add unit tests for dataset, revision and task services (#686)#692
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the unit-test coverage of three core service modules (dataset, revision, task) identified in #686, and makes two small DatasetService adjustments to remove unreachable logic and improve testability. It also raises the global Jest coverage thresholds to reflect the improved baseline.
Changes:
- Added comprehensive unit tests covering happy/unhappy paths for
DatasetService, revision service helpers, andTaskService. - Simplified
DatasetService.updateFactTable()by removing an unreachablerevisionIndex === 1branch and always resetting dimensions/measure after the existing guard. - Updated
DatasetService.deleteDraftRevision()to use the injectedfileService(instead of creating a new one internally), and raised Jest global coverage thresholds.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/services/task.test.ts | Adds unit tests for TaskService covering task creation, status transitions, and archive/unarchive/unpublish flows. |
| test/unit/services/revision.test.ts | Adds unit tests for revision service functions including validation-cube flows, rebuild flows, and revision-task updates. |
| test/unit/services/dataset.test.ts | Adds unit tests for DatasetService including metadata updates, publication flows, draft deletion cleanup, and history/tasklist behavior. |
| src/services/dataset.ts | Removes unreachable branch in fact-table replacement and uses injected fileService for draft-revision cleanup. |
| jest.config.ts | Raises global coverage thresholds in line with improved suite coverage. |
Brings the three under-covered services up to the testing-initiative target: - dataset.ts: 50% -> 99.6% statements - revision.ts: 31% -> 93.5% statements - task.ts: 14% -> 100% statements Covers happy and unhappy paths across each service's public methods, including task lifecycle and status transitions, revision draft/approval flows and dataset fact-table replacement. dataset.ts: use the injected this.fileService instead of getFileService() so the draft-revision delete path is unit-testable. The redundant revisionIndex === 1 guard around the dimension/measure reset is kept as a defensive backstop -- the outer guard already guarantees the first revision, but the explicit check protects against that guard being relaxed later. Raise the global coverage thresholds in jest.config.ts to match the new floor (statements 79, branches 67, functions 75, lines 79).
1d5b0b6 to
4dfbb55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds unit tests for three under-covered services flagged in #686, bringing each above the 70% statement-coverage target used across the testing initiative.
src/services/dataset.tssrc/services/revision.tssrc/services/task.ts84 new tests covering both happy and unhappy paths across each service's public methods — task lifecycle and status transitions, revision draft/approval flows, and dataset fact-table replacement.
Source changes
src/services/dataset.ts:getFileService()to the injectedthis.fileService, so the path can be exercised in a unit test.revisionIndex === 1guard around the dimension/measure reset as a deliberate defensive backstop. The outer guard inupdateFactTablealready throws for any revision other than the first, so the inner check is currently redundant — but it stays as cheap protection against that outer guard being relaxed later, so we never reset a non-first revision's dimensions/measure.jest.config.ts:Scope
This PR covers the three services from #686. The four controllers (
admin,build-log,measure,translation) are handled separately in #693.Verification
jest --coverage— 1551 tests pass, global thresholds met.tscbuild and lint clean.Part of #686.