File size: 1,389 Bytes
1cbdba3
 
58bf1b1
1cbdba3
 
 
 
 
 
 
 
58bf1b1
 
 
 
 
 
 
 
1cbdba3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Test uploading a file in an import box.
import { test, expect } from '@playwright/test';
import { Splash, Workspace } from './lynxkite';
import { join, dirname  } from 'path';
import { fileURLToPath } from 'url';


let workspace: Workspace;


test.beforeEach(async ({ browser }) => {
  workspace = await Workspace.empty(await browser.newPage(), 'upload_spec_test');
});

test.afterEach(async ({ }) => {
  await workspace.close();
  const splash = await new Splash(workspace.page);
  splash.page.on('dialog', async dialog => { await dialog.accept(); });
  await splash.deleteEntry('upload_spec_test');
});


test('can upload and import a simple CSV', async () => {
    const __filename = fileURLToPath(import.meta.url);
    const __dirname = dirname(__filename);
    const csvPath = join(__dirname, 'data', 'upload_test.csv');

    await workspace.addBox('Import CSV');
    const csvBox =  workspace.getBox('Import CSV 1');
    const filenameInput = csvBox.locator('input.input-bordered').nth(0);
    await filenameInput.click();
    await filenameInput.fill(csvPath);
    await filenameInput.press('Enter');
    
    await workspace.addBox('View tables');
    const tableBox = workspace.getBox('View tables 1');
    await workspace.connectBoxes('Import CSV 1', 'View tables 1');

    const tableRows = tableBox.locator('table tbody tr');
    await expect(tableRows).toHaveCount(4);
});