Context
PR #3 introduced the first unit tests (test/formatters.test.ts, test/helpers.test.ts, test/utils.test.ts) covering pure helpers. Several higher-value modules remain at 0% coverage, and the @bitrix24/b24jssdk 1→2 major bump is not exercised by any test. This issue tracks closing those gaps as a dedicated follow-up (kept out of PR #3 to avoid bloating a dependency-update PR and because it needs additional test harness setup).
Coverage gaps to close
app/composables/useDealStats/api.ts — the core CRM integration (currently untested):
- paginated loading via
b24.actions.v2.fetchList.make (mock the async generator with canned pages);
- date-range boundary normalization (
setHours(0,0,0,0) / 23:59:59.999);
- the
stageSemanticId === 'P' ? null : ... closedate nulling — this is the exact invariant getLatestSales's filter relies on, currently only assumed via hand-built fixtures;
- revenue aggregation per currency,
successfulDeals count, and uniqueCustomers dedup (contactId / companyId / 'empty' fallback).
app/composables/useDealStats/index.ts — orchestration: processCrmData / loadDeals, mock-vs-B24 branching, partial-stat callback merging, variation calc (current vs previous period), currency-list cleanup, and the SdkError error/toast path. Needs Nuxt auto-import mocking (useI18n, useToast, shallowRef, …) or @nuxt/test-utils.
app/composables/useDealStats/formatters.ts — formatDateRange and formatDateTimeShort are untested (add cases under the pinned TZ=UTC).
app/composables/useDealStats/helpers.ts — groupSalesByDate has two live @todo fix this markers; add edge cases (closedate before the earliest timestamp, duplicate/near timestamps, unsorted input) that pin current behavior before any fix.
app/composables/useDealStats/mocks.ts — smoke tests for generateMockStats / generateMockChart / generateMockSales (e.g. count, chart length matches dates).
B24 SDK smoke test (major bump 1→2)
No test currently exercises the SDK integration surface (useB24 init/set/get, initializeB24Frame, useB24Helper, LoadDataType, actions.v2.fetchList). Add at least a mocked smoke test that pins the expected shapes so a future SDK bump that changes them is caught by CI.
Test-harness prerequisites
vitest.config.ts currently has no setupFiles / path aliases / coverage config. Composable/orchestration tests will need Nuxt auto-import mocking (or @nuxt/test-utils) and possibly ~/#imports aliases.
- Consider wiring
vitest run --coverage and a coverage threshold into CI (.github/workflows/ci.yml) so gaps stay visible.
Acceptance
Follow-up to PR #3.
Context
PR #3 introduced the first unit tests (
test/formatters.test.ts,test/helpers.test.ts,test/utils.test.ts) covering pure helpers. Several higher-value modules remain at 0% coverage, and the@bitrix24/b24jssdk1→2 major bump is not exercised by any test. This issue tracks closing those gaps as a dedicated follow-up (kept out of PR #3 to avoid bloating a dependency-update PR and because it needs additional test harness setup).Coverage gaps to close
app/composables/useDealStats/api.ts— the core CRM integration (currently untested):b24.actions.v2.fetchList.make(mock the async generator with canned pages);setHours(0,0,0,0)/23:59:59.999);stageSemanticId === 'P' ? null : ...closedate nulling — this is the exact invariantgetLatestSales's filter relies on, currently only assumed via hand-built fixtures;successfulDealscount, anduniqueCustomersdedup (contactId/companyId/'empty'fallback).app/composables/useDealStats/index.ts— orchestration:processCrmData/loadDeals, mock-vs-B24 branching, partial-stat callback merging, variation calc (current vs previous period), currency-list cleanup, and theSdkErrorerror/toast path. Needs Nuxt auto-import mocking (useI18n,useToast,shallowRef, …) or@nuxt/test-utils.app/composables/useDealStats/formatters.ts—formatDateRangeandformatDateTimeShortare untested (add cases under the pinnedTZ=UTC).app/composables/useDealStats/helpers.ts—groupSalesByDatehas two live@todo fix thismarkers; add edge cases (closedate before the earliest timestamp, duplicate/near timestamps, unsorted input) that pin current behavior before any fix.app/composables/useDealStats/mocks.ts— smoke tests forgenerateMockStats/generateMockChart/generateMockSales(e.g. count, chart length matches dates).B24 SDK smoke test (major bump 1→2)
No test currently exercises the SDK integration surface (
useB24init/set/get,initializeB24Frame,useB24Helper,LoadDataType,actions.v2.fetchList). Add at least a mocked smoke test that pins the expected shapes so a future SDK bump that changes them is caught by CI.Test-harness prerequisites
vitest.config.tscurrently has nosetupFiles/ path aliases / coverage config. Composable/orchestration tests will need Nuxt auto-import mocking (or@nuxt/test-utils) and possibly~/#importsaliases.vitest run --coverageand a coverage threshold into CI (.github/workflows/ci.yml) so gaps stay visible.Acceptance
api.tscovered (pagination, date bounds, closedate nulling, aggregation, dedup)index.tsorchestration covered (mock + B24 branches, error path)formatDateRange/formatDateTimeShortcovered (TZ-pinned)groupSalesByDateedge cases coveredmocks.tssmoke-testedFollow-up to PR #3.