PSA/packages/scheduling/tests/timeEntryChangeRequests.test.ts
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

112 lines
3.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
getProminentTimeEntryChangeRequest,
getTimeEntryChangeRequestState,
} from '../src/lib/timeEntryChangeRequests';
describe('time entry change request selectors', () => {
it('T007: chooses the most recent feedback as the prominent inline message', () => {
const prominent = getProminentTimeEntryChangeRequest([
{
change_request_id: 'older',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'Older note',
created_at: '2026-03-10T09:00:00.000Z',
created_by: 'manager-1',
tenant: 'tenant-1',
},
{
change_request_id: 'latest',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'Latest note',
created_at: '2026-03-11T09:00:00.000Z',
created_by: 'manager-1',
tenant: 'tenant-1',
},
]);
expect(prominent?.change_request_id).toBe('latest');
expect(prominent?.comment).toBe('Latest note');
});
it('T026: updates the prominent feedback to a new review-cycle request after a handled cycle', () => {
const state = getTimeEntryChangeRequestState([
{
change_request_id: 'handled-request',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'First review cycle',
created_at: '2026-03-10T09:00:00.000Z',
created_by: 'manager-1',
handled_at: '2026-03-10T12:00:00.000Z',
handled_by: 'user-1',
tenant: 'tenant-1',
},
{
change_request_id: 'new-request',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'Second review cycle',
created_at: '2026-03-11T09:00:00.000Z',
created_by: 'manager-1',
tenant: 'tenant-1',
},
]);
const prominent = getProminentTimeEntryChangeRequest([
{
change_request_id: 'handled-request',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'First review cycle',
created_at: '2026-03-10T09:00:00.000Z',
created_by: 'manager-1',
handled_at: '2026-03-10T12:00:00.000Z',
handled_by: 'user-1',
tenant: 'tenant-1',
},
{
change_request_id: 'new-request',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'Second review cycle',
created_at: '2026-03-11T09:00:00.000Z',
created_by: 'manager-1',
tenant: 'tenant-1',
},
]);
expect(state).toBe('unresolved');
expect(prominent?.change_request_id).toBe('new-request');
});
it('keeps the entry unresolved while any older feedback remains open', () => {
const state = getTimeEntryChangeRequestState([
{
change_request_id: 'latest-handled',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'Latest review cycle was handled.',
created_at: '2026-03-12T09:00:00.000Z',
created_by: 'manager-1',
handled_at: '2026-03-12T12:00:00.000Z',
handled_by: 'user-1',
tenant: 'tenant-1',
},
{
change_request_id: 'older-unresolved',
time_entry_id: 'entry-1',
time_sheet_id: 'sheet-1',
comment: 'An older request is still unresolved.',
created_at: '2026-03-11T09:00:00.000Z',
created_by: 'manager-1',
tenant: 'tenant-1',
},
]);
expect(state).toBe('unresolved');
});
});