From 5bd940203473e8b7858280cb18a33c3786369570 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" Date: Sat, 26 Sep 2026 00:04:04 -0400 Subject: [PATCH] test(fetch-community-people): cover the four uncovered sub-line regions scripts/fetch-community-people.mjs reported 100.00% line but 94.20% region coverage. Four fallback regions never executed: - lastSegment()'s '|| null' for a URL whose path strips to no segment - the '|| previous.name' and "|| ''" arms of the name fallback chain - the ": 's'" plural suffix on the run's fallback count Add one case per region. The file now reports 100.00% region coverage and the repo-wide src region figure moves from 97.95% to 98.19%. Closes #685 Signed-off-by: hivecommons-hive[bot] --- tests/fetch-community-people.test.mjs | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/fetch-community-people.test.mjs b/tests/fetch-community-people.test.mjs index 236be06d..bf3833b1 100644 --- a/tests/fetch-community-people.test.mjs +++ b/tests/fetch-community-people.test.mjs @@ -444,3 +444,81 @@ test('falls back to the cached handle when the upstream URL is unparseable', () assert.equal(person.linkedin, 'ada-lovelace'); assert.equal(person.twitter, 'ada'); }); + +test('drops a link URL whose path has no segment instead of emitting an empty handle', () => { + const result = run({ + fixtures: { + [ROSTER]: roster({ tab: [{ name: 'Ada Lovelace', github: 'ada' }] }), + }, + records: [ + { + name: 'Ada Lovelace', + github: 'https://github.com/ada', + // A bare profile host carries no handle: the path strips to nothing, + // so the link must come out null rather than an empty-string handle + // the site would render as a link to the provider's front page. + linkedin: 'https://www.linkedin.com/', + twitter: 'https://twitter.com///', + }, + ], + }); + + const person = parseOutput(result).people.tab[0]; + assert.equal(person.linkedin, null); + assert.equal(person.twitter, null); +}); + +test('falls back to the cached name when the roster entry has none', () => { + const result = run({ + fixtures: { + [ROSTER]: roster({ tab: [{ company: 'Roster Co', github: 'ada' }] }), + [OUTPUT]: JSON.stringify({ + fetchedAt: '2020-01-01T00:00:00.000Z', + people: { tab: [{ name: 'Ada Lovelace', github: 'ada' }] }, + }), + }, + records: [], + }); + + const person = parseOutput(result).people.tab[0]; + assert.equal(person.name, 'Ada Lovelace'); + assert.equal(person.company, 'Roster Co'); +}); + +test('emits an empty name when neither the roster nor the cache has one', () => { + const result = run({ + fixtures: { + [ROSTER]: roster({ tab: [{ company: 'Roster Co', github: 'ada' }] }), + }, + records: [ + { + name: 'Upstream Name', + github: 'https://github.com/ada', + }, + ], + }); + + // cncf/people names are never authoritative, so an absent roster name and an + // absent cache must leave the field an empty string rather than adopting the + // upstream value. + const person = parseOutput(result).people.tab[0]; + assert.equal(person.name, ''); + assert.equal(person.company, 'Roster Co'); +}); + +test('pluralises the fallback count when more than one handle is unmatched', () => { + const result = run({ + fixtures: { + [ROSTER]: roster({ + tab: [ + { name: 'Ada Lovelace', github: 'ada' }, + { name: 'Grace Hopper', github: 'grace' }, + ], + }), + }, + records: [], + }); + + parseOutput(result); + assert.match(result.stdout, /\(2 fallbacks\)/); +});