Skip to content

Commit 3ac54ad

Browse files
authored
E2E tests in CI (#307)
Fixes the E2E tests in CI so that they always run to completion. We were used disk mode for the session store in tests, and it appears it was interfering with some of the tests - and suggests that we may have an issue with session cleanup (particularly the in-memory caches) which we can resolve in another PR. There was a recent change to how examples are generated which broke the other test, but all should be working as expected now.
1 parent 04a9cb4 commit 3ac54ad

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

lib/importer/src/dudk/backend.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const errorTypes = require('./util/errors');
99
// An implementation of the interface described in https://struct.register-dynamics.co.uk/trac/wiki/DataImporter/API
1010

1111
let sessionStore = function () {
12-
if (process.env.NODE_ENV === undefined || process.env.NODE_ENV == "development") {
12+
if (process.env.NODE_ENV == "development") {
1313
return store.MakeSessionStore(store.SessionStoreType.DISK)
1414
}
1515

@@ -571,7 +571,7 @@ exports.SessionSuggestFields = (sid, typeGuesses, domainModelFields) => {
571571
exports.SessionGetInputValues = (sid, range, maxValues) => {
572572
assert(sessionStore.get(sid));
573573
assert(sessionStore.get(sid).wb.Sheets[range.sheet]);
574-
assert(range.end.row >= range.start.row);
574+
assert(range.end.row >= range.start.row, `End row (${range.end.row}) must be >= start row (${range.start.row}) to get input values`);
575575
assert(range.end.column >= range.start.column);
576576

577577
const sheet = sessionStore.get(sid).wb.Sheets[range.sheet];
@@ -669,7 +669,7 @@ function validateMapping(range, mapping) {
669669
exports.SessionPerformMappingJob = (sid, range, mapping, includeErrorRow = false) => {
670670
assert(sessionStore.get(sid));
671671
assert(sessionStore.get(sid).wb.Sheets[range.sheet]);
672-
assert(range.end.row >= range.start.row);
672+
assert(range.end.row >= range.start.row, `End row (${range.end.row}) must be >= start row (${range.start.row}) when performing mapping`);
673673
assert(range.end.column >= range.start.column);
674674

675675
const footerRange = this.SessionGetFooterRange(sid, range.sheet); // Ensure the footer range is loaded

lib/importer/src/dudk/sheets.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,12 @@ exports.GetColumnValues = (sid, sheet, columnIndex, cellWidth = 30, count = 10)
226226

227227
// The range passed to SessionGetInputValues is inclusive, and therefore
228228
// we end up with the first row of the selected footer. To avoid this
229-
// we will decrement the end.row to ensure we don't pull too make values.
230-
dataRange.end.row = dataRange.end.row - 1
229+
// we will decrement the end.row to ensure we don't pull too many values.
230+
// We also need to make sure in small tables thast this doesn't make end.row
231+
// less than start.row
232+
if (dataRange.end.row > dataRange.start.row) {
233+
dataRange.end.row = dataRange.end.row - 1
234+
}
231235

232236
let values = backend.SessionGetInputValues(
233237
sid,

prototypes/basic/tests/helpers/mapping_page.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export class MappingPage {
1111

1212
getColumnNames = async() => {
1313
let tbl = await this.getTable()
14-
let rowCount = await tbl.locator("tbody tr").count()
14+
15+
let rowCount = await tbl.locator("tbody tr").count();
1516
let names = new Array()
1617

1718
for (let idx = 0; idx< rowCount; idx++) {

prototypes/basic/tests/small-file.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ test('tiny files', async ({ page }) => {
8585
const examples = await mapping.getExamples()
8686
expect(examples).toStrictEqual(expectedExamples)
8787

88+
// One of these must be Salary as it is required, the other can be anything
8889
await mapping.setMapping('A', 'Title')
89-
await mapping.setMapping('B', 'Surname')
90+
await mapping.setMapping('B', 'Salary')
9091
await mapping.submit()
9192

9293
// // ---------------------------------------------------------------------------

prototypes/basic/tests/tribbles.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test('trouble with tribbles', async ({ page }) => {
8686
"1-1-24, 1-5-24, 2-3-24, 2-4-24, 3-5-24",
8787
"15:05, 1:00, 4:34, 6:01, 9:55",
8888
"4.9, 5.5, 6, 6.5, 8.4",
89-
"Beige, Black, Brown, Maroon, Pink",
89+
"Beige, Brown, Maroon, Pink", // Pink appears twice but should only be in the list once
9090
"Blob on top, N/A, Splotches, Yes,"
9191
]
9292

0 commit comments

Comments
 (0)