-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to read room metadata from the room description
Implements part of #134 (comment), making it possible to define the room's metadata within the description field next to the definition of the room in the GitHub project. Note that this does not make any practical change to available semantics. The code does not yet support any more metadata key (such as "availability"). To be done later on.
- Loading branch information
Showing
4 changed files
with
183 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import * as assert from 'node:assert'; | ||
import { initTestEnv } from './init-test-env.mjs'; | ||
import { getEnvKey, setEnvKey } from '../tools/lib/envkeys.mjs'; | ||
import { fetchProject } from '../tools/lib/project.mjs'; | ||
|
||
async function fetchTestProject() { | ||
const project = await fetchProject( | ||
await getEnvKey('PROJECT_OWNER'), | ||
await getEnvKey('PROJECT_NUMBER')); | ||
return project; | ||
} | ||
|
||
function assertRoom(project, name, metadata) { | ||
const room = project.rooms.find(r => r.name === name); | ||
assert.ok(room, `Room "${name}" not found in project`); | ||
const roomCopy = Object.assign({}, room); | ||
if (roomCopy.id) { | ||
delete roomCopy.id; | ||
} | ||
const metadataCopy = Object.assign({}, metadata); | ||
metadataCopy.name = metadata.name ?? name; | ||
assert.deepStrictEqual(roomCopy, metadataCopy); | ||
} | ||
|
||
describe('The room definition', function () { | ||
before(function () { | ||
initTestEnv(); | ||
setEnvKey('PROJECT_NUMBER', 'room-metadata'); | ||
setEnvKey('ISSUE_TEMPLATE', 'test/data/template-breakout.yml'); | ||
}); | ||
|
||
it('may be just a name', async function () { | ||
const project = await fetchTestProject(); | ||
const name = 'Just a room'; | ||
assertRoom(project, name, { | ||
label: name, | ||
location: '', | ||
capacity: 30, | ||
vip: false | ||
}); | ||
}); | ||
|
||
it('may inline room information in the name', async function () { | ||
const project = await fetchTestProject(); | ||
const name = 'Inline (75 - basement) (VIP)'; | ||
assertRoom(project, name, { | ||
label: 'Inline', | ||
capacity: 75, | ||
location: 'basement', | ||
vip: true | ||
}); | ||
}); | ||
|
||
it('may contain VIP info in the description', async function () { | ||
const project = await fetchTestProject(); | ||
const name = 'VIP room'; | ||
assertRoom(project, name, { | ||
label: name, | ||
location: '', | ||
capacity: 25, | ||
vip: true | ||
}); | ||
}); | ||
|
||
it('may contain additional metadata in the description', async function () { | ||
const project = await fetchTestProject(); | ||
const name = 'In the back'; | ||
assertRoom(project, name, { | ||
label: name, | ||
location: '2nd floor', | ||
capacity: 40, | ||
vip: false, | ||
type: 'backroom' | ||
}); | ||
}); | ||
|
||
it('may contain invalid metadata in the description', async function () { | ||
const project = await fetchTestProject(); | ||
const name = 'Weird'; | ||
assertRoom(project, name, { | ||
label: name, | ||
location: 'somewhere', | ||
capacity: 30, | ||
vip: false | ||
}); | ||
}); | ||
|
||
it('may define metadata inline and in the description', async function () { | ||
const project = await fetchTestProject(); | ||
const name = 'Hybrid (42)'; | ||
assertRoom(project, name, { | ||
label: 'Hybrid', | ||
location: 'on ze web', | ||
capacity: 42, | ||
vip: false | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export default { | ||
description: 'meeting: Validation of room metadata, timezone: Etc/UTC', | ||
|
||
days: [ | ||
'2042-04-05' | ||
], | ||
|
||
slots: [ | ||
'9:00 - 10:00', | ||
'10:00 - 11:00' | ||
], | ||
|
||
rooms: [ | ||
'Just a room', | ||
'Inline (75 - basement) (VIP)', | ||
{ | ||
name: 'VIP room', | ||
description: ` | ||
- capacity: 25 | ||
- vip: true | ||
` | ||
}, | ||
{ | ||
name: 'In the back', | ||
description: ` | ||
* location: 2nd floor | ||
* capacity: 40 | ||
* vip: false | ||
* type: backroom` | ||
}, | ||
{ | ||
name: 'Weird', | ||
description: ` | ||
- | ||
- yes | ||
- location: somewhere` | ||
}, | ||
{ | ||
name: 'Hybrid (42)', | ||
description: `capacity: 35 | ||
location: on ze web` | ||
} | ||
], | ||
|
||
sessions: [ | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters