@webship-js/django-steps 0.0.0-stage → 2.0.1

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,258 @@
1
+ 'use strict';
2
+
3
+ // Deleting and the history of an object: the delete confirmation with the
4
+ // related objects it would delete (for one object and for "Delete selected …"),
5
+ // confirming or going back, the refusal when a protected relation keeps the
6
+ // object, and the history page of an object's changes.
7
+
8
+ const { When, Then } = require('@cucumber/cucumber');
9
+ const { friendly } = require('webship-js/tests/step-definitions/webship');
10
+ const {
11
+ clean,
12
+ normal,
13
+ listed,
14
+ hintFor,
15
+ open,
16
+ afterNavigation,
17
+ pageSummary,
18
+ eventually,
19
+ findObjects,
20
+ userName,
21
+ } = require('./django-helpers');
22
+
23
+ /** What the delete confirmation on screen lists: its summary and every object, with the related ones. */
24
+ async function confirmation(page) {
25
+ return page.evaluate(() => {
26
+ const body = document.body.classList;
27
+ const content = document.getElementById('content');
28
+ if (!content || !body.contains('delete-confirmation')) return null;
29
+ const h1 = content.querySelector('h1');
30
+ // The summary: the list after the heading "Summary".
31
+ const summary = [];
32
+ for (const h2 of content.querySelectorAll('h2')) {
33
+ if (/summary/i.test(h2.textContent)) {
34
+ let el = h2.nextElementSibling;
35
+ while (el && el.tagName !== 'UL') el = el.nextElementSibling;
36
+ if (el) for (const li of el.querySelectorAll(':scope > li')) summary.push(li.textContent.replace(/\s+/g, ' ').trim());
37
+ }
38
+ }
39
+ const objects = [...content.querySelectorAll('#deleted-objects li, ul#deleted-objects li, h2 ~ ul li')]
40
+ .map((li) => (li.firstChild && li.firstChild.nodeType === 3 ? li.firstChild.textContent : '') + (li.querySelector(':scope > a') ? li.querySelector(':scope > a').textContent : ''))
41
+ .map((t) => t.replace(/\s+/g, ' ').trim()).filter(Boolean);
42
+ return {
43
+ heading: h1 ? h1.textContent.replace(/\s+/g, ' ').trim() : '',
44
+ refused: !content.querySelector('form input[name="post"]'),
45
+ summary,
46
+ objects: [...new Set(objects)],
47
+ };
48
+ }).catch(() => null);
49
+ }
50
+
51
+ /** The confirmation on screen, or a failure that says what the page is. */
52
+ async function confirmationOrFail(world) {
53
+ const shown = await confirmation(world.page);
54
+ if (shown) return shown;
55
+ throw friendly({ message: `The page is no delete confirmation: ${await pageSummary(world)}.`, hint: hintFor(world, 'Press "Delete" on an object\'s form, or run the action "Delete selected …" on the list.') });
56
+ }
57
+
58
+ /**
59
+ * Assert that the delete confirmation lists (or does not list) an object, as
60
+ * it writes it: the model's name, a colon and the object ("Choice: Yes"). The
61
+ * related objects the deletion takes with it are listed under the object.
62
+ *
63
+ * Example #1: Then the delete confirmation should list "Question: Delete test question"
64
+ * Example #2: Then the delete confirmation should list "Choice: Yes"
65
+ * Example #3: And the delete confirmation should not list "Choice: Maybe"
66
+ * Example #4: Then the delete confirmation should list "Question: Action test question one"
67
+ * Example #5: And the delete confirmation should list "Choice: No"
68
+ */
69
+ Then(/^the delete confirmation should( not)* list "([^"]*)"$/, async function (notCase, object) {
70
+ const shown = await confirmationOrFail(this);
71
+ const has = shown.objects.some((o) => normal(o) === normal(object));
72
+ if (has === !!notCase) {
73
+ throw friendly({ message: notCase ? `The delete confirmation lists "${object}".` : `The delete confirmation does not list "${object}". It lists: ${listed(shown.objects)}.`, hint: 'The confirmation writes each object as "<model>: <object>".' });
74
+ }
75
+ });
76
+
77
+ /**
78
+ * Assert a line of the delete confirmation's summary: how many objects of a
79
+ * model the deletion takes ("Choices: 2").
80
+ *
81
+ * Example #1: Then the delete confirmation should count "Questions: 1"
82
+ * Example #2: Then the delete confirmation should count "Choices: 2"
83
+ * Example #3: And the delete confirmation should count "Questions: 2"
84
+ * Example #4: Then the delete confirmation should count "Choices: 4"
85
+ * Example #5: And the delete confirmation should count "Choices: 3"
86
+ */
87
+ Then(/^the delete confirmation should count "([^"]*)"$/, async function (line) {
88
+ const shown = await confirmationOrFail(this);
89
+ if (!shown.summary.some((s) => normal(s) === normal(line))) {
90
+ throw friendly({ message: `The delete confirmation's summary has no "${line}". It says: ${listed(shown.summary)}.`, hint: 'The summary counts the objects of each model the deletion takes: "<plural>: <count>".' });
91
+ }
92
+ });
93
+
94
+ /**
95
+ * Confirm the deletion on the delete confirmation ("Yes, I’m sure").
96
+ *
97
+ * Example #1: When I confirm the deletion
98
+ * Example #2: When we confirm the deletion
99
+ * Example #3: And I confirm the deletion
100
+ * Example #4: Then I confirm the deletion
101
+ * Example #5: And we confirm the deletion
102
+ */
103
+ When(/^(I |we )*confirm the deletion$/, async function (pronounCase) {
104
+ const shown = await confirmationOrFail(this);
105
+ if (shown.refused) {
106
+ throw friendly({ message: `The deletion cannot be confirmed: the page says "${shown.heading}".`, hint: 'A protected relation keeps the object: the page lists what keeps it.' });
107
+ }
108
+ const page = this.page;
109
+ await afterNavigation(this, () => page.locator('#content form input[name="post"]').locator('xpath=ancestor::form[1]').locator('[type="submit"]').first().click());
110
+ });
111
+
112
+ /**
113
+ * Go back from the delete confirmation without deleting ("No, take me back").
114
+ *
115
+ * Example #1: When I cancel the deletion
116
+ * Example #2: When we cancel the deletion
117
+ * Example #3: And I cancel the deletion
118
+ * Example #4: Then I cancel the deletion
119
+ * Example #5: And we cancel the deletion
120
+ */
121
+ When(/^(I |we )*cancel the deletion$/, async function (pronounCase) {
122
+ await confirmationOrFail(this);
123
+ const page = this.page;
124
+ const back = page.locator('#content a.cancel-link');
125
+ if (!(await back.count())) {
126
+ throw friendly({ message: 'The delete confirmation has no "No, take me back" link.', hint: 'The link goes back to the page the deletion was asked from.' });
127
+ }
128
+ await afterNavigation(this, () => back.first().click());
129
+ });
130
+
131
+ /**
132
+ * Assert that the admin refuses to delete the object because a protected
133
+ * relation keeps it (the page "Cannot delete …"), and with "because of" one
134
+ * object it names as keeping it.
135
+ *
136
+ * Example #1: Then the deletion should be refused
137
+ * Example #2: Then the deletion should be refused because of "Question: Which river is the longest?"
138
+ * Example #3: And the deletion should be refused because of "Question: How far is the nearest star?"
139
+ * Example #4: Then the deletion should be refused because of "Question: Delete test question"
140
+ * Example #5: And the deletion should be refused
141
+ */
142
+ Then(/^the deletion should be refused(?: because of "([^"]*)")?$/, async function (object) {
143
+ const shown = await confirmationOrFail(this);
144
+ if (!shown.refused) {
145
+ throw friendly({ message: `The deletion is not refused: the page "${shown.heading}" asks to confirm it.`, hint: 'The admin refuses a deletion that a protected relation (on_delete=PROTECT) keeps.' });
146
+ }
147
+ if (object && !shown.objects.some((o) => normal(o) === normal(object))) {
148
+ throw friendly({ message: `The refusal does not name "${object}". It names: ${listed(shown.objects)}.`, hint: 'The refusal writes each object that keeps the deletion as "<model>: <object>".' });
149
+ }
150
+ });
151
+
152
+ /**
153
+ * Delete an object of a model's list, by its text, the way a person does:
154
+ * open it, press "Delete", then confirm.
155
+ *
156
+ * Example #1: When I delete "Delete test question" from the "Questions" list
157
+ * Example #2: When we delete "Inline test question" from the "Questions" list
158
+ * Example #3: And I delete "Reviewers" from the "Groups" list
159
+ * Example #4: When I delete "Test tag" from the "Tags" list
160
+ * Example #5: And we delete "History test question" from the "Questions" list
161
+ */
162
+ When(/^(I |we )*delete "([^"]*)" from the "([^"]*)" list$/, async function (pronounCase, object, model) {
163
+ const urls = await findObjects(this, model, object);
164
+ if (!urls.length) {
165
+ throw friendly({ message: `The "${model}" list has no "${object}" to delete.`, hint: 'Write the object as its list shows it in the first column.' });
166
+ }
167
+ await open(this, urls[0]);
168
+ const page = this.page;
169
+ const link = page.locator('.submit-row a.deletelink, a.deletelink');
170
+ if (!(await link.count())) {
171
+ throw friendly({ message: `The page of "${object}" has no "Delete" link: ${await pageSummary(this)}.`, hint: 'The account may not delete objects of this model.' });
172
+ }
173
+ await afterNavigation(this, () => link.first().click());
174
+ const shown = await confirmationOrFail(this);
175
+ if (shown.refused) {
176
+ throw friendly({ message: `The admin refuses to delete "${object}": ${listed(shown.objects)} keep it.`, hint: 'A protected relation keeps the object: delete what keeps it first.' });
177
+ }
178
+ await afterNavigation(this, () => page.locator('#content form input[name="post"]').locator('xpath=ancestor::form[1]').locator('[type="submit"]').first().click());
179
+ });
180
+
181
+ /** The entries of the history page on screen: when, who, what. */
182
+ async function historyEntries(page) {
183
+ return page.evaluate(() => [...document.querySelectorAll('#change-history tbody tr')].map((tr) => {
184
+ const cells = [...tr.children].map((c) => c.textContent.replace(/\s+/g, ' ').trim());
185
+ return { when: cells[0] || '', user: cells[1] || '', action: cells[2] || '' };
186
+ })).catch(() => []);
187
+ }
188
+
189
+ /**
190
+ * Open the history of the object whose form is on screen (its "History"
191
+ * link), or of an object of a model's list, by its text.
192
+ *
193
+ * Example #1: When I open the history
194
+ * Example #2: When I open the history of "History test question" in the "Questions" list
195
+ * Example #3: And we open the history
196
+ * Example #4: When we open the history of "editor" in the "Users" list
197
+ * Example #5: And I open the history of "What's up?" in the "Questions" list
198
+ */
199
+ When(/^(I |we )*open the history(?: of "([^"]*)" in the "([^"]*)" list)?$/, async function (pronounCase, object, model) {
200
+ const page = this.page;
201
+ if (object) {
202
+ const urls = await findObjects(this, model, object);
203
+ if (!urls.length) throw friendly({ message: `The "${model}" list has no "${object}".`, hint: 'Write the object as its list shows it in the first column.' });
204
+ await open(this, urls[0].replace(/change\/?$/, '') + 'history/');
205
+ return;
206
+ }
207
+ const link = page.locator('.object-tools a.historylink');
208
+ if (!(await link.count())) {
209
+ throw friendly({ message: `The page has no "History" link: ${await pageSummary(this)}.`, hint: hintFor(this, 'Open an object\'s form first.') });
210
+ }
211
+ await afterNavigation(this, () => link.first().click());
212
+ });
213
+
214
+ /**
215
+ * Assert that the history lists (or does not list) an entry: what was done,
216
+ * as the admin writes it ("Added.", "Changed Question text."), and with "by"
217
+ * the account (a handle of the users registry or a user name).
218
+ *
219
+ * Example #1: Then the history should list "Added."
220
+ * Example #2: Then the history should list "Changed Question text." by "editor"
221
+ * Example #3: And the history should list "Added choice “Yes”." by "administrator"
222
+ * Example #4: Then the history should not list "Deleted choice"
223
+ * Example #5: And the history should list "Added." by "editor"
224
+ */
225
+ Then(/^the history should( not)* list "([^"]*)"(?: by "([^"]*)")?$/, async function (notCase, action, who) {
226
+ const page = this.page;
227
+ if (!(await page.locator('#change-history').count())) {
228
+ throw friendly({ message: `The page is no history page: ${await pageSummary(this)}.`, hint: 'Open it with: When I open the history' });
229
+ }
230
+ const entries = await historyEntries(page);
231
+ const user = who ? userName(this, who) : null;
232
+ const has = entries.some((e) => normal(e.action).includes(normal(action)) && (!user || normal(e.user) === normal(user)));
233
+ if (has === !!notCase) {
234
+ throw friendly({
235
+ message: notCase ? `The history lists "${action}"${user ? ` by "${user}"` : ''}.` : `The history does not list "${action}"${user ? ` by "${user}"` : ''}. It lists: ${listed(entries.map((e) => `${e.action} (${e.user})`))}.`,
236
+ hint: 'The history lists every change made through the admin, oldest first.',
237
+ });
238
+ }
239
+ });
240
+
241
+ /**
242
+ * Assert how many entries the history of an object has.
243
+ *
244
+ * Example #1: Then the history should have 1 entry
245
+ * Example #2: Then the history should have 2 entries
246
+ * Example #3: And the history should have 3 entries
247
+ * Example #4: Then the history should have 2 entries
248
+ * Example #5: And the history should have 1 entry
249
+ */
250
+ Then(/^the history should have (\d+) entr(?:y|ies)$/, async function (expected) {
251
+ const page = this.page;
252
+ const entries = await eventually(this, () => historyEntries(page), () => true, () => ({ message: '' }), 1);
253
+ if (entries.length !== parseInt(expected, 10)) {
254
+ throw friendly({ message: `The history has ${entries.length} entr${entries.length === 1 ? 'y' : 'ies'}, not ${expected}: ${listed(entries.map((e) => e.action))}.`, hint: 'Each save through the admin adds an entry.' });
255
+ }
256
+ });
257
+
258
+ module.exports = { confirmation, clean };
@@ -0,0 +1,209 @@
1
+ 'use strict';
2
+
3
+ // The inline rows of a form: the objects edited on the page of another (the
4
+ // choices of a question), in a table (tabular) or one under another (stacked):
5
+ // how many rows, adding a row, removing one, setting and reading a field of a
6
+ // row, and what the rows list.
7
+
8
+ const { When, Then } = require('@cucumber/cucumber');
9
+ const { friendly } = require('webship-js/tests/step-definitions/webship');
10
+ const {
11
+ clean,
12
+ normal,
13
+ listed,
14
+ eventually,
15
+ setField,
16
+ readField,
17
+ inlineGroup,
18
+ inlineRows,
19
+ inlineRow,
20
+ } = require('./django-helpers');
21
+
22
+ /** How many rows an inline group shows (saved and new; the hidden template left out). */
23
+ async function rowCount(inline) {
24
+ return inlineRows(inline).count();
25
+ }
26
+
27
+ /** Every value a row shows: its inputs' values, its chosen options, its texts. */
28
+ async function rowValues(row) {
29
+ return row.evaluate((r) => {
30
+ const out = [];
31
+ for (const el of r.querySelectorAll('input:not([type=hidden]):not([type=checkbox]):not([type=radio]), textarea')) if (el.value) out.push(el.value);
32
+ for (const el of r.querySelectorAll('select')) for (const o of el.selectedOptions) if (o.value) out.push(o.textContent);
33
+ for (const el of r.querySelectorAll('.readonly, td.original p, td.field-__str__, td p')) if (el.textContent.trim()) out.push(el.textContent);
34
+ return out.map((t) => t.replace(/\s+/g, ' ').trim()).filter(Boolean);
35
+ });
36
+ }
37
+
38
+ /**
39
+ * Assert how many rows an inline shows, by its heading ("Choices"): the saved
40
+ * rows and the new ones, the template the admin copies new rows from left out.
41
+ *
42
+ * Example #1: Then the "Choices" inline should have 3 rows
43
+ * Example #2: Then the "Choices" inline should have 4 rows
44
+ * Example #3: And the "Questions" inline should have 1 row
45
+ * Example #4: Then the "Choices" inline should have 2 rows
46
+ * Example #5: And the "Questions" inline should have 5 rows
47
+ */
48
+ Then(/^the "([^"]*)" inline should have (\d+) rows?$/, async function (name, expected) {
49
+ const inline = await inlineGroup(this, name);
50
+ await eventually(this, () => rowCount(inline), (n) => n === parseInt(expected, 10),
51
+ (n) => ({ message: `The inline "${name}" has ${n} row${n === 1 ? '' : 's'}, not ${expected}.`, hint: 'A new form shows the extra rows of the inline (extra); "Add another …" adds one, "Remove" takes a new one away.' }), 3000);
52
+ });
53
+
54
+ /**
55
+ * Add a row to an inline with its "Add another …" link, as a person does.
56
+ *
57
+ * Example #1: When I add a row to the "Choices" inline
58
+ * Example #2: When we add a row to the "Choices" inline
59
+ * Example #3: And I add a row to the "Questions" inline
60
+ * Example #4: When I add a row to the "Choices" inline
61
+ * Example #5: And we add a row to the "Questions" inline
62
+ */
63
+ When(/^(I |we )*add a row to the "([^"]*)" inline$/, async function (pronounCase, name) {
64
+ const inline = await inlineGroup(this, name);
65
+ const before = await rowCount(inline);
66
+ const link = inline.group.locator('.add-row a');
67
+ if (!(await link.count()) || !(await link.first().isVisible())) {
68
+ throw friendly({ message: `The inline "${name}" offers no "Add another" link: it has as many rows as it may (max_num), or the account may not add to it.`, hint: 'The admin hides the link when the inline is full.' });
69
+ }
70
+ await link.first().click();
71
+ await eventually(this, () => rowCount(inline), (n) => n === before + 1,
72
+ (n) => ({ message: `After "Add another" the inline "${name}" has ${n} rows (it had ${before}).`, hint: 'The admin\'s inline script adds the row.' }), 3000);
73
+ });
74
+
75
+ /**
76
+ * Remove a row of an inline, by its number from 1: a new row goes away with
77
+ * its "Remove" link; a saved row is marked for deletion with its "Delete" box
78
+ * (it is deleted when the form is saved).
79
+ *
80
+ * Example #1: When I remove row 4 of the "Choices" inline
81
+ * Example #2: When I remove row 2 of the "Choices" inline
82
+ * Example #3: And we remove row 1 of the "Questions" inline
83
+ * Example #4: When we remove row 3 of the "Choices" inline
84
+ * Example #5: And I remove row 1 of the "Choices" inline
85
+ */
86
+ When(/^(I |we )*remove row (\d+) of the "([^"]*)" inline$/, async function (pronounCase, number, name) {
87
+ const inline = await inlineGroup(this, name);
88
+ const row = await inlineRow(this, inline, parseInt(number, 10), name);
89
+ const before = await rowCount(inline);
90
+ const remove = row.locator('a.inline-deletelink');
91
+ if (await remove.count()) {
92
+ await remove.first().click();
93
+ await eventually(this, () => rowCount(inline), (n) => n === before - 1,
94
+ (n) => ({ message: `After "Remove" the inline "${name}" still has ${n} rows.`, hint: 'The admin\'s inline script takes the new row away.' }), 3000);
95
+ return;
96
+ }
97
+ const box = row.locator('input[type=checkbox][name$="-DELETE"]');
98
+ if (!(await box.count())) {
99
+ throw friendly({ message: `Row ${number} of the inline "${name}" can be neither removed nor deleted.`, hint: 'The inline does not let the account delete its rows (can_delete, or the delete permission).' });
100
+ }
101
+ await box.first().check();
102
+ });
103
+
104
+ /**
105
+ * Assert whether a saved row of an inline is marked for deletion (its "Delete"
106
+ * box ticked).
107
+ *
108
+ * Example #1: Then row 2 of the "Choices" inline should be marked for deletion
109
+ * Example #2: Then row 1 of the "Choices" inline should not be marked for deletion
110
+ * Example #3: And row 1 of the "Questions" inline should be marked for deletion
111
+ * Example #4: Then row 3 of the "Choices" inline should not be marked for deletion
112
+ * Example #5: And row 2 of the "Choices" inline should not be marked for deletion
113
+ */
114
+ Then(/^row (\d+) of the "([^"]*)" inline should( not)* be marked for deletion$/, async function (number, name, notCase) {
115
+ const inline = await inlineGroup(this, name);
116
+ const row = await inlineRow(this, inline, parseInt(number, 10), name);
117
+ const box = row.locator('input[type=checkbox][name$="-DELETE"]');
118
+ const marked = (await box.count()) ? await box.first().isChecked() : false;
119
+ if (marked === !!notCase) {
120
+ throw friendly({ message: `Row ${number} of the inline "${name}" is ${marked ? '' : 'not '}marked for deletion.`, hint: `Mark it with: When I remove row ${number} of the "${name}" inline` });
121
+ }
122
+ });
123
+
124
+ /**
125
+ * Set a field of one row of an inline: by its column in a table, by its label
126
+ * in a stacked row (see "I set "…" to "…"" for the values each kind takes).
127
+ *
128
+ * Example #1: When I set "Choice text" to "Yes" in row 1 of the "Choices" inline
129
+ * Example #2: When I set "Votes" to "5" in row 1 of the "Choices" inline
130
+ * Example #3: And we set "Choice text" to "No" in row 2 of the "Choices" inline
131
+ * Example #4: When I set "Question text" to "Inline question" in row 1 of the "Questions" inline
132
+ * Example #5: And I set "Date published" to "2026-01-15 10:30:00" in row 1 of the "Questions" inline
133
+ */
134
+ When(/^(I |we )*set "([^"]*)" to "([^"]*)" in row (\d+) of the "([^"]*)" inline$/, async function (pronounCase, label, value, number, name) {
135
+ const inline = await inlineGroup(this, name);
136
+ const row = await inlineRow(this, inline, parseInt(number, 10), name);
137
+ await setField(this, row, label, value, `Row ${number} of the inline "${name}"`);
138
+ });
139
+
140
+ /**
141
+ * Fill the rows of an inline from a table: its first row names the columns
142
+ * (the fields), each next row fills one inline row, from the first; the step
143
+ * adds rows when the inline has too few.
144
+ *
145
+ * Example #1: When I fill in the "Choices" inline:
146
+ * Example #2: And I fill in the "Choices" inline:
147
+ * Example #3: When we fill in the "Questions" inline:
148
+ * Example #4: And we fill in the "Choices" inline:
149
+ * Example #5: Given I fill in the "Choices" inline:
150
+ */
151
+ When(/^(I |we )*fill in the "([^"]*)" inline:$/, { timeout: 120000 }, async function (pronounCase, name, table) {
152
+ const [labels, ...rows] = table.raw();
153
+ const inline = await inlineGroup(this, name);
154
+ for (let i = 0; i < rows.length; i += 1) {
155
+ if ((await rowCount(inline)) < i + 1) {
156
+ await inline.group.locator('.add-row a').first().click();
157
+ await eventually(this, () => rowCount(inline), (n) => n >= i + 1,
158
+ (n) => ({ message: `The inline "${name}" could not get a row ${i + 1} (it has ${n}).`, hint: 'The inline may be full (max_num).' }), 3000);
159
+ }
160
+ const row = await inlineRow(this, inline, i + 1, name);
161
+ for (let c = 0; c < labels.length; c += 1) {
162
+ if (rows[i][c] === undefined || rows[i][c] === '') continue;
163
+ await setField(this, row, labels[c], rows[i][c], `Row ${i + 1} of the inline "${name}"`);
164
+ }
165
+ }
166
+ });
167
+
168
+ /**
169
+ * Assert what a field of one row of an inline holds (see "… should be set to
170
+ * …" for how each kind reads).
171
+ *
172
+ * Example #1: Then row 1 of the "Choices" inline should have "Yes" in "Choice text"
173
+ * Example #2: Then row 1 of the "Choices" inline should have "5" in "Votes"
174
+ * Example #3: And row 2 of the "Choices" inline should have "No" in "Choice text"
175
+ * Example #4: Then row 1 of the "Questions" inline should have "Inline question" in "Question text"
176
+ * Example #5: And row 2 of the "Choices" inline should have "0" in "Votes"
177
+ */
178
+ Then(/^row (\d+) of the "([^"]*)" inline should have "([^"]*)" in "([^"]*)"$/, async function (number, name, expected, label) {
179
+ const inline = await inlineGroup(this, name);
180
+ const row = await inlineRow(this, inline, parseInt(number, 10), name);
181
+ const value = await readField(this, row, label, `Row ${number} of the inline "${name}"`);
182
+ if (normal(value) !== normal(expected)) {
183
+ throw friendly({ message: `Row ${number} of the inline "${name}" has "${value}" in "${label}", not "${expected}".`, hint: 'A field of a table row is named by its column.' });
184
+ }
185
+ });
186
+
187
+ /**
188
+ * Assert that some row of an inline holds (or no row holds) a value, in any
189
+ * of its fields.
190
+ *
191
+ * Example #1: Then the "Choices" inline should list "Yes"
192
+ * Example #2: Then the "Choices" inline should not list "Maybe"
193
+ * Example #3: And the "Questions" inline should list "Which instrument would you learn?"
194
+ * Example #4: Then the "Choices" inline should list "No"
195
+ * Example #5: And the "Choices" inline should not list "Yes"
196
+ */
197
+ Then(/^the "([^"]*)" inline should( not)* list "([^"]*)"$/, async function (name, notCase, value) {
198
+ const inline = await inlineGroup(this, name);
199
+ const rows = inlineRows(inline);
200
+ const count = await rows.count();
201
+ const all = [];
202
+ for (let i = 0; i < count; i += 1) all.push(...(await rowValues(rows.nth(i))));
203
+ const has = all.some((v) => normal(v) === normal(value));
204
+ if (has === !!notCase) {
205
+ throw friendly({ message: notCase ? `The inline "${name}" lists "${value}".` : `The inline "${name}" does not list "${value}". Its rows hold: ${listed(all)}.`, hint: 'The step reads every field of every row.' });
206
+ }
207
+ });
208
+
209
+ module.exports = { rowCount, clean };