Run the people-data-labs spec suite in CI (#23743)
The PDL app's unit vitest config only matched `src/**/*.test.ts`, but the app's test files were named `*.spec.ts`, so CI ran a single file and 368 tests never executed. Renamed the 88 spec files to `*.test.ts`, the convention every other public app and the `create-twenty-app` scaffold already use, which leaves `vitest.unit.config.ts` byte-identical to the other apps. `capitalize-name` had both a spec and a test file covering the same function, so the more thorough one was kept. Turning the suite on surfaced one real failure: `collectUuids` in the select-option test scooped up the `path` strings added to `PDL_LOGIC_FUNCTION_CONSTANTS` and asserted they were v4 UUIDs. It now stops at any object with a `universalIdentifier` and collects only that value. `yarn test:unit` is green at 88 files / 368 tests, with `yarn typecheck` and `yarn lint` clean.
This commit is contained in:
+10
@@ -110,11 +110,21 @@ describe('select fields collectively', () => {
|
||||
const UUID_V4_REGEX =
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
||||
|
||||
const hasUniversalIdentifier = (
|
||||
value: object,
|
||||
): value is { universalIdentifier: string } =>
|
||||
'universalIdentifier' in value &&
|
||||
typeof (value as { universalIdentifier: unknown }).universalIdentifier ===
|
||||
'string';
|
||||
|
||||
const collectUuids = (value: unknown): string[] => {
|
||||
if (typeof value === 'string') {
|
||||
return [value];
|
||||
}
|
||||
if (value !== null && typeof value === 'object') {
|
||||
if (!Array.isArray(value) && hasUniversalIdentifier(value)) {
|
||||
return [value.universalIdentifier];
|
||||
}
|
||||
return Object.values(value).flatMap(collectUuids);
|
||||
}
|
||||
return [];
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { capitalizeName } from 'src/logic-functions/utils/capitalize-name';
|
||||
|
||||
describe('capitalizeName', () => {
|
||||
it('capitalizes a lowercase single token', () => {
|
||||
expect(capitalizeName('sean')).toBe('Sean');
|
||||
});
|
||||
|
||||
it('capitalizes every whitespace-separated token', () => {
|
||||
expect(capitalizeName('sean thorne')).toBe('Sean Thorne');
|
||||
});
|
||||
|
||||
it('capitalizes after hyphens and apostrophes', () => {
|
||||
expect(capitalizeName('mary-jane')).toBe('Mary-Jane');
|
||||
expect(capitalizeName("o'brien")).toBe("O'Brien");
|
||||
});
|
||||
|
||||
it('leaves already-capitalized names untouched', () => {
|
||||
expect(capitalizeName('Jane Doe')).toBe('Jane Doe');
|
||||
});
|
||||
|
||||
it('returns an empty string unchanged', () => {
|
||||
expect(capitalizeName('')).toBe('');
|
||||
});
|
||||
});
|
||||
+14
-4
@@ -3,15 +3,25 @@ import { describe, expect, it } from 'vitest';
|
||||
import { capitalizeName } from 'src/logic-functions/utils/capitalize-name';
|
||||
|
||||
describe('capitalizeName', () => {
|
||||
it('should capitalize the first letter of each word', () => {
|
||||
expect(capitalizeName('john doe')).toBe('John Doe');
|
||||
it('capitalizes a lowercase single token', () => {
|
||||
expect(capitalizeName('sean')).toBe('Sean');
|
||||
});
|
||||
|
||||
it('should capitalize letters after hyphens and apostrophes', () => {
|
||||
it('capitalizes every whitespace-separated token', () => {
|
||||
expect(capitalizeName('sean thorne')).toBe('Sean Thorne');
|
||||
});
|
||||
|
||||
it('capitalizes after hyphens and apostrophes', () => {
|
||||
expect(capitalizeName('mary-jane')).toBe('Mary-Jane');
|
||||
expect(capitalizeName("o'brien")).toBe("O'Brien");
|
||||
expect(capitalizeName("jean-luc o'brien")).toBe("Jean-Luc O'Brien");
|
||||
});
|
||||
|
||||
it('should return an empty string unchanged', () => {
|
||||
it('leaves already-capitalized names untouched', () => {
|
||||
expect(capitalizeName('Jane Doe')).toBe('Jane Doe');
|
||||
});
|
||||
|
||||
it('returns an empty string unchanged', () => {
|
||||
expect(capitalizeName('')).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user