Skip to content

Commit f2edd6b

Browse files
authored
Partial bugfix 86 - modify experiment preserves previous edits (#88)
* Return full state from form submit * Return full state from permutation form submit as well * Write test cases to trigger bug/check fix
1 parent 8382629 commit f2edd6b

File tree

3 files changed

+78
-3
lines changed

3 files changed

+78
-3
lines changed

apps/class-solid/src/components/ExperimentConfigForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function ExperimentConfigForm({
4242
id={id}
4343
onSubmit={handleSubmit}
4444
shouldActive={false} // Also return from collapsed fields
45-
shouldDirty={true} // Don't return empty strings for unset fields
45+
shouldDirty={false} // ~Don't return empty strings for unset fields~
4646
>
4747
<div>
4848
<ObjectField

apps/class-solid/src/components/PermutationsList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function PermutationConfigForm(props: {
7979
id={props.id}
8080
onSubmit={handleSubmit}
8181
shouldActive={false} // Also return from collapsed fields
82-
shouldDirty={true} // Don't return empty strings for unset fields
82+
shouldDirty={false} // ~Don't return empty strings for unset fields~
8383
>
8484
<div>
8585
<ObjectField
@@ -222,7 +222,7 @@ function PermutationDifferenceButton(props: {
222222
</fieldset>
223223
<fieldset class="border">
224224
<legend>Permutation configuration</legend>
225-
<pre>{prunedPermutation()}</pre>
225+
<pre title="PermutationConfig">{prunedPermutation()}</pre>
226226
</fieldset>
227227
</div>
228228
</DialogContent>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)