PSA/packages/n8n-nodes-alga-psa/__tests__/package-and-credential.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

49 lines
2.2 KiB
TypeScript

import { execSync } from 'node:child_process';
import { existsSync, readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import { AlgaPsaApi } from '../credentials/AlgaPsaApi.credentials';
const testDir = path.dirname(fileURLToPath(import.meta.url));
const packageRoot = path.resolve(testDir, '..');
const packageJsonPath = path.join(packageRoot, 'package.json');
describe('Package metadata and credential', () => {
it('T001: package metadata follows n8n naming and built entry conventions', () => {
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as Record<string, unknown>;
const n8n = packageJson.n8n as Record<string, unknown>;
expect(String(packageJson.name)).toMatch(/^n8n-nodes-/);
expect(Array.isArray(n8n.nodes)).toBe(true);
expect(Array.isArray(n8n.credentials)).toBe(true);
expect((n8n.nodes as string[])[0]).toBe('dist/nodes/AlgaPsa/AlgaPsa.node.js');
expect((n8n.credentials as string[])[0]).toBe('dist/credentials/AlgaPsaApi.credentials.js');
});
it('T002: build emits compiled node and credential artifacts without TS compile errors', () => {
// Cold CI builds exceed vitest's default 5s timeout, and because execSync
// is synchronous vitest can't preempt it — a hung child held the CI job
// open for hours. Kill the build at the child level and give the test a
// realistic budget.
execSync('npm run build', {
cwd: packageRoot,
stdio: 'pipe',
timeout: 120_000,
killSignal: 'SIGKILL',
});
expect(existsSync(path.join(packageRoot, 'dist/nodes/AlgaPsa/AlgaPsa.node.js'))).toBe(true);
expect(existsSync(path.join(packageRoot, 'dist/nodes/AlgaPsa/avatar-purple.png'))).toBe(true);
expect(existsSync(path.join(packageRoot, 'dist/credentials/AlgaPsaApi.credentials.js'))).toBe(true);
}, 180_000);
it('T003: credential definition exposes exactly baseUrl and secret apiKey fields', () => {
const credential = new AlgaPsaApi();
const fields = credential.properties.map((field) => field.name);
expect(fields).toEqual(['baseUrl', 'apiKey']);
expect(credential.properties[1]?.typeOptions).toMatchObject({ password: true });
});
});