Files
wekan/tests/playwright/specs/csv-upload.e2e.js
T
Lauri Ojansivu 60bbf69164 Jira and CSV / TSV files are uploaded too; their people and columns are read from the file on the server.
They were the last files the Import page read itself and sent whole. A
chosen Jira file is now uploaded like the other sources: the people of
its map-members step are read from it by the server (the Jira mapper is
shared, models/lib/jiraMembersMapper.js), and the estimate mapping goes
with the import call. A CSV / TSV file's header, sample rows and guessed
mapping come from the server (csvUploadPreview), its people from the
columns chosen (csvUploadPeople), and the import parses it there. Both
methods read only the sender's own upload, signed in and while import is
enabled, and leave it for the import that follows.

Thanks to xet7 !
2026-11-20 06:46:46 +02:00

35 lines
1.8 KiB
JavaScript

'use strict';
// A CSV file chosen on the Import page is uploaded to the server's disk, and
// its column mapping is offered from the server's reading of it.
const { test, expect } = require('../fixtures');
const db = require('../helpers/db');
const { navigateInApp } = require('../helpers/auth');
const { waitForImportedBoard } = require('../helpers/import');
test('a CSV file is uploaded, mapped from the server\'s preview, and imported', async ({ loggedInPage: page }) => {
let boardId;
try {
await navigateInApp(page, '/import/csv');
const csv = 'Title,List,Description\nUploaded card,To Do,From the disk\nSecond,Done,\n';
await page.locator('.js-import-file').setInputFiles({ name: 'cards.csv', mimeType: 'text/csv', buffer: Buffer.from(csv) });
await page.locator('.js-import-without-mapping').click();
// The mapping step, with the file's header read on the server.
await expect(page.locator('.js-csv-mapping-import')).toBeVisible();
await expect(page.getByText('Description', { exact: true }).first()).toBeVisible();
await page.locator('.js-csv-mapping-import').click();
await waitForImportedBoard(page);
boardId = page.url().match(/\/b\/([^/]+)/)[1];
const cards = db.find('cards', { boardId });
expect(cards.map(c => c.title).sort()).toEqual(['Second', 'Uploaded card']);
expect(cards.find(c => c.title === 'Uploaded card').description).toBe('From the disk');
} finally { if (boardId) db.cleanup({ boardIds: [boardId] }); }
});
test('negative: another user cannot read someone\'s upload', async ({ loggedInPage: page }) => {
await navigateInApp(page, '/import/csv');
const result = await page.evaluate(async () => {
try { await Meteor.callAsync('csvUploadPreview', 'a'.repeat(32)); return 'allowed'; } catch (e) { return e.error; }
});
expect(result).toBe('import-upload-not-found');
});