Skip to content

Commit

Permalink
test_UI: add UI tests for game initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendiot42 committed Jul 1, 2024
1 parent eef75d8 commit b30d906
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
3 changes: 2 additions & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module.exports = defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: "rm -r data; unzip data.zip -d .; nix run",
// command: "rm -r data; unzip data.zip -d .; nix run",
command: "nix run",
url: "http://127.0.0.1:3000",
reuseExistingServer: true,
},
Expand Down
51 changes: 48 additions & 3 deletions tests_UI/test-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ test.describe("PlantBreedGame_UI", () => {
await page.goto(page_root);
});

test("game_initialisation", async ({ page }) => {
test.setTimeout(200_000);
await page.goto(page_root);
await page.getByRole("link", { name: "gears icon Admin" }).click();
await page.getByRole("button", { name: "Initialise Game" }).click();
await expect(
page.getByRole("heading", {
name: "Apimeta simulans , a species with a bright future!",
}),
).toBeVisible({
timeout: 200_000, // game initialisation can be quite long
});
});

test("basicLogin", async ({ page }) => {
await login(page, "admin", psw);
});
Expand Down Expand Up @@ -63,6 +77,9 @@ test.describe("PlantBreedGame_UI", () => {
]);
});

// TODO add tests where several requests are made with the same file
// this is a edge case that could happend

test("evaluation", async ({ page }) => {
test.setTimeout(120_000);

Expand Down Expand Up @@ -131,10 +148,38 @@ test.describe("PlantBreedGame_UI", () => {
await runEvaluation(page, registered_inds);
});

// TODO add tests related to game initialisation
test("game re-initialisation", async ({ page }) => {
test.setTimeout(200_000);
await login(page, "admin", psw);
await page.getByRole("link", { name: "gears icon Admin" }).click();
await page.getByRole("link", { name: "Game Initialisation" }).click();
await page.getByLabel("Confirmation:").fill("plantbreedgame");
await page.getByRole("button", { name: "Initialise Game" }).click();
await expect(
page.getByRole("heading", {
name: "Apimeta simulans , a species with a bright future!",
}),
).toBeVisible({
timeout: 200_000, // game initialisation can be quite long
});

// TODO add tests where several requests are made with the same file
// this is a edge case that could happend
// simple game actions
await login(page, "admin", psw);
await addBreeder(page, "test_UI", psw, "tester");
await login(page, "test_UI", psw);

await requestPhenotyping(page, "pheno_init_2_allMethods.txt");
await requestPlantMaterial(page, "pltMat_init_set1.txt");
await requestGenotyping(page, "geno_init_3_allMethods.txt");

var registered_inds: Registerd_indsList = {
test_UI: ["Coll0101", "Coll0102", "Coll0103", "Coll0104", "Coll0105"],
};
for (let breeder in registered_inds) {
await registerIndividuals(page, registered_inds[breeder], false);
}
await runEvaluation(page, registered_inds);
});
});

async function login(page: Page, username: string, password: string) {
Expand Down

0 comments on commit b30d906

Please sign in to comment.