PSA/packages/projects/tests/projectInfoDrawer.test.tsx
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

91 lines
2.3 KiB
TypeScript

/**
* @vitest-environment jsdom
*/
import React from 'react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { IProject } from '@alga-psa/types';
const openDrawer = vi.fn();
const closeDrawer = vi.fn();
vi.mock('@alga-psa/ui', () => ({
useDrawer: () => ({
openDrawer,
closeDrawer,
}),
}));
vi.mock('@alga-psa/projects/lib/projectUtils', () => ({
calculateProjectCompletion: vi.fn(async () => ({
taskCompletionPercentage: 0,
hoursCompletionPercentage: 0,
budgetedHours: 0,
spentHours: 0,
remainingHours: 0,
})),
}));
vi.mock('@alga-psa/tags/components', () => ({
TagManager: () => null,
}));
vi.mock('../src/components/ProjectDetailsEdit', () => ({
default: () => null,
}));
vi.mock('../src/components/project-templates/CreateTemplateDialog', () => ({
default: () => null,
}));
vi.mock('@alga-psa/ui/components/BackNav', () => ({
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@alga-psa/ui/components/Button', () => ({
Button: ({ children, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) => (
<button type="button" {...props}>{children}</button>
),
}));
vi.mock('../src/components/ProjectMaterialsDrawer', () => ({
default: () => null,
}));
vi.mock('../src/components/HoursProgressBar', () => ({
default: () => null,
}));
describe('ProjectInfo materials drawer', () => {
beforeEach(() => {
openDrawer.mockClear();
closeDrawer.mockClear();
});
it('opens the materials drawer with 560px width (T002)', async () => {
const project = {
project_id: 'project-1',
project_name: 'Test Project',
project_number: 'PRJ-100',
client_id: 'client-1',
client_name: 'Client One',
} as IProject;
const ProjectInfo = (await import('../src/components/ProjectInfo')).default;
render(
<ProjectInfo
project={project}
users={[]}
clients={[]}
/>
);
await userEvent.click(screen.getByRole('button', { name: 'Materials' }));
expect(openDrawer).toHaveBeenCalledTimes(1);
const call = openDrawer.mock.calls[0];
expect(call[3]).toBe('560px');
});
});