refactor: normalise data (#756)

* chore: remove legal from bundle

* refactor: create normalised dataset

* refactor: cuesheet uses flat rundown

* refactor: multi-selection

* refactor: prevent stale data on server restart

* refactor: increase ID size

* chore: instrument operation

* chore: update csv tests

* fix: resolve directory to test-db (#758)
This commit is contained in:
Carlos Valente
2024-02-03 21:43:17 +01:00
committed by GitHub
parent 47a519bac1
commit 1890fc49d7
62 changed files with 1838 additions and 3341 deletions
+13 -22
View File
@@ -2,31 +2,21 @@ import { expect, test } from '@playwright/test';
import fs from 'fs';
test('cuesheet displays events and exports csv', async ({ page }) => {
// ensure elements exist in editor
await page.goto('http://localhost:4001/editor');
await page.getByText('First test event').click();
await page.getByText('Second test event').click();
await page.getByText('Third test event').click();
await page.getByText('Add timeSubtract timeApplyCancel').click();
await page.getByText('Lunch').click();
// same elements in cuesheet
await page.goto('http://localhost:4001/cuesheet');
await page.getByText('All about Carlos demo event').click();
await page.getByRole('cell', { name: 'First test event' }).click();
await page.getByRole('cell', { name: 'Second test event' }).click();
await page.getByRole('cell', { name: 'Third test event' }).click();
await page.getByRole('cell', { name: '+10 min' }).click();
await page.getByRole('cell', { name: 'Lunch' }).click();
const downloadPromise = page.waitForEvent('download');
await page.getByTestId('cuesheet').getByText('Export').click();
await page.getByText('CSV').click();
await page.getByText('Eurovision Song Contest').click();
await page.getByRole('cell', { name: 'Lunch break' }).click();
await page.getByRole('cell', { name: 'Albania' }).click();
await page.getByRole('cell', { name: 'Latvia' }).click();
await page.getByRole('cell', { name: 'Lithuania' }).click();
// From here we test the CSV download feature
const downloadPromise = page.waitForEvent('download');
await page.getByTestId('cuesheet').getByText('Export CSV').click();
function validateCSV(contents) {
function validateCSV(contents: string) {
// We should try to keep this in sync with the implementation over at cuesheetUtils.ts
const expectedHeader = ['All about Carlos demo event', 'www.getontime.no'];
const expectedHeader = ['Project title: Eurovision Song Contest', 'Project description: Turin 2022'];
const expectedColumns = [
'Time Start',
'Time End',
@@ -50,14 +40,15 @@ test('cuesheet displays events and exports csv', async ({ page }) => {
'user8',
'user9',
];
const expectedValues = ['First test event', 'Second test event', 'Third test event', 'Lunch'];
const expectedValues = ['Albania', 'Latvia', 'Lithuania', 'Lunch break'];
const allExpected = [...expectedHeader, ...expectedColumns, ...expectedValues];
return allExpected.every((value) => contents.includes(value));
return allExpected.every((value) => {
return contents.toLowerCase().includes(value.toLowerCase());
});
}
const download = await downloadPromise;
const contents = await fs.promises.readFile(await download.path(), 'utf-8');
expect(contents).toContain('All about Carlos demo event');
expect(validateCSV(contents)).toBe(true);
});