fix download (#1434)

* fix download

* update test db

* create download test
This commit is contained in:
Alex Christoffer Rasmussen
2025-01-06 20:26:06 +01:00
committed by GitHub
parent 9cfed5a150
commit 13eadeb0af
4 changed files with 425 additions and 296 deletions
+1
View File
@@ -28,6 +28,7 @@ test-results
playwright-report playwright-report
/playwright/.cache/ /playwright/.cache/
automated-screenshots automated-screenshots
e2e/tests/fixtures/tmp/*
# production # production
build/ build/
+1 -1
View File
@@ -12,7 +12,7 @@ const dbPath = `${apiEntryUrl}/db`;
* HTTP request to the current DB * HTTP request to the current DB
*/ */
export function getDb(filename: string): Promise<AxiosResponse<DatabaseModel>> { export function getDb(filename: string): Promise<AxiosResponse<DatabaseModel>> {
return axios.post(`${dbPath}/download/`, { filename }); return axios.post(`${dbPath}/download`, { filename });
} }
/** /**
+32
View File
@@ -1,6 +1,9 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { readFile } from 'fs/promises';
const fileToUpload = 'e2e/tests/fixtures/test-db.json'; const fileToUpload = 'e2e/tests/fixtures/test-db.json';
const fileToDownload = 'e2e/tests/fixtures/tmp/test-db.json';
test('project file upload', async ({ page }) => { test('project file upload', async ({ page }) => {
await page.goto('http://localhost:4001/editor'); await page.goto('http://localhost:4001/editor');
@@ -34,3 +37,32 @@ test('project file upload', async ({ page }) => {
const thirdTitle = page.getByTestId('entry-3').getByTestId('block__title'); const thirdTitle = page.getByTestId('entry-3').getByTestId('block__title');
await expect(thirdTitle).toHaveValue('Lithuania'); await expect(thirdTitle).toHaveValue('Lithuania');
}); });
test('project file download', async ({ page }) => {
await page.goto('http://localhost:4001/editor');
// close the welcome modal if it is open
await page.keyboard.down('Escape');
await page.getByRole('button', { name: 'toggle settings' }).click();
await page.getByRole('button', { name: 'Project', exact: true }).click();
// workaround to download
// https://playwright.dev/docs/api/class-download
const downloadPromise = page.waitForEvent('download');
await page
.getByRole('row', { name: RegExp('^test-db') })
.getByLabel('Options')
.click();
await page.getByRole('menuitem', { name: 'Download' }).click();
const download = await downloadPromise;
// Wait for the download process to complete and save the downloaded file somewhere.
await download.saveAs(fileToDownload);
await expect(download.failure()).toMatchObject({});
const original = JSON.parse(await readFile(fileToUpload, { encoding: 'utf-8' }));
const fromServer = JSON.parse(await readFile(fileToDownload, { encoding: 'utf-8' }));
await expect(original).toEqual(fromServer);
});
+186 -90
View File
@@ -1,100 +1,130 @@
{ {
"rundown": [ "rundown": [
{ {
"id": "32d31",
"type": "event",
"title": "Albania", "title": "Albania",
"note": "SF1.01",
"endAction": "none",
"timerType": "count-down",
"timeStart": 36000000, "timeStart": 36000000,
"timeEnd": 37200000, "timeEnd": 37200000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.01",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "32d31",
"cue": "SF1.01", "cue": "SF1.01",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Sekret", "song": "Sekret",
"artist": "Ronela Hajati" "artist": "Ronela Hajati"
} }
}, },
{ {
"id": "21cd2",
"type": "event",
"title": "Latvia", "title": "Latvia",
"note": "SF1.02",
"endAction": "none",
"timerType": "count-down",
"timeStart": 37500000, "timeStart": 37500000,
"timeEnd": 38700000, "timeEnd": 38700000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.02",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "21cd2",
"cue": "SF1.02", "cue": "SF1.02",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Eat Your Salad", "song": "Eat Your Salad",
"artist": "Citi Zeni" "artist": "Citi Zeni"
} }
}, },
{ {
"id": "0b371",
"type": "event",
"title": "Lithuania", "title": "Lithuania",
"note": "SF1.03",
"endAction": "none",
"timerType": "count-down",
"timeStart": 39000000, "timeStart": 39000000,
"timeEnd": 40200000, "timeEnd": 40200000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.03",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "0b371",
"cue": "SF1.03", "cue": "SF1.03",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Sentimentai", "song": "Sentimentai",
"artist": "Monika Liu" "artist": "Monika Liu"
} }
}, },
{ {
"id": "3cd28",
"type": "event",
"title": "Switzerland", "title": "Switzerland",
"note": "SF1.04",
"endAction": "none",
"timerType": "count-down",
"timeStart": 40500000, "timeStart": 40500000,
"timeEnd": 41700000, "timeEnd": 41700000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.04",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "3cd28",
"cue": "SF1.04", "cue": "SF1.04",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Boys Do Cry", "song": "Boys Do Cry",
"artist": "Marius Bear" "artist": "Marius Bear"
} }
}, },
{ {
"id": "e457f",
"type": "event",
"title": "Slovenia", "title": "Slovenia",
"note": "SF1.05",
"endAction": "none",
"timerType": "count-down",
"timeStart": 42000000, "timeStart": 42000000,
"timeEnd": 43200000, "timeEnd": 43200000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.05",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "e457f",
"cue": "SF1.05", "cue": "SF1.05",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Disko", "song": "Disko",
"artist": "LPS" "artist": "LPS"
@@ -106,100 +136,130 @@
"id": "01e85" "id": "01e85"
}, },
{ {
"id": "1c420",
"type": "event",
"title": "Ukraine", "title": "Ukraine",
"note": "SF1.06",
"endAction": "none",
"timerType": "count-down",
"timeStart": 47100000, "timeStart": 47100000,
"timeEnd": 48300000, "timeEnd": 48300000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.06",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "1c420",
"cue": "SF1.06", "cue": "SF1.06",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Stefania", "song": "Stefania",
"artist": "Kalush Orchestra" "artist": "Kalush Orchestra"
} }
}, },
{ {
"id": "b7737",
"type": "event",
"title": "Bulgaria", "title": "Bulgaria",
"note": "SF1.07",
"endAction": "none",
"timerType": "count-down",
"timeStart": 48600000, "timeStart": 48600000,
"timeEnd": 49800000, "timeEnd": 49800000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.07",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "b7737",
"cue": "SF1.07", "cue": "SF1.07",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Intention", "song": "Intention",
"artist": "Intelligent Music Project" "artist": "Intelligent Music Project"
} }
}, },
{ {
"id": "d3a80",
"type": "event",
"title": "Netherlands", "title": "Netherlands",
"note": "SF1.08",
"endAction": "none",
"timerType": "count-down",
"timeStart": 50100000, "timeStart": 50100000,
"timeEnd": 51300000, "timeEnd": 51300000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.08",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "d3a80",
"cue": "SF1.08", "cue": "SF1.08",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "De Diepte", "song": "De Diepte",
"artist": "S10" "artist": "S10"
} }
}, },
{ {
"id": "8276c",
"type": "event",
"title": "Moldova", "title": "Moldova",
"note": "SF1.09",
"endAction": "none",
"timerType": "count-down",
"timeStart": 51600000, "timeStart": 51600000,
"timeEnd": 52800000, "timeEnd": 52800000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.09",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "8276c",
"cue": "SF1.09", "cue": "SF1.09",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Trenuletul", "song": "Trenuletul",
"artist": "Zdob si Zdub" "artist": "Zdob si Zdub"
} }
}, },
{ {
"id": "2340b",
"type": "event",
"title": "Portugal", "title": "Portugal",
"note": "SF1.10",
"endAction": "none",
"timerType": "count-down",
"timeStart": 53100000, "timeStart": 53100000,
"timeEnd": 54300000, "timeEnd": 54300000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.10",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "2340b",
"cue": "SF1.10", "cue": "SF1.10",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Saudade Saudade", "song": "Saudade Saudade",
"artist": "Maro" "artist": "Maro"
@@ -211,97 +271,122 @@
"id": "cb90b" "id": "cb90b"
}, },
{ {
"id": "503c4",
"type": "event",
"title": "Croatia", "title": "Croatia",
"note": "SF1.11",
"endAction": "none",
"timerType": "count-down",
"timeStart": 56100000, "timeStart": 56100000,
"timeEnd": 57300000, "timeEnd": 57300000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.11",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "503c4",
"cue": "SF1.11", "cue": "SF1.11",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Guilty Pleasure", "song": "Guilty Pleasure",
"artist": "Mia Dimsic" "artist": "Mia Dimsic"
} }
}, },
{ {
"id": "5e965",
"type": "event",
"title": "Denmark", "title": "Denmark",
"note": "SF1.12",
"endAction": "none",
"timerType": "count-down",
"timeStart": 57600000, "timeStart": 57600000,
"timeEnd": 58800000, "timeEnd": 58800000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.12",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "5e965",
"cue": "SF1.12", "cue": "SF1.12",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "The Show", "song": "The Show",
"artist": "Reddi" "artist": "Reddi"
} }
}, },
{ {
"id": "bab4a",
"type": "event",
"title": "Austria", "title": "Austria",
"note": "SF1.13",
"endAction": "none",
"timerType": "count-down",
"timeStart": 59100000, "timeStart": 59100000,
"timeEnd": 60300000, "timeEnd": 60300000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.13",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "bab4a",
"cue": "SF1.13", "cue": "SF1.13",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Halo", "song": "Halo",
"artist": "LUM!X & Pia Maria" "artist": "LUM!X & Pia Maria"
} }
}, },
{ {
"id": "d3eb1",
"type": "event",
"title": "Greece", "title": "Greece",
"note": "SF1.14",
"endAction": "none",
"timerType": "count-down",
"timeStart": 60600000, "timeStart": 60600000,
"timeEnd": 61800000, "timeEnd": 61800000,
"duration": 1200000, "duration": 1200000,
"timeStrategy": "lock-duration",
"linkStart": null,
"endAction": "none",
"timerType": "count-down",
"countToEnd": false,
"isPublic": true, "isPublic": true,
"skip": false, "skip": false,
"note": "SF1.14",
"colour": "", "colour": "",
"type": "event", "delay": 0,
"revision": 0,
"id": "d3eb1",
"cue": "SF1.14", "cue": "SF1.14",
"revision": 0,
"timeWarning": 120000,
"timeDanger": 60000,
"custom": { "custom": {
"song": "Die Together", "song": "Die Together",
"artist": "Amanda Tenfjord" "artist": "Amanda Tenfjord"
} }
} }
], ],
"project": { "project": {
"title": "Eurovision Song Contest", "title": "Eurovision Song Contest",
"description": "Turin 2022", "description": "Turin 2022",
"publicUrl": "www.getontime.no", "publicUrl": "www.getontime.no",
"publicInfo": "Rehearsal Schedule - Turin 2022", "publicInfo": "Rehearsal Schedule - Turin 2022",
"backstageUrl": "www.github.com/cpvalente/ontime", "backstageUrl": "www.github.com/cpvalente/ontime",
"backstageInfo": "Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal" "backstageInfo": "Rehearsal Schedule - Turin 2022\nAll performers to wear full costumes for 1st rehearsal",
"projectLogo": null
}, },
"settings": { "settings": {
"app": "ontime", "app": "ontime",
"version": "2.0.0", "version": "3.10.2",
"serverPort": 4001, "serverPort": 4001,
"editorKey": null, "editorKey": null,
"operatorKey": null, "operatorKey": null,
@@ -312,10 +397,9 @@
"overrideStyles": false, "overrideStyles": false,
"normalColor": "#ffffffcc", "normalColor": "#ffffffcc",
"warningColor": "#FFAB33", "warningColor": "#FFAB33",
"warningThreshold": 120000,
"dangerColor": "#ED3333", "dangerColor": "#ED3333",
"dangerThreshold": 60000, "endMessage": "",
"endMessage": "" "freezeEnd": false
}, },
"urlPresets": [ "urlPresets": [
{ {
@@ -335,5 +419,17 @@
"http": { "http": {
"enabledOut": true, "enabledOut": true,
"subscriptions": [] "subscriptions": []
},
"customFields": {
"song": {
"type": "string",
"colour": "",
"label": "song"
},
"artist": {
"type": "string",
"colour": "",
"label": "artist"
}
} }
} }