From 931e77fbe3c69c54ec85f9df2eca2104eb2864ba Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Sat, 31 May 2025 17:38:44 +0200 Subject: [PATCH] Sessions: add year csv export (#21555) --- assets/js/views/Sessions.vue | 84 +++++++++++++++++------------------- i18n/bg.json | 3 +- i18n/ca.json | 1 - i18n/cs.json | 3 +- i18n/da.json | 3 +- i18n/de.json | 3 +- i18n/el.json | 3 +- i18n/en.json | 3 +- i18n/es.json | 3 +- i18n/fi.json | 3 +- i18n/fr.json | 3 +- i18n/hr.json | 3 +- i18n/hu.json | 3 +- i18n/it.json | 3 +- i18n/lb.json | 3 +- i18n/lt.json | 3 +- i18n/nl.json | 3 +- i18n/no.json | 3 +- i18n/pl.json | 3 +- i18n/pt.json | 3 +- i18n/ro.json | 3 +- i18n/ru.json | 1 - i18n/sl.json | 3 +- i18n/sv.json | 3 +- i18n/ta.json | 3 +- i18n/tr.json | 3 +- i18n/uk.json | 3 +- i18n/zh-Hans.json | 3 +- tests/sessions.spec.js | 38 +++++++++++----- 29 files changed, 92 insertions(+), 107 deletions(-) diff --git a/assets/js/views/Sessions.vue b/assets/js/views/Sessions.vue index ea6ecd528..96c7b2890 100644 --- a/assets/js/views/Sessions.vue +++ b/assets/js/views/Sessions.vue @@ -144,40 +144,26 @@ -
- - + +
+ + {{ csvLinkLabel }} + +
- { }); }); +const date = new Date(); +const YEAR = date.getFullYear(); +const MONTH = date.getMonth() + 1; +const MONTH_YEAR = new Intl.DateTimeFormat("en", { month: "long", year: "numeric" }).format(date); + test.describe("csv export", async () => { test("total export", async ({ page }) => { - await page.goto("/#/sessions?year=2023&month=5"); - await expect(page.getByRole("link", { name: "Download total CSV" })).toHaveAttribute( - "href", - "./api/sessions?format=csv&lang=en" - ); - - await page.goto("/#/sessions?year=2023&month=6"); + await page.goto("/#/sessions?period=total"); await expect(page.getByRole("link", { name: "Download total CSV" })).toHaveAttribute( "href", "./api/sessions?format=csv&lang=en" ); }); + test("year export", async ({ page }) => { + // fixed year + await page.goto("/#/sessions?period=year&year=2023"); + await expect(page.getByRole("link", { name: "Download 2023 CSV" })).toHaveAttribute( + "href", + "./api/sessions?format=csv&lang=en&year=2023" + ); + + // current year + await page.goto(`/#/sessions?period=year`); + await expect(page.getByRole("link", { name: `Download ${YEAR} CSV` })).toHaveAttribute( + "href", + `./api/sessions?format=csv&lang=en&year=${YEAR}` + ); + }); test("monthly export", async ({ page }) => { - await page.goto("/#/sessions?year=2023&month=5"); + await page.goto("/#/sessions?&year=2023&month=5"); await expect(page.getByRole("link", { name: "Download May 2023 CSV" })).toHaveAttribute( "href", "./api/sessions?format=csv&lang=en&year=2023&month=5" ); - await page.goto("/#/sessions?year=2023&month=6"); - await expect(page.getByRole("link", { name: "Download June 2023 CSV" })).toHaveCount(0); + // current month + await page.goto(`/#/sessions`); + await expect(page.getByRole("link", { name: `Download ${MONTH_YEAR} CSV` })).toHaveAttribute( + "href", + `./api/sessions?format=csv&lang=en&year=${YEAR}&month=${MONTH}` + ); }); });