@bongos/core 1.24.90 → 1.24.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,6 +66,17 @@ test('a key means an action only when nothing else spent it', () => {
66
66
  assert.equal(V.keyFor('artisan', ev('Escape')), null, 'the ambient glass never takes Escape (ADR 0399 §2.4)');
67
67
  });
68
68
 
69
+ // task 1005209: a scene action the visor binds (bind: true) answers its key after the character's.
70
+ test("a place's own key: the visor binds it only when the scene asks, and the character's keys win", () => {
71
+ const V = loadPure();
72
+ const ev = (key) => ({ key, defaultPrevented: false, ctrlKey: false, metaKey: false, altKey: false });
73
+ const run = () => {};
74
+ V.scene({ name: 'x', place: 'X', actions: [{ label: 'Decide', key: 'D', bind: true, lead: true, run }, { label: 'Back to centre', key: '0', run }, { label: 'Claim here', key: 'c', bind: true, run }] });
75
+ assert.equal(V.keyFor('artisan', ev('d')).label, 'Decide', 'bound, and case does not matter');
76
+ assert.equal(V.keyFor('artisan', ev('0')), null, "a key the scene binds itself stays the scene's");
77
+ assert.equal(V.keyFor('artisan', ev('c')).id, 'claim', "the character's key wins a clash");
78
+ });
79
+
69
80
  // task 1005203: the four segments are the version the project is building, in quarters.
70
81
  test('progress: the starred version while open, else the one building, else none', () => {
71
82
  const V = loadPure();
@@ -146,7 +157,7 @@ test('source: the minimal visor spends the Helm tokens and types in no colour, s
146
157
  assert.ok(phone, 'the phone rules sit in the shared phone block');
147
158
  assert.match(phone[0], /\.visor__hint:not\(\[data-visor-sheet\]\) \{ display: none; \}/, 'a phone keeps only Actions of the hints');
148
159
  assert.doesNotMatch(read('home-city.css'), /visor-on/, 'Home has no top-right pill to clear any more');
149
- assert.match(read('city.css'), /\nhtml\.visor-on \.city-door \{ bottom: 150px; \}/, 'the city\'s door clears the centred button at every width');
160
+ assert.match(read('city.css'), /\nhtml\.visor-on \.city-door \{ bottom: 224px; \}/, 'the city\'s door clears the centred button at every width');
150
161
  });
151
162
 
152
163
  // ---------- in a browser: the glass over a stand-in scene ----------
@@ -260,6 +271,21 @@ test('Escape closes one layer, top first: the sheet, then the scene\'s pick, the
260
271
  await ctx.close();
261
272
  });
262
273
 
274
+ test('a lead scene action is the first key hint, and its click and its key run it (task 1005209)', { skip }, async () => {
275
+ const { ctx, page, errors } = await open();
276
+ await page.evaluate(() => OTBVisor.scene({ name: 'test', place: 'Test city', actions: [{ label: 'Decide 2 in a row', key: 'd', bind: true, lead: true, run() { window.decided = (window.decided || 0) + 1; } }] }));
277
+ const hints = await page.$$eval('.visor__hints .visor__hint', (h) => h.map((x) => x.textContent));
278
+ assert.deepEqual(hints, ['DDecide 2 in a row', 'TYour thinking', 'AActions', 'EscOptions']);
279
+ await page.click('.visor__hint--place');
280
+ await page.keyboard.press('d');
281
+ assert.equal(await page.evaluate(() => window.decided), 2, 'the hint and D both press it');
282
+ await page.evaluate(() => document.documentElement.removeAttribute('data-game'));
283
+ await page.keyboard.press('d');
284
+ assert.equal(await page.evaluate(() => window.decided), 2, 'outside game mode the glass binds no key');
285
+ assert.deepEqual(errors, []);
286
+ await ctx.close();
287
+ });
288
+
263
289
  test('the sheet lists the character\'s actions, then this place, and runs a scene action', { skip }, async () => {
264
290
  const { ctx, page } = await open();
265
291
  await page.click('[data-visor-sheet]');