Skip to content

Commit

Permalink
Fix mapping of group names when name contains group type
Browse files Browse the repository at this point in the history
The mapping logic expected all entries in the `CHAIR_W3CID` variable to use
abbreviated group types such as `CG` instead of `Community Group`.
  • Loading branch information
tidoust committed May 1, 2024
1 parent a9cfcc2 commit 47b4279
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
51 changes: 51 additions & 0 deletions test/check-group-unknown.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { initTestEnv } from './init-test-env.mjs';
import { getEnvKey, setEnvKey } from '../tools/lib/envkeys.mjs';
import { fetchProject } from '../tools/lib/project.mjs';
import { validateSession } from '../tools/lib/validate.mjs';
import * as assert from 'node:assert';

async function fetchTestProject() {
return fetchProject(
await getEnvKey('PROJECT_OWNER'),
await getEnvKey('PROJECT_NUMBER'));
}

describe('Validation of unknown groups', function () {
before(function () {
initTestEnv();
setEnvKey('PROJECT_NUMBER', 'group-unknown');
setEnvKey('ISSUE_TEMPLATE', 'test/data/template-group.yml');
});

it('takes mapping into account regardless of type abbreviation (BG -> Business Group)', async function () {
const project = await fetchTestProject();
project.chairsToW3CID = { 'The Super Business Group': -1 };
const sessionNumber = 1;
const errors = await validateSession(sessionNumber, project);
assert.deepStrictEqual(errors, []);
});

it('takes mapping into account regardless of type abbreviation (BG -> BG)', async function () {
const project = await fetchTestProject();
project.chairsToW3CID = { 'The Super BG': 'ok' };
const sessionNumber = 1;
const errors = await validateSession(sessionNumber, project);
assert.deepStrictEqual(errors, []);
});

it('takes mapping into account regardless of type abbreviation (Working Group -> Working Group)', async function () {
const project = await fetchTestProject();
project.chairsToW3CID = { 'the not heavily working group': 'lazy' };
const sessionNumber = 2;
const errors = await validateSession(sessionNumber, project);
assert.deepStrictEqual(errors, []);
});

it('takes mapping into account regardless of type abbreviation (Working Group -> WG)', async function () {
const project = await fetchTestProject();
project.chairsToW3CID = { 'the not heavily WG': -1 };
const sessionNumber = 2;
const errors = await validateSession(sessionNumber, project);
assert.deepStrictEqual(errors, []);
});
});
15 changes: 15 additions & 0 deletions test/data/group-unknown.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default {
description: 'meeting: Mapping of unknown group names, timezone: Etc/UTC, type: groups',

sessions: [
{
number: 1,
title: 'The Super BG'
},

{
number: 2,
title: 'The Not Heavily Working Group'
}
]
}
8 changes: 7 additions & 1 deletion tools/lib/groups.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ import { fetchW3CGroups } from './w3c.mjs';
export async function fetchSessionGroups(session, groups2W3CID) {
const lcGroups2W3CID = {};
for (const name of Object.keys(groups2W3CID ?? {})) {
lcGroups2W3CID[name.toLowerCase()] = groups2W3CID[name];
const normalized = name.toLowerCase()
.replace(/ Business Group$/i, ' bg')
.replace(/ Community Group$/i, ' cg')
.replace(/ Interest Group$/i, ' ig')
.replace(/ Working Group$/i, ' wg')
.replace(/ Task Force$/i, ' tf');
lcGroups2W3CID[normalized] = groups2W3CID[name];
}

const w3cGroups = await fetchW3CGroups();
Expand Down

0 comments on commit 47b4279

Please sign in to comment.