-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcsvImport.spec.ts
More file actions
70 lines (59 loc) · 2.6 KB
/
Copy pathcsvImport.spec.ts
File metadata and controls
70 lines (59 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {test, expect} from '@playwright/test';
import {openApp} from '../../tests/shared/utils';
import {tpGetData} from '../../tests/shared/utilsTestPanel';
import {
expandImportOptions,
openCsvImportDialog,
setColumnPath,
setCsvTablePath,
submitCsvImport,
uploadCsvFile,
uploadCsvFileAndCheckProgress,
} from '../../tests/shared/utilsCsvImport';
import {SessionMode} from '../src/store/sessionMode';
test('Import CSV as standalone table with default paths', async ({page}) => {
await openApp(page, 'settings_testpanel.json');
await openCsvImportDialog(page);
await uploadCsvFile(page, 'data_people.csv');
// submit without changing any options — default table path comes from the filename
await submitCsvImport(page);
// filename "data_people.csv" → stringToIdentifier strips underscores → key is "datapeople"
const data = await tpGetData(page, SessionMode.DataEditor);
expect(data).toHaveProperty('datapeople');
expect(data.datapeople).toHaveLength(2);
expect(data.datapeople[0]).toMatchObject({name: 'Alice', city: 'Berlin', role: 'Engineer'});
expect(data.datapeople[1]).toMatchObject({name: 'Bob', city: 'Munich', role: 'Designer'});
});
test('Import CSV with custom table path and renamed column', async ({page}) => {
await openApp(page, 'settings_testpanel.json');
await openCsvImportDialog(page);
await uploadCsvFile(page, 'data_people.csv');
await expandImportOptions(page);
await setCsvTablePath(page, 'people');
await setColumnPath(page, 'city', 'location');
await submitCsvImport(page);
const data = await tpGetData(page, SessionMode.DataEditor);
expect(data).toEqual({
people: [
{name: 'Alice', location: 'Berlin', role: 'Engineer'},
{name: 'Bob', location: 'Munich', role: 'Designer'},
],
});
});
test('CSV file upload progresses reliably for 15 consecutive attempts in the same session without reload', async ({page}) => {
test.setTimeout(60000);
await openApp(page, 'settings_testpanel.json');
for (let attempt = 1; attempt <= 15; attempt++) {
await test.step(`csv upload attempt ${attempt}`, async () => {
await openCsvImportDialog(page);
try {
await uploadCsvFileAndCheckProgress(page, 'data_people.csv', 4000);
} catch (error) {
throw new Error(`CSV upload attempt ${attempt} got stuck before parsing completed`, {
cause: error instanceof Error ? error : undefined,
});
}
await submitCsvImport(page);
});
}
});