From b23a5cd644b5c1f1acaeb6014f1d1144f95c3702 Mon Sep 17 00:00:00 2001 From: Julien DIOT Date: Mon, 30 Sep 2024 14:41:41 +0900 Subject: [PATCH] test(data-viz): add basic tests --- src/fun/func_data-viz.R | 1 + tests_UI/test-1.spec.ts | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/src/fun/func_data-viz.R b/src/fun/func_data-viz.R index 1fc36dd..19dddfc 100644 --- a/src/fun/func_data-viz.R +++ b/src/fun/func_data-viz.R @@ -31,6 +31,7 @@ data_viz_ui <- function(id) { ), hr(), div(style = "margin-top: 30px;", + id = ns("data-table"), withSpinner(dataTableOutput(ns("dataTable"))) ) ) diff --git a/tests_UI/test-1.spec.ts b/tests_UI/test-1.spec.ts index aba2603..68b8b33 100644 --- a/tests_UI/test-1.spec.ts +++ b/tests_UI/test-1.spec.ts @@ -107,6 +107,73 @@ test.describe("PlantBreedGame_UI", () => { await deleteBreeder(page, "test_UI"); }); + test("data-viz", async ({ page }) => { + await login(page, "admin", psw); + + // download initial phenotype file: + await expect(page.locator("#phenoFile-selectized")).toBeVisible({ + timeout: 100, + }); + await page.locator("#phenoFile-selectized").locator("..").click(); + + await page + .getByRole("option") + .getByText("Result_phenos_initialColl.txt.gz") + .first() + .click(); + + const downloadPromise = page.waitForEvent("download"); + await page.locator("#dwnlPheno").click(); + const download = await downloadPromise; + + const tempDirPath = tmpdir() + "/"; + const data_file = tempDirPath + download.suggestedFilename(); + await download.saveAs(data_file); + + // Data-viz + await page.getByRole("link", { name: "chart-line icon Data" }).click(); + + await page.getByLabel("Browse...").setInputFiles(data_file); + + const variables = [ + "-- None --", + "ind", + "year", + "plot", + "pathogen", + "trait1", + "trait2", + "trait3", + ]; + + // check data table + for (let variable of variables.slice(1)) { + await expect( + page + .locator("#data-viz_file-dataTable") + .locator("th") + .filter({ hasText: variable }), + ).toBeVisible(); + } + + // check all variables can be selected for X/Y/Col + const variable_selection_ids = [ + "#data-viz_file-x_var-selectized", + "#data-viz_file-y_var-selectized", + "#data-viz_file-col_var-selectized", + ]; + for (let select_id of variable_selection_ids) { + await expect(page.locator(select_id)).toBeVisible(); + await page.locator(select_id).click(); + for (let variable of variables) { + await expect( + page.getByRole("option", { name: variable }), + ).toBeVisible(); + } + await page.getByRole("option", { name: variables[0] }).click(); + } + }); + test("Large_requests/full campaing", async ({ page }) => { test.setTimeout(180_000); await login(page, "admin", psw);