|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | + |
| 3 | +// Check that modifying an experiment preserves previous edits |
| 4 | +test("Edit experiment preserves previous edits", async ({ page }) => { |
| 5 | + await page.goto("/"); |
| 6 | + |
| 7 | + // Create new experiment with custom ABL height |
| 8 | + await page.getByRole("button", { name: "Add Start from scratch (" }).click(); |
| 9 | + await page.getByRole("button", { name: "Initial State Button" }).click(); |
| 10 | + await page.getByLabel("ABL height").fill("800"); |
| 11 | + await page.getByRole("button", { name: "Run" }).click(); |
| 12 | + |
| 13 | + // Edit a second field |
| 14 | + await page.getByRole("button", { name: "Edit" }).click(); |
| 15 | + await page.getByRole("button", { name: "Time control Button" }).click(); |
| 16 | + await page.getByLabel("Time step").fill("30"); |
| 17 | + await page.getByRole("button", { name: "Run" }).click(); |
| 18 | + |
| 19 | + // Open editor again and check that both values are still updated |
| 20 | + await page.getByRole("button", { name: "Edit" }).click(); |
| 21 | + await page.getByRole("button", { name: "Initial State Button" }).click(); |
| 22 | + await expect(page.getByLabel("ABL height")).toHaveValue("800"); |
| 23 | + await page.getByRole("button", { name: "Time control Button" }).click(); |
| 24 | + await expect(page.getByLabel("Time step")).toHaveValue("30"); |
| 25 | +}); |
| 26 | + |
| 27 | +test("Edit permutation preserves previous edits", async ({ page }) => { |
| 28 | + // Add experiment |
| 29 | + await page.goto("/"); |
| 30 | + await page.getByRole("button", { name: "Add Start from scratch (" }).click(); |
| 31 | + await page.getByRole("button", { name: "Run" }).click(); |
| 32 | + |
| 33 | + // Add permutation with very small initial temperature jump |
| 34 | + // Expect boundary layer to grow very quickly |
| 35 | + const experiment1 = page.getByLabel("My experiment 1", { exact: true }); |
| 36 | + await experiment1 |
| 37 | + .getByTitle( |
| 38 | + "Add a permutation to the reference configuration of this experiment", |
| 39 | + ) |
| 40 | + .click(); |
| 41 | + await page.getByRole("button", { name: "Initial State Button" }).click(); |
| 42 | + await page.getByLabel("Temperature jump at h").fill("0.1"); |
| 43 | + await page.getByRole("button", { name: "Run" }).click(); |
| 44 | + // TODO: this gives weird looking results, fix + add check; how to test?? |
| 45 | + |
| 46 | + // Modify permutation: perhaps time step is too large? |
| 47 | + await page.getByRole("button", { name: "Edit permutation" }).click(); |
| 48 | + await page.getByRole("button", { name: "Time control Button" }).click(); |
| 49 | + await page.getByLabel("Time step").fill("0.1"); |
| 50 | + await page.getByRole("button", { name: "Run" }).click(); |
| 51 | + // TODO: this gives NaN values, fix and add check |
| 52 | + |
| 53 | + // Set time step back to a more reasonable value |
| 54 | + await page.getByRole("button", { name: "Edit permutation" }).click(); |
| 55 | + await page.getByRole("button", { name: "Time control Button" }).click(); |
| 56 | + await page.getByLabel("Time step").fill("1"); |
| 57 | + await page.getByRole("button", { name: "Run" }).click(); |
| 58 | + |
| 59 | + // Verify both initial jump and time step are still modified |
| 60 | + await page |
| 61 | + .getByRole("button", { name: "View differences between this" }) |
| 62 | + .click(); |
| 63 | + await expect(page.getByTitle("PermutationConfig")).toHaveText( |
| 64 | + ` |
| 65 | + { |
| 66 | + "initialState": { |
| 67 | + "dtheta_0": 0.1 |
| 68 | + }, |
| 69 | + "timeControl": { |
| 70 | + "dt": 1 |
| 71 | + } |
| 72 | + } |
| 73 | + `, |
| 74 | + ); |
| 75 | +}); |
0 commit comments