@bongos/core 1.24.27 → 1.24.28
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.
- package/.bongos-core.json +40 -35
- package/docs/copy-inventory.md +175 -175
- package/docs/copy-registry.json +280 -280
- package/docs/module-api-changelog.md +2 -0
- package/docs/page-inventory.json +9 -3
- package/docs/page-readings.json +277 -214
- package/modules/hall-ui/public/my-agents.css +72 -1
- package/modules/hall-ui/public/my-agents.html +30 -6
- package/modules/hall-ui/public/my-agents.js +63 -54
- package/modules/hall-ui/public/my-agents.states.json +18 -0
- package/modules/hall-ui/public/settings.css +2 -132
- package/modules/hall-ui/public/settings.html +8 -48
- package/modules/hall-ui/public/speciality-tools.css +140 -0
- package/modules/hall-ui/public/{settings-specialities.js → speciality-tools.js} +83 -6
- package/modules/hall-ui/records/my-agents.md +4 -2
- package/modules/hall-ui/records/panel-family.md +2 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/release-notes.json +6 -0
- package/scripts/hall-preview/server.js +4 -0
- package/src/module-api.js +1 -1
- package/tests/hall_loading.mjs +3 -1
- package/tests/hall_my_agents.mjs +104 -2
- package/tests/helpers.mjs +161 -0
- package/tests/speciality_offer_ui.mjs +182 -149
- package/tests/speciality_walkthrough_ui.mjs +180 -161
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// tests/speciality_walkthrough_ui.mjs — the
|
|
2
|
-
//
|
|
1
|
+
// tests/speciality_walkthrough_ui.mjs — the ADOPTER's side of the speciality
|
|
2
|
+
// tools: taking one on, the skills walkthrough it opens, and stopping it (task
|
|
3
|
+
// 1004073, part 2 of 3 of ADR 0310; on My agents too since task 1005052).
|
|
3
4
|
//
|
|
4
5
|
// The owner's ruling: an adopted speciality's skills start OFF, "and you should
|
|
5
6
|
// walk through what comes with each, people need to learn the system". The task
|
|
@@ -9,21 +10,19 @@
|
|
|
9
10
|
// every step, no control that decides without the person seeing each skill, and
|
|
10
11
|
// nothing written until the recap is saved.
|
|
11
12
|
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
13
|
+
// THE SAFETY STEP. A speciality someone else wrote puts their prose into your
|
|
14
|
+
// sessions, so its full instructions are on the card, open, before the control
|
|
15
|
+
// that adopts it — pinned below on both pages.
|
|
16
|
+
//
|
|
17
|
+
// TWO PAGES, ONE COMPONENT (task 1005052). modules/hall-ui/public/speciality-tools.js
|
|
18
|
+
// is mounted by Settings and by My agents. Every case runs once per page, booted
|
|
19
|
+
// on THAT page's own markup (tests/helpers.mjs bootSpecialityTools), so a host
|
|
20
|
+
// lost from either page fails that page's run.
|
|
16
21
|
//
|
|
17
22
|
// Run: node tests/speciality_walkthrough_ui.mjs
|
|
18
23
|
import assert from 'node:assert/strict';
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
import vm from 'node:vm';
|
|
22
|
-
import { fileURLToPath } from 'node:url';
|
|
23
|
-
import { makeRunner } from './helpers.mjs';
|
|
24
|
-
|
|
25
|
-
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
26
|
-
const SRC = fs.readFileSync(path.join(ROOT, 'modules/hall-ui/public/settings-specialities.js'), 'utf8');
|
|
24
|
+
import { makeRunner, bootSpecialityTools, SPECIALITY_PAGES } from './helpers.mjs';
|
|
25
|
+
|
|
27
26
|
const { test, summary } = makeRunner();
|
|
28
27
|
|
|
29
28
|
const explained = (name, extra = {}) => ({
|
|
@@ -56,163 +55,183 @@ const SKILLS_BODY = {
|
|
|
56
55
|
],
|
|
57
56
|
};
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const els = new Map();
|
|
64
|
-
const handlers = new Map();
|
|
65
|
-
const makeEl = (id) => ({
|
|
66
|
-
id, hidden: id === 'specialities-scroll', innerHTML: '', textContent: '', elements: {},
|
|
67
|
-
addEventListener(type, fn) { handlers.set(`${id}:${type}`, fn); },
|
|
68
|
-
});
|
|
69
|
-
for (const id of ['specialities-scroll', 'specialities-rows', 'speciality-suggestions', 'specialities-status']) els.set(id, makeEl(id));
|
|
70
|
-
let focused = null;
|
|
71
|
-
|
|
72
|
-
const fetch = async (url, opts = {}) => {
|
|
73
|
-
const method = opts.method || 'GET';
|
|
74
|
-
const p = url.replace('/api/bongos', '');
|
|
75
|
-
requests.push({ method, path: p, body: opts.body ? JSON.parse(opts.body) : undefined });
|
|
76
|
-
let body = {};
|
|
77
|
-
if (method === 'GET' && p === '/specialities') body = { specialities: catalog };
|
|
78
|
-
else if (method === 'GET' && p === '/me/specialities') body = { adoptions: [] };
|
|
79
|
-
else if (method === 'GET' && p === '/specialities/offered') body = { suggestions: [] };
|
|
80
|
-
else if (method === 'GET' && /\/skills$/.test(p)) body = skillsBody;
|
|
81
|
-
else if (method === 'POST' && /\/adopt$/.test(p)) body = { adoption: { active: true } };
|
|
82
|
-
else if (method === 'PUT' && /\/skills$/.test(p)) body = { adoption: { enabled_skills: JSON.parse(opts.body).enabled_skills } };
|
|
83
|
-
return { ok: true, status: 200, json: async () => body };
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const document = {
|
|
87
|
-
readyState: 'complete',
|
|
88
|
-
getElementById: (id) => els.get(id) || null,
|
|
89
|
-
addEventListener() {},
|
|
90
|
-
querySelector: (sel) => (sel.includes('data-walk-focus') ? { focus() { focused = 'walk-heading'; } } : null),
|
|
91
|
-
};
|
|
92
|
-
const window = {
|
|
93
|
-
OTB: {
|
|
94
|
-
escapeHtml: (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'),
|
|
95
|
-
$: () => null,
|
|
96
|
-
toast: (m) => toasts.push(m),
|
|
97
|
-
roleAxisLabel: () => 'Role',
|
|
98
|
-
},
|
|
99
|
-
location: { assign() {} },
|
|
100
|
-
};
|
|
101
|
-
vm.runInNewContext(SRC, { window, document, fetch, JSON, Promise, Map, Set, String, Number, Array, Object, Math, RegExp, console });
|
|
102
|
-
const settle = () => new Promise((r) => setTimeout(r, 0));
|
|
103
|
-
for (let i = 0; i < 5; i++) await settle();
|
|
104
|
-
|
|
105
|
-
const rows = els.get('specialities-rows');
|
|
106
|
-
// A click through the delegated handler, on the first button whose attribute matches.
|
|
107
|
-
async function click(attr, value) {
|
|
108
|
-
const re = new RegExp(`<button[^>]*${attr}="${value}"[^>]*>`);
|
|
109
|
-
const tag = re.exec(rows.innerHTML);
|
|
110
|
-
assert.ok(tag, `no ${attr}="${value}" button in:\n${rows.innerHTML}`);
|
|
111
|
-
const dataset = {};
|
|
112
|
-
for (const [, k, v] of tag[0].matchAll(/data-([a-z]+)="([^"]*)"/g)) dataset[k] = v;
|
|
113
|
-
const btn = { dataset };
|
|
114
|
-
const target = { closest: (sel) => (sel === `button[${attr}]` ? btn : null) };
|
|
115
|
-
handlers.get('specialities-rows:click')({ target });
|
|
116
|
-
for (let i = 0; i < 6; i++) await settle();
|
|
117
|
-
}
|
|
118
|
-
const text = () => rows.innerHTML.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ');
|
|
119
|
-
return { els, rows, requests, toasts, click, text, focused: () => focused };
|
|
58
|
+
async function boot(page, { catalog = [speciality()], skillsBody = SKILLS_BODY, ...rest } = {}) {
|
|
59
|
+
const h = bootSpecialityTools({ page, catalog, skills: { 9: skillsBody }, ...rest });
|
|
60
|
+
await h.ready();
|
|
61
|
+
return h;
|
|
120
62
|
}
|
|
63
|
+
const ROWS = '#specialities-rows';
|
|
64
|
+
const writes = (h) => h.writes();
|
|
65
|
+
const text = (h) => h.text('specialities-rows');
|
|
66
|
+
|
|
67
|
+
for (const page of SPECIALITY_PAGES) {
|
|
68
|
+
await test(`${page}: the specialities panel is revealed once its reads answer — it shipped hidden and nothing ever showed it`, async () => {
|
|
69
|
+
const h = await boot(page);
|
|
70
|
+
assert.equal(h.el('specialities-scroll').hidden, false);
|
|
71
|
+
});
|
|
121
72
|
|
|
122
|
-
|
|
73
|
+
await test(`${page}: adopting a speciality that offers skills opens the walkthrough on the FIRST skill, with nothing written yet`, async () => {
|
|
74
|
+
const h = await boot(page);
|
|
75
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
76
|
+
assert.ok(h.requests.some((r) => r.method === 'GET' && r.path === '/specialities/9/skills'), 'the walkthrough read its skills');
|
|
77
|
+
assert.match(text(h), /Skill 1 of 3 in Economics/, 'only INSTALLED skills are steps');
|
|
78
|
+
assert.ok(h.focused() && 'data-walk-focus' in h.focused().attrs, 'focus moves to the step, not left on a button that is gone');
|
|
79
|
+
assert.deepEqual(writes(h).map((r) => r.path), ['/specialities/9/adopt'], 'no enabled set was written by adopting');
|
|
80
|
+
});
|
|
123
81
|
|
|
124
|
-
await test(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
82
|
+
await test(`${page}: it is not a page of checkboxes: one skill per step, and no control decides for several at once`, async () => {
|
|
83
|
+
const h = await boot(page);
|
|
84
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
85
|
+
assert.ok(!/type="checkbox"/.test(h.html('specialities-rows')), 'no checkbox anywhere in the walkthrough');
|
|
86
|
+
assert.ok(!/(turn|enable|select) (them )?all/i.test(text(h)), 'no "turn them all on"');
|
|
87
|
+
assert.ok(text(h).includes('recall') && !text(h).includes('status does its one thing'), 'the next skill is not shown yet');
|
|
88
|
+
});
|
|
128
89
|
|
|
129
|
-
await test(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
90
|
+
await test(`${page}: every step answers what it does, when to reach for it, and what it costs`, async () => {
|
|
91
|
+
const h = await boot(page);
|
|
92
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
93
|
+
for (let step = 0; step < 3; step++) {
|
|
94
|
+
for (const q of ['What it does', 'When to reach for it', 'What it costs']) assert.ok(text(h).includes(q), `step ${step + 1} is missing "${q}"`);
|
|
95
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
137
98
|
|
|
138
|
-
await test(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
99
|
+
await test(`${page}: a rank-gated skill says so BEFORE the choice — turning it on grants nothing`, async () => {
|
|
100
|
+
const h = await boot(page);
|
|
101
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
102
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
103
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
104
|
+
const t = text(h);
|
|
105
|
+
assert.match(t, /Skill 3 of 3/);
|
|
106
|
+
assert.match(t, /Metic rank or above.*does not change that/);
|
|
107
|
+
assert.match(t, /What it needs on your machine gh/);
|
|
108
|
+
});
|
|
145
109
|
|
|
146
|
-
await test(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
110
|
+
await test(`${page}: the recap names every skill with what it does and the choice made, then saves exactly the ones turned on`, async () => {
|
|
111
|
+
const h = await boot(page);
|
|
112
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
113
|
+
await h.click(`${ROWS} button[data-walk="on"]`);
|
|
114
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
115
|
+
await h.click(`${ROWS} button[data-walk="on"]`);
|
|
116
|
+
const t = text(h);
|
|
117
|
+
assert.match(t, /Your choices for Economics/);
|
|
118
|
+
assert.match(t, /2 of 3 turned on/);
|
|
119
|
+
for (const n of ['recall', 'status', 'goal-review']) assert.ok(t.includes(`${n} does its one thing.`), `the recap restates what ${n} does`);
|
|
120
|
+
assert.ok(!t.includes('And a second sentence'), 'one line each, not the whole description again');
|
|
121
|
+
assert.match(t, /no longer on this project.*gone/, 'an offered skill removed since is named, not offered');
|
|
122
|
+
assert.equal(writes(h).length, 1, 'still nothing written before Save');
|
|
123
|
+
await h.click(`${ROWS} button[data-walk="save"]`);
|
|
124
|
+
const put = writes(h).find((r) => r.method === 'PUT');
|
|
125
|
+
assert.ok(put, 'Save wrote the set');
|
|
126
|
+
assert.equal(put.path, '/specialities/9/skills');
|
|
127
|
+
assert.deepEqual(put.body, { enabled_skills: ['recall', 'goal-review'] });
|
|
128
|
+
assert.ok(h.toasts.some((m) => /2 of 3/.test(m)));
|
|
129
|
+
});
|
|
155
130
|
|
|
156
|
-
await test(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
131
|
+
await test(`${page}: Back revisits a decision and the new choice is the one saved`, async () => {
|
|
132
|
+
const h = await boot(page);
|
|
133
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
134
|
+
await h.click(`${ROWS} button[data-walk="on"]`);
|
|
135
|
+
await h.click(`${ROWS} button[data-walk="back"]`);
|
|
136
|
+
assert.match(text(h), /Skill 1 of 3/);
|
|
137
|
+
assert.match(h.html('specialities-rows'), /data-walk="on" aria-pressed="true"/, 'the earlier choice shows when you step back to it');
|
|
138
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
139
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
140
|
+
await h.click(`${ROWS} button[data-walk="off"]`);
|
|
141
|
+
await h.click(`${ROWS} button[data-walk="save"]`);
|
|
142
|
+
assert.deepEqual(writes(h).find((r) => r.method === 'PUT').body, { enabled_skills: [] });
|
|
143
|
+
});
|
|
166
144
|
|
|
167
|
-
await test(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
assert.match(t, /2 of 3 turned on/);
|
|
176
|
-
for (const n of ['recall', 'status', 'goal-review']) assert.ok(t.includes(`${n} does its one thing.`), `the recap restates what ${n} does`);
|
|
177
|
-
assert.ok(!t.includes('And a second sentence'), 'one line each, not the whole description again');
|
|
178
|
-
assert.match(t, /no longer on this project.*gone/, 'an offered skill removed since is named, not offered');
|
|
179
|
-
assert.equal(writes(h).length, 1, 'still nothing written before Save');
|
|
180
|
-
await h.click('data-walk', 'save');
|
|
181
|
-
const put = writes(h).find((r) => r.method === 'PUT');
|
|
182
|
-
assert.ok(put, 'Save wrote the set');
|
|
183
|
-
assert.equal(put.path, '/specialities/9/skills');
|
|
184
|
-
assert.deepEqual(put.body, { enabled_skills: ['recall', 'goal-review'] });
|
|
185
|
-
assert.ok(h.toasts.some((m) => /2 of 3/.test(m)));
|
|
186
|
-
});
|
|
145
|
+
await test(`${page}: finishing later writes nothing, so every skill stays off — the default the ruling asked for`, async () => {
|
|
146
|
+
const h = await boot(page);
|
|
147
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
148
|
+
await h.click(`${ROWS} button[data-walk="on"]`);
|
|
149
|
+
await h.click(`${ROWS} button[data-walk="close"]`);
|
|
150
|
+
assert.ok(!/skill-walk/.test(h.html('specialities-rows')), 'the walkthrough closed');
|
|
151
|
+
assert.ok(!writes(h).some((r) => r.method === 'PUT'), 'a half-finished walk saves nothing');
|
|
152
|
+
});
|
|
187
153
|
|
|
188
|
-
await test(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
assert.match(h.rows.innerHTML, /data-walk="on" aria-pressed="true"/, 'the earlier choice shows when you step back to it');
|
|
195
|
-
await h.click('data-walk', 'off');
|
|
196
|
-
await h.click('data-walk', 'off');
|
|
197
|
-
await h.click('data-walk', 'off');
|
|
198
|
-
await h.click('data-walk', 'save');
|
|
199
|
-
assert.deepEqual(writes(h).find((r) => r.method === 'PUT').body, { enabled_skills: [] });
|
|
200
|
-
});
|
|
154
|
+
await test(`${page}: a speciality that offers no skills adopts without a walkthrough`, async () => {
|
|
155
|
+
const h = await boot(page, { catalog: [speciality({ skills: [] })] });
|
|
156
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
157
|
+
assert.ok(!h.requests.some((r) => /\/skills$/.test(r.path)), 'no skills read for a speciality with none');
|
|
158
|
+
assert.ok(!/skill-walk/.test(h.html('specialities-rows')));
|
|
159
|
+
});
|
|
201
160
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
await
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
});
|
|
161
|
+
// ---- the safety step, and the rest of the adopter's tools (task 1005052) ----
|
|
162
|
+
|
|
163
|
+
await test(`${page}: SAFETY — someone else's speciality shows its full instructions, open, in the same card as the only control that adopts it`, async () => {
|
|
164
|
+
const contract = 'Argue from mechanism, not vibes.\nAlways name the assumption a number rests on.';
|
|
165
|
+
const h = await boot(page, { catalog: [speciality({ contract_md: contract })], suggestions: [speciality({ id: 21, name: 'Rates', contract_md: contract })] });
|
|
166
|
+
for (const host of ['specialities-rows', 'speciality-suggestions']) {
|
|
167
|
+
const card = h.find(`#${host} li[data-id]`);
|
|
168
|
+
assert.ok(card, `${host}: the speciality has a card`);
|
|
169
|
+
const details = card.querySelector('details');
|
|
170
|
+
assert.ok(details && details.open, `${host}: its instructions are OPEN, not folded behind a summary`);
|
|
171
|
+
assert.equal(card.querySelector('pre').textContent, contract, `${host}: the whole instruction, word for word`);
|
|
172
|
+
assert.match(card.querySelector('summary').textContent, /written by someone else/, `${host}: and whose they are`);
|
|
173
|
+
assert.match(details.textContent, /You did not write this\. Read it before using the speciality/);
|
|
174
|
+
assert.ok(card.querySelector('button[data-act="adopt"]'), `${host}: the adopt control is in that same card`);
|
|
175
|
+
}
|
|
176
|
+
assert.equal(h.find('button[data-adopt]'), null, 'no other control adopts it');
|
|
177
|
+
});
|
|
210
178
|
|
|
211
|
-
await test(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
179
|
+
await test(`${page}: a speciality you use can be stopped: one POST /abandon, and the card offers it again`, async () => {
|
|
180
|
+
const h = await boot(page, { adoptions: [{ id: 9, active: true, enabled_skills: ['recall'] }] });
|
|
181
|
+
assert.match(text(h), /active/, 'the card says it is in use');
|
|
182
|
+
assert.match(text(h), /offers 4 skills, 1 on for you/, 'and how many of its skills are on');
|
|
183
|
+
assert.equal(h.find(`${ROWS} button[data-act="adopt"]`), null, 'in use: no "Use this"');
|
|
184
|
+
await h.click(`${ROWS} button[data-act="abandon"]`);
|
|
185
|
+
assert.deepEqual(writes(h).map((r) => `${r.method} ${r.path}`), ['POST /specialities/9/abandon']);
|
|
186
|
+
assert.ok(h.toasts.includes('Stopped using it.'));
|
|
187
|
+
assert.ok(h.find(`${ROWS} button[data-act="adopt"]`), 'stopped: it can be taken on again');
|
|
188
|
+
assert.equal(h.find(`${ROWS} button[data-act="abandon"]`), null);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
await test(`${page}: stopping a speciality closes its walkthrough if it was open`, async () => {
|
|
192
|
+
const h = await boot(page, { adoptions: [{ id: 9, active: true, enabled_skills: [] }] });
|
|
193
|
+
await h.click(`${ROWS} button[data-act="walk"]`);
|
|
194
|
+
assert.match(h.html('specialities-rows'), /skill-walk/);
|
|
195
|
+
await h.click(`${ROWS} button[data-act="abandon"]`);
|
|
196
|
+
assert.ok(!/skill-walk/.test(h.html('specialities-rows')), 'no walkthrough for a speciality you stopped using');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await test(`${page}: "Choose its skills" reopens the walkthrough for one you use, and says which are on now`, async () => {
|
|
200
|
+
const h = await boot(page, { adoptions: [{ id: 9, active: true, enabled_skills: ['recall'] }], skillsBody: { ...SKILLS_BODY, enabled: ['recall'] } });
|
|
201
|
+
await h.click(`${ROWS} button[data-act="walk"]`);
|
|
202
|
+
assert.match(text(h), /Skill 1 of 3 in Economics/);
|
|
203
|
+
assert.match(text(h), /You have this one on at the moment/);
|
|
204
|
+
assert.equal(writes(h).length, 0, 'opening it writes nothing');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
await test(`${page}: a suggestion adopts through the same act as the catalogue`, async () => {
|
|
208
|
+
const h = await boot(page, { suggestions: [speciality({ id: 21, name: 'Rates', skills: [] })] });
|
|
209
|
+
assert.match(h.text('speciality-suggestions'), /Suggested for you.*Rates/);
|
|
210
|
+
await h.click('#speciality-suggestions button[data-act="adopt"]');
|
|
211
|
+
assert.deepEqual(writes(h).map((r) => `${r.method} ${r.path}`), ['POST /specialities/21/adopt']);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
await test(`${page}: adopting, stopping and saving its skills each tell the rest of the page, so what a session reads can be re-read`, async () => {
|
|
215
|
+
const h = await boot(page);
|
|
216
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
217
|
+
assert.deepEqual(h.events, ['otb:specialities-changed'], 'adopting');
|
|
218
|
+
for (let i = 0; i < 3; i++) await h.click(`${ROWS} button[data-walk="off"]`);
|
|
219
|
+
await h.click(`${ROWS} button[data-walk="save"]`);
|
|
220
|
+
assert.equal(h.events.length, 2, 'saving the skills');
|
|
221
|
+
await h.click(`${ROWS} button[data-act="abandon"]`);
|
|
222
|
+
assert.equal(h.events.length, 3, 'stopping');
|
|
223
|
+
const quiet = await boot(page, { catalog: [speciality({ mine: true })] });
|
|
224
|
+
await quiet.click(`${ROWS} button[data-act="train"]`);
|
|
225
|
+
assert.deepEqual(quiet.events, [], 'opening a tool that changes no session says nothing');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
await test(`${page}: a refused adopt says why and changes nothing`, async () => {
|
|
229
|
+
const h = await boot(page, { answer: (m, p) => (m === 'POST' && /\/adopt$/.test(p) ? { status: 409, data: { message: 'already_adopted' } } : null) });
|
|
230
|
+
await h.click(`${ROWS} button[data-act="adopt"]`);
|
|
231
|
+
assert.equal(h.el('specialities-status').textContent, 'already_adopted');
|
|
232
|
+
assert.ok(!/skill-walk/.test(h.html('specialities-rows')), 'no walkthrough for an adopt that did not happen');
|
|
233
|
+
assert.deepEqual(h.events, [], 'and nothing told the page it changed');
|
|
234
|
+
});
|
|
235
|
+
}
|
|
217
236
|
|
|
218
237
|
summary();
|