Skip to content

Commit

Permalink
prevent setup script to run if data folder exists
Browse files Browse the repository at this point in the history
The setup script add only add (or overwrite) new files/data to this folder.
So if it already exists the resulting data may contain the previous content of
the folder, which do not correspond to a "fresh game session".
  • Loading branch information
juliendiot42 committed Jun 3, 2024
1 parent 8aa5a53 commit 2422d72
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

data:
R -e "rmarkdown::render('plantbreedgame_setup.Rmd')"
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
initialise-data = pkgs.writeShellApplication {
name = "initialise-data";
text = ''
rm -rf data
rm data.zip || echo "no data.zip file"
make data
'';
};
Expand Down
5 changes: 3 additions & 2 deletions plantbreedgame_setup.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ Set up directories:
```{r setup_dir}
root.dir <- file.path(getwd(), "data")
root.dir <- path.expand(root.dir)
if (!dir.exists(root.dir)) {
dir.create(root.dir)
if (dir.exists(root.dir)) {
stop(paste0("`data` directory (", root.dir, ") already exists. Please remove this directory before running this script."))
}
dir.create(root.dir)
truth.dir <- file.path(root.dir, "truth")
if (!dir.exists(truth.dir)) {
dir.create(truth.dir)
Expand Down
22 changes: 22 additions & 0 deletions tests_UI/test-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ test.describe("PlantBreedGame_UI", () => {
await page.goto(page_root);
});

test("basicLogin", async ({ page }) => {
await login(page, "admin", psw);
});

test("addBreeder", async ({ page }) => {
await login(page, "admin", psw);
await addBreeder(page, "test_UI", psw, "tester");
Expand Down Expand Up @@ -136,7 +140,25 @@ async function login(page: Page, username: string, password: string) {
await page.getByLabel("Password").click();
await page.getByLabel("Password").fill(password);
await page.getByRole("button", { name: "Log in" }).click();

// top bar visible ?
await expect(page.locator("#breederBoxID")).toBeVisible();
await expect(page.getByRole("heading", { name: username })).toBeVisible();
await expect(page.locator("#dateBoxID")).toBeVisible();
await expect(page.locator("#budgetBoxID")).toBeVisible();
await expect(page.locator("#serverIndicID")).toBeVisible();

// content
await expect(
page.getByRole("heading", { name: "Phenotyping data:" }),
).toBeVisible();
await expect(
page.getByRole("heading", { name: "Genotyping data:" }),
).toBeVisible();
await expect(
page.getByRole("heading", { name: "Plant material data:" }),
).toBeVisible();
await expect(page.getByRole("heading", { name: "Other:" })).toBeVisible();
}

async function addBreeder(
Expand Down

0 comments on commit 2422d72

Please sign in to comment.