diff --git a/test/check-group-unknown.mjs b/test/check-group-unknown.mjs new file mode 100644 index 0000000..12a027b --- /dev/null +++ b/test/check-group-unknown.mjs @@ -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, []); + }); +}); \ No newline at end of file diff --git a/test/data/group-unknown.mjs b/test/data/group-unknown.mjs new file mode 100644 index 0000000..db1b164 --- /dev/null +++ b/test/data/group-unknown.mjs @@ -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' + } + ] +} \ No newline at end of file diff --git a/tools/lib/groups.mjs b/tools/lib/groups.mjs index 857ec8f..a864c21 100644 --- a/tools/lib/groups.mjs +++ b/tools/lib/groups.mjs @@ -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();