mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-08 04:11:18 +02:00
feat(eval-pass-rates): attribute legacy records by the exact slug of their display name
This commit is contained in:
1 parent
d6b3559b78
commit
8ee9f887ed
2 files changed
+7
-2
No files matched your search
@@ -189,14 +189,17 @@ export function caseTier(id: string, registry: Registry = LIVE_REGISTRY): string
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute a legacy eval-store record to a registry id: the case-shard slug
|
* Attribute a legacy eval-store record to a registry id: the case-shard slug
|
||||||
* suffix (`<file>--<id>`), the recorded name, a CASE_TEST_NAMES label, or the
|
* suffix (`<file>--<id>`), the recorded name or its exact slug (`/qa b6-static`
|
||||||
* only id its shard file registers. Anything else is unattributed (null).
|
* is `qa-b6-static`), a CASE_TEST_NAMES label, or the only id its shard file
|
||||||
|
* registers. Anything else is unattributed (null).
|
||||||
*/
|
*/
|
||||||
export function attributeLegacyRecord(name: string, shard: string | undefined, registry: Registry = LIVE_REGISTRY): string | null {
|
export function attributeLegacyRecord(name: string, shard: string | undefined, registry: Registry = LIVE_REGISTRY): string | null {
|
||||||
const known = (id: string) => id in registry.kinds;
|
const known = (id: string) => id in registry.kinds;
|
||||||
const [slugFile, slugCase] = (shard ?? '').split('--');
|
const [slugFile, slugCase] = (shard ?? '').split('--');
|
||||||
if (slugCase && known(slugCase)) return slugCase;
|
if (slugCase && known(slugCase)) return slugCase;
|
||||||
if (known(name)) return name;
|
if (known(name)) return name;
|
||||||
|
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
||||||
|
if (known(slug)) return slug;
|
||||||
const labeled = Object.entries(registry.testNames).find(([, label]) => label === name)?.[0];
|
const labeled = Object.entries(registry.testNames).find(([, label]) => label === name)?.[0];
|
||||||
if (labeled && known(labeled)) return labeled;
|
if (labeled && known(labeled)) return labeled;
|
||||||
if (slugFile) {
|
if (slugFile) {
|
||||||
|
|||||||
@@ -281,6 +281,8 @@ describe('pass-rates inputs', () => {
|
|||||||
test('legacy records attribute by shard suffix, id, label or single-owner file, else stay unattributed', () => {
|
test('legacy records attribute by shard suffix, id, label or single-owner file, else stay unattributed', () => {
|
||||||
expect(attributeLegacyRecord('/anything', 'skill-e2e-b--beh-b', registry)).toBe('beh-b');
|
expect(attributeLegacyRecord('/anything', 'skill-e2e-b--beh-b', registry)).toBe('beh-b');
|
||||||
expect(attributeLegacyRecord('rule-a', 'skill-e2e-zzz', registry)).toBe('rule-a');
|
expect(attributeLegacyRecord('rule-a', 'skill-e2e-zzz', registry)).toBe('rule-a');
|
||||||
|
expect(attributeLegacyRecord('/Rule a', 'skill-e2e-zzz', registry)).toBe('rule-a');
|
||||||
|
expect(attributeLegacyRecord('/rule a extra', 'skill-e2e-zzz', registry)).toBeNull();
|
||||||
expect(attributeLegacyRecord('/gate c labeled', undefined, registry)).toBe('gate-c');
|
expect(attributeLegacyRecord('/gate c labeled', undefined, registry)).toBe('gate-c');
|
||||||
expect(attributeLegacyRecord('/a display name', 'skill-e2e-a', registry)).toBe('rule-a');
|
expect(attributeLegacyRecord('/a display name', 'skill-e2e-a', registry)).toBe('rule-a');
|
||||||
expect(attributeLegacyRecord('/shared display', 'skill-e2e-shared', registry)).toBeNull();
|
expect(attributeLegacyRecord('/shared display', 'skill-e2e-shared', registry)).toBeNull();
|
||||||
|
|||||||
Reference in new issue
Block a user