@webship-js/espocrm-steps 0.0.0-stage → 2.0.0

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.
@@ -0,0 +1,434 @@
1
+ 'use strict';
2
+
3
+ // Case step definitions: the test content a scenario makes and removes (a case made by the managing user through the
4
+ // site's REST API, removed after the scenario), a new case through the site's form, one case and what a person does on
5
+ // it (a post on its stream, its status, its assignee, its teams), what it shows, and what a user may not see or do.
6
+ //
7
+ // The site is one page: a change saves without a page load, and the steps wait for the record and the stream to show
8
+ // it. Name test content "Webship test …": the Workspace's `cmd-tools-espocrm-cli.sh <site> --tidy` removes what a
9
+ // stopped run left.
10
+
11
+ const { Given, When, Then, After, AfterAll } = require('@cucumber/cucumber');
12
+ const { friendly } = require('webship-js/tests/step-definitions/webship');
13
+ const {
14
+ budget, exactly, tidy, open, pageTitle, notices, actOrExplain, waitForValue, api, disposeApi, findCases, caseNamed,
15
+ teamId, remember, removeCases, pickOption, pickSuggestion, waitForRecord, consoleMark, allowConsole,
16
+ } = require('./espocrm-helpers');
17
+
18
+ /** The case on screen, or a friendly error. */
19
+ function current(world) {
20
+ const c = world.espocrm && world.espocrm.case;
21
+ if (!c) throw friendly({ message: 'No case is open.', hint: 'Open one first with When I open the case "…".' });
22
+ return c;
23
+ }
24
+
25
+ /** A field of the record on screen. */
26
+ function cell(world, name) {
27
+ return world.page.locator(`.record .cell[data-name="${name}"]`).first();
28
+ }
29
+
30
+ /** The value a field of the record on screen shows (its label left out). */
31
+ async function shown(world, name) {
32
+ const c = cell(world, name);
33
+ const all = tidy(await c.innerText().catch(() => ''));
34
+ const label = tidy(await c.locator('label').first().innerText().catch(() => ''));
35
+ return label && all.startsWith(label) ? tidy(all.slice(label.length)) : all;
36
+ }
37
+
38
+ /** Open a case's page and wait for its record. */
39
+ async function showCase(world, c) {
40
+ world.espocrm = Object.assign(world.espocrm || {}, { case: c });
41
+ await open(world, `#Case/view/${c.id}`);
42
+ }
43
+
44
+ /** The stream of the case on screen, newest first: each entry's text. */
45
+ async function stream(world) {
46
+ return (await world.page.locator('.panel[data-name="stream"] .list-group-item').allInnerTexts().catch(() => [])).map(tidy);
47
+ }
48
+
49
+ /**
50
+ * Wait until the stream of the case on screen holds an entry: the panel refreshes on its own schedule after a change, so
51
+ * when the entry is not there after a short wait the case is opened again (as a person reloads it), and waited for.
52
+ */
53
+ async function waitForStream(world, test) {
54
+ const first = await waitForValue(() => stream(world), (list) => list.some(test), Math.min(5000, budget(world)));
55
+ if (first.ok) return first;
56
+ await showCase(world, current(world));
57
+ await world.page.locator('.panel[data-name="stream"]').first().waitFor({ state: 'visible', timeout: budget(world) }).catch(() => {});
58
+ return waitForValue(() => stream(world), (list) => list.some(test), budget(world));
59
+ }
60
+
61
+ /** Edit the record on screen (its Edit button), do what the step does, and save it; wait until it shows again. */
62
+ async function editAndSave(world, fn) {
63
+ const page = world.page;
64
+ const edit = page.locator('.detail-button-container button[data-action="edit"]').first();
65
+ if (!(await edit.isVisible().catch(() => false))) throw new Error('the case offers no Edit (the user may not change it)');
66
+ await edit.click();
67
+ await page.locator('.detail-button-container button[data-action="save"]').first().waitFor({ state: 'visible', timeout: budget(world) });
68
+ await fn();
69
+ await page.locator('.detail-button-container button[data-action="save"]').first().click();
70
+ const back = await waitForValue(() => edit.isVisible(), (v) => v, budget(world) * 2);
71
+ if (!back.ok) {
72
+ const said = (await notices(page)).join(' ') || tidy(await page.locator('.record .has-error').allInnerTexts().then((t) => t.join(' ')).catch(() => ''));
73
+ throw new Error(`the case was not saved${said ? `: ${said}` : ''}`);
74
+ }
75
+ }
76
+
77
+ // ---------------------------------------------------------------------------
78
+ // Test content
79
+ // ---------------------------------------------------------------------------
80
+
81
+ /**
82
+ * Make a case as the managing user through the site's REST API: status New, nobody assigned, in a team (the team of
83
+ * cucumber.js unless the step names one). A case of the name a stopped run left goes first. It goes after the
84
+ * scenario.
85
+ *
86
+ * Example #1: Given there is a case "Webship test post"
87
+ * Example #2: Given there is a case "Webship test sales" in the team "Sales"
88
+ * Example #3: And there is a case "Webship test status"
89
+ * Example #4: Given there is a case "Webship test list" in the team "Support"
90
+ * Example #5: Given there is a case "Webship test work"
91
+ *
92
+ */
93
+ Given(/^there is a case "([^"]*)"(?: in the team "([^"]*)")?$/, async function (name, team) {
94
+ await removeCases(this, name);
95
+ remember(this, name);
96
+ const id = await teamId(this, team || (this.parameters && this.parameters.team) || 'Support');
97
+ const made = await api(this, 'POST', '/Case', { name, status: 'New', teamsIds: [id], assignedUserId: null, description: 'Made by a test scenario; it goes after the scenario.' });
98
+ this.espocrm = Object.assign(this.espocrm || {}, { case: { id: made.id, name, number: made.number } });
99
+ });
100
+
101
+ /**
102
+ * Make sure there is no case of the name: one there is removed, as the managing user.
103
+ *
104
+ * Example #1: Given there is no case "Webship test new"
105
+ * Example #2: Given there is no case "Webship test made"
106
+ * Example #3: And there is no case "Webship test new"
107
+ * Example #4: Then there is no case "Webship test new"
108
+ * Example #5: Given there is no case "Webship test made"
109
+ *
110
+ */
111
+ Given(/^there is no case "([^"]*)"$/, async function (name) {
112
+ await removeCases(this, name);
113
+ });
114
+
115
+ // ---------------------------------------------------------------------------
116
+ // A new case
117
+ // ---------------------------------------------------------------------------
118
+
119
+ /**
120
+ * Create a case as the session's user through the site's form (Cases, Create): its name and, when the step gives one,
121
+ * its description; the site puts it in its maker's default team (and assigns it to its maker only when the maker's
122
+ * role may not assign cases). It goes after the scenario.
123
+ *
124
+ * Example #1: When I create a case "Webship test made"
125
+ * Example #2: When I create a case "Webship test made" with the description "The page title shows the old name."
126
+ * Example #3: And we create a case "Webship test made"
127
+ * Example #4: When I create a case "Webship test made" with the description "Seen on the test site."
128
+ * Example #5: When create a case "Webship test made"
129
+ *
130
+ */
131
+ When(/^(I |we )*create a case "([^"]*)"(?: with the description "([^"]*)")?$/, async function (pronounCase, name, description) {
132
+ remember(this, name);
133
+ await actOrExplain('create the case', name, async () => {
134
+ await open(this, '#Case/create');
135
+ await cell(this, 'name').locator('input').waitFor({ state: 'visible', timeout: budget(this) * 2 });
136
+ await cell(this, 'name').locator('input').fill(name);
137
+ if (description) await cell(this, 'description').locator('textarea').fill(description);
138
+ await this.page.locator('.detail-button-container button[data-action="save"]').first().click();
139
+ const saved = await waitForValue(() => this.page.url(), (u) => /#Case\/view\/[0-9a-f]+/.test(u), budget(this) * 2);
140
+ if (!saved.ok) throw new Error('the site did not open the new case');
141
+ }, 'Cases, Create: the form has Name and Description, and Save opens the new case.');
142
+ const id = this.page.url().match(/#Case\/view\/([0-9a-f]+)/)[1];
143
+ await waitForRecord(this);
144
+ this.espocrm = Object.assign(this.espocrm || {}, { case: { id, name } });
145
+ });
146
+
147
+ // ---------------------------------------------------------------------------
148
+ // One case
149
+ // ---------------------------------------------------------------------------
150
+
151
+ /**
152
+ * Open a case by its name (found by the managing user).
153
+ *
154
+ * Example #1: When I open the case "Webship test post"
155
+ * Example #2: When I open the case "The login page does not keep the user name"
156
+ * Example #3: And we open the case "Exported reports have no date"
157
+ * Example #4: Given I open the case "Webship test status"
158
+ * Example #5: When open the case "The upload error page has no way back"
159
+ *
160
+ */
161
+ When(/^(I |we )*open the case "([^"]*)"$/, async function (pronounCase, name) {
162
+ const c = await caseNamed(this, name);
163
+ await showCase(this, c);
164
+ await actOrExplain('open the case', name, () => waitForRecord(this), 'To assert a refusal, use Then I should be refused the case "…".');
165
+ });
166
+
167
+ /**
168
+ * Post on the stream of the case on screen (its "Write your comment here" box and "Post").
169
+ *
170
+ * Example #1: When I post "Checked on the test site" on the case
171
+ * Example #2: When I post "It happens in every browser" on the case
172
+ * Example #3: And we post "Fixed in the export" on the case
173
+ * Example #4: When I post "Waiting for the customer" on the case
174
+ * Example #5: When post "Checked on the test site" on the case
175
+ *
176
+ */
177
+ When(/^(I |we )*post "([^"]*)" on the case$/, async function (pronounCase, text) {
178
+ current(this);
179
+ await actOrExplain('post on the case', text, async () => {
180
+ const box = this.page.locator('.panel[data-name="stream"] textarea[data-name="post"]').first();
181
+ await box.waitFor({ state: 'visible', timeout: budget(this) });
182
+ await box.click();
183
+ await box.fill(text);
184
+ const button = this.page.locator('.panel[data-name="stream"] button.post').first();
185
+ await waitForValue(async () => !(await button.getAttribute('class') || '').includes('disabled'), (v) => v, 3000);
186
+ await button.click();
187
+ const posted = await waitForValue(() => stream(this), (list) => list.some((e) => e.includes(text)), budget(this));
188
+ if (!posted.ok) throw new Error('the post did not show on the stream');
189
+ }, 'The case\'s stream has a box ("Write your comment here") and its Post button.');
190
+ });
191
+
192
+ /**
193
+ * Set the status of the case on screen with its status field, in place (New, Assigned, Pending, Closed, Rejected,
194
+ * Duplicate).
195
+ *
196
+ * Example #1: When I set the status of the case to "Pending"
197
+ * Example #2: When I set the status of the case to "Closed"
198
+ * Example #3: And we set the status of the case to "Assigned"
199
+ * Example #4: When I set the status of the case to "Rejected"
200
+ * Example #5: When set the status of the case to "Pending"
201
+ *
202
+ */
203
+ When(/^(I |we )*set the status of the case to "([^"]*)"$/, async function (pronounCase, status) {
204
+ current(this);
205
+ await actOrExplain('set the status of the case to', status, async () => {
206
+ const c = cell(this, 'status');
207
+ const pencil = c.locator('.inline-edit-link');
208
+ // The pencil shows while the pointer is on the field, once the field is drawn again after a change.
209
+ const offered = await waitForValue(async () => { await this.page.mouse.move(0, 0); await c.hover(); return pencil.isVisible(); }, (v) => v, budget(this));
210
+ if (!offered.ok) throw new Error('the status offers no change (the user may not change the case)');
211
+ await pencil.click();
212
+ await pickOption(this, c, status);
213
+ await c.locator('.inline-save-link').click();
214
+ const done = await waitForValue(() => shown(this, 'status'), (v) => exactly(status).test(v), budget(this));
215
+ if (!done.ok) throw new Error(`the status shows "${done.value}"`);
216
+ }, 'The status field changes in place: its pencil, the list of the statuses, and its tick.');
217
+ });
218
+
219
+ /**
220
+ * Assign the case on screen to a user by the name the site shows (its Edit, the Assigned User box, Save), or to nobody
221
+ * ("nobody").
222
+ *
223
+ * Example #1: When I assign the case to "Owner Test"
224
+ * Example #2: When I assign the case to "Developer Test"
225
+ * Example #3: And we assign the case to "nobody"
226
+ * Example #4: When I assign the case to "Owner Test"
227
+ * Example #5: When assign the case to "Developer Test"
228
+ *
229
+ */
230
+ When(/^(I |we )*assign the case to "([^"]*)"$/, async function (pronounCase, who) {
231
+ current(this);
232
+ await actOrExplain('assign the case to', who, () => editAndSave(this, async () => {
233
+ const c = cell(this, 'assignedUser');
234
+ if (/^nobody$/i.test(who)) {
235
+ const clear = c.locator('button[data-action="clearLink"]');
236
+ await clear.waitFor({ state: 'visible', timeout: budget(this) });
237
+ await clear.click();
238
+ return;
239
+ }
240
+ const input = c.locator('input[data-name="assignedUserName"]');
241
+ const editable = await input.waitFor({ state: 'visible', timeout: budget(this) }).then(() => true).catch(() => false);
242
+ if (!editable) throw new Error('the Assigned User field cannot be changed (the user may not assign)');
243
+ await pickSuggestion(this, input, who);
244
+ }), 'The case\'s Edit, then Assigned User: type a name and pick it among the users the session may assign to.');
245
+ });
246
+
247
+ /**
248
+ * Put the case on screen in teams, by their names, instead of the teams it is in (its Edit, the Teams box, Save).
249
+ *
250
+ * Example #1: When I set the teams of the case to "Sales"
251
+ * Example #2: When I set the teams of the case to "Support, Sales"
252
+ * Example #3: And we set the teams of the case to "Support"
253
+ * Example #4: When I set the teams of the case to "Sales"
254
+ * Example #5: When set the teams of the case to "Support"
255
+ *
256
+ */
257
+ When(/^(I |we )*set the teams of the case to "([^"]*)"$/, async function (pronounCase, list) {
258
+ current(this);
259
+ const wanted = list.split(',').map(tidy).filter(Boolean);
260
+ await actOrExplain('set the teams of the case to', list, () => editAndSave(this, async () => {
261
+ const c = cell(this, 'teams');
262
+ await c.locator('.add-team input').first().waitFor({ state: 'visible', timeout: budget(this) });
263
+ for (;;) {
264
+ const x = c.locator('.link-container a[data-action="clearLink"]').first();
265
+ if (!(await x.count())) break;
266
+ await x.click();
267
+ }
268
+ for (const team of wanted) await pickSuggestion(this, c.locator('.add-team input').first(), team);
269
+ }), 'The case\'s Edit, then Teams: a user picks among the teams it is in (an administrator, any team).');
270
+ });
271
+
272
+ /**
273
+ * Assert the status of the case on screen.
274
+ *
275
+ * Example #1: Then the status of the case should be "New"
276
+ * Example #2: Then the status of the case should be "Pending"
277
+ * Example #3: And the status of the case should be "Assigned"
278
+ * Example #4: Then the status of the case should be "Closed"
279
+ * Example #5: Then the status of the case should be "Pending"
280
+ *
281
+ */
282
+ Then(/^the status of the case should be "([^"]*)"$/, async function (status) {
283
+ current(this);
284
+ const result = await waitForValue(() => shown(this, 'status'), (v) => exactly(status).test(v), budget(this));
285
+ if (!result.ok) throw friendly({ message: `Expected the case to be "${status}", but it is "${result.value || 'not shown'}".`, hint: 'The case\'s Status field shows its status.' });
286
+ });
287
+
288
+ /**
289
+ * Assert who the case on screen is assigned to (the name the site shows), or that nobody is.
290
+ *
291
+ * Example #1: Then the case should be assigned to "Owner Test"
292
+ * Example #2: Then the case should be assigned to "Developer Test"
293
+ * Example #3: And the case should not be assigned
294
+ * Example #4: Then the case should be assigned to "Sales Test"
295
+ * Example #5: Then the case should not be assigned
296
+ *
297
+ */
298
+ Then(/^the case should (?:be assigned to "([^"]*)"|not be assigned)$/, async function (who) {
299
+ current(this);
300
+ const test = (v) => (who ? exactly(who).test(v) : /^(None)?$/i.test(v));
301
+ const result = await waitForValue(() => shown(this, 'assignedUser'), test, budget(this));
302
+ if (!result.ok) {
303
+ throw friendly({ message: who ? `Expected the case to be assigned to ${who}, but it is "${result.value || 'nobody'}".` : `Expected nobody to be assigned the case, but it is ${result.value}.`, hint: 'The case\'s Assigned User field shows its assignee ("None" for nobody).' });
304
+ }
305
+ });
306
+
307
+ /**
308
+ * Assert the case on screen is in a team, or is not.
309
+ *
310
+ * Example #1: Then the case should be in the team "Support"
311
+ * Example #2: Then the case should be in the team "Sales"
312
+ * Example #3: And the case should not be in the team "Support"
313
+ * Example #4: Then the case should be in the team "Support"
314
+ * Example #5: But the case should not be in the team "Sales"
315
+ *
316
+ */
317
+ Then(/^the case should( not)? be in the team "([^"]*)"$/, async function (notCase, team) {
318
+ current(this);
319
+ const has = (v) => v.split(/\s*,\s*|\s{2,}|\n/).map(tidy).includes(team) || new RegExp(`(^|\\s)${team.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\s|$)`).test(v);
320
+ const result = await waitForValue(async () => tidy((await cell(this, 'teams').locator('.field').innerText().catch(() => ''))), (v) => has(v) === !notCase, budget(this));
321
+ if (!result.ok) throw friendly({ message: notCase ? `Expected the case not to be in the team ${team}, but it is (${result.value}).` : `Expected the case to be in the team ${team}, but its teams are "${result.value || 'none'}".`, hint: 'The case\'s Teams field lists its teams.' });
322
+ });
323
+
324
+ /**
325
+ * Assert the stream of the case on screen shows a post that holds the text, by the user of that name.
326
+ *
327
+ * Example #1: Then the case should show the post "Checked on the test site" by "Developer Test"
328
+ * Example #2: Then the case should show the post "The session cookie is set too late." by "Owner Test"
329
+ * Example #3: And the case should show the post "Reproduced on the test site." by "Developer Test"
330
+ * Example #4: Then the case should show the post "Waiting for the customer" by "Viewer Test"
331
+ * Example #5: Then the case should show the post "Fixed in the upload settings." by "Developer Test"
332
+ *
333
+ */
334
+ Then(/^the case should show the post "([^"]*)" by "([^"]*)"$/, async function (text, who) {
335
+ current(this);
336
+ const result = await waitForStream(this, (e) => e.startsWith(who + ' ') && e.includes(text));
337
+ if (!result.ok) throw friendly({ message: `Expected the case's stream to show the post "${text}" by ${who}, but it shows ${(result.value || []).slice(0, 6).map((e) => `"${e.slice(0, 60)}"`).join(', ') || 'nothing'}.`, hint: 'The stream shows the posts and the changes of the case, newest first, each with its author\'s name.' });
338
+ });
339
+
340
+ /**
341
+ * Assert the stream of the case on screen shows a change of its status to a value, by the user of that name.
342
+ *
343
+ * Example #1: Then the case should show the status change to "Pending" by "Developer Test"
344
+ * Example #2: Then the case should show the status change to "Closed" by "Developer Test"
345
+ * Example #3: And the case should show the status change to "Assigned" by "Owner Test"
346
+ * Example #4: Then the case should show the status change to "Pending" by "Owner Test"
347
+ * Example #5: Then the case should show the status change to "Closed" by "Developer Test"
348
+ *
349
+ */
350
+ Then(/^the case should show the status change to "([^"]*)" by "([^"]*)"$/, async function (status, who) {
351
+ current(this);
352
+ const re = new RegExp(`^${who.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} updated this case ${status.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`);
353
+ const result = await waitForStream(this, (e) => re.test(e));
354
+ if (!result.ok) throw friendly({ message: `Expected the case's stream to show ${who} changing its status to ${status}, but it shows ${(result.value || []).slice(0, 6).map((e) => `"${e.slice(0, 60)}"`).join(', ') || 'nothing'}.`, hint: 'A change of status shows on the stream as "<name> updated this case <status>".' });
355
+ });
356
+
357
+ /**
358
+ * Assert the session may not change the case on screen: the case offers no Edit and its fields no change in place.
359
+ * The stream's post box may still be there (a user who reads a case may post on its stream).
360
+ *
361
+ * Example #1: Then I should not be able to change the case
362
+ * Example #2: Then we should not be able to change the case
363
+ * Example #3: And I should not be able to change the case
364
+ * Example #4: But I should not be able to change the case
365
+ * Example #5: Then should not be able to change the case
366
+ *
367
+ */
368
+ Then(/^(I |we )*should not be able to change the case$/, async function (pronounCase) {
369
+ current(this);
370
+ await waitForRecord(this);
371
+ const edit = await this.page.locator('.detail-button-container button[data-action="edit"]:visible').count();
372
+ await this.page.mouse.move(0, 0);
373
+ await cell(this, 'status').hover();
374
+ const pencil = await cell(this, 'status').locator('.inline-edit-link:visible').count();
375
+ if (edit || pencil) throw friendly({ message: `Expected the case to offer no change, but it offers ${edit ? 'its Edit' : ''}${edit && pencil ? ' and ' : ''}${pencil ? 'a change of its status in place' : ''}.`, hint: 'A user whose role reads cases without editing them sees no Edit and no pencil on the fields.' });
376
+ });
377
+
378
+ /**
379
+ * Open a case by its name (found by the managing user) and assert that the site refuses it to the session: its page
380
+ * "403 You don't have access to this area.". The browser's console logs the site's refusal of that case's address (a
381
+ * 403, and the site's own report of it): this step lets through exactly those lines, logged while it opened that case,
382
+ * and nothing else.
383
+ *
384
+ * Example #1: Then I should be refused the case "The release checklist of the site"
385
+ * Example #2: Then we should be refused the case "Webship test sales"
386
+ * Example #3: And I should be refused the case "The release checklist of the site"
387
+ * Example #4: But I should be refused the case "Exported reports have no date"
388
+ * Example #5: Then should be refused the case "The release checklist of the site"
389
+ *
390
+ */
391
+ Then(/^(I |we )*should be refused the case "([^"]*)"$/, async function (pronounCase, name) {
392
+ const c = await caseNamed(this, name);
393
+ const mark = consoleMark(this);
394
+ await showCase(this, c);
395
+ const read = async () => tidy(await this.page.locator('body').innerText().catch(() => ''));
396
+ const result = await waitForValue(read, (v) => /You don't have access to this area/i.test(v) || /\b403\b/.test(v), budget(this));
397
+ if (!result.ok || !/You don't have access to this area/i.test(result.value)) {
398
+ throw friendly({ message: `Expected the case #${c.number} ("${name}") to be refused, but the page is "${await pageTitle(this)}".`, hint: 'The site refuses a case of a team the user is not in: "403 You don\'t have access to this area.".' });
399
+ }
400
+ // The refusal's own lines: the 403 of this case's address, the site's report of it, and the request it leaves
401
+ // unhandled (an uncaught error whose message is the site's request object, one letter, with no address of its own):
402
+ // that one only when this case's 403 was logged in the same step.
403
+ const own = new RegExp(`/api/v1/Case/${c.id}(?:[/?#].*)?$`);
404
+ const lines = (this._jsErrors || []).slice(mark);
405
+ const refused = lines.some((l) => /^Failed to load resource: the server responded with a status of 403\b/.test(l.message) && own.test(l.url || ''));
406
+ if (refused) {
407
+ allowConsole(this, mark, [
408
+ (l) => /^Failed to load resource: the server responded with a status of 403\b/.test(l.message) && own.test(l.url || ''),
409
+ (l) => l.type === 'console.error' && /^Server side error 403: No 'read' access\.?$/.test(l.message) && /\/client\/lib\/espo[\w.-]*\.js/.test(l.url || ''),
410
+ (l) => (l.type === 'pageerror' || (l.type === 'console.error' && /\/client\/lib\/espo[\w.-]*\.js/.test(l.url || ''))) && /^[A-Za-z]$/.test(l.message),
411
+ ]);
412
+ }
413
+ });
414
+
415
+ // ---------------------------------------------------------------------------
416
+ // After a scenario
417
+ // ---------------------------------------------------------------------------
418
+
419
+ // The cases a scenario made, removed by the managing user through the site's API. A failure to remove one is reported
420
+ // but does not fail the scenario; the Workspace's --tidy removes what is left (and what the site keeps of a removed
421
+ // case).
422
+ After(async function () {
423
+ const made = this.espocrm && this.espocrm.made;
424
+ if (!made || !made.size) return;
425
+ for (const name of made) {
426
+ try { await removeCases(this, name); } catch (err) { console.warn(`The case "${name}" a scenario made could not be removed: ${err.message}`); }
427
+ }
428
+ made.clear();
429
+ });
430
+
431
+ AfterAll(async function () {
432
+ await disposeApi();
433
+ });
434
+