Skip to content

Commit

Permalink
test(data-viz): add basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendiot42 committed Oct 6, 2024
1 parent a290c79 commit b23a5cd
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/fun/func_data-viz.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ data_viz_ui <- function(id) {
),
hr(),
div(style = "margin-top: 30px;",
id = ns("data-table"),
withSpinner(dataTableOutput(ns("dataTable")))
)
)
Expand Down
67 changes: 67 additions & 0 deletions tests_UI/test-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b23a5cd

Please sign in to comment.