-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ffa0ed
commit 94e2b99
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { randomUUID } from "crypto"; | ||
import { test, expect } from "../fixtures"; | ||
import { getTotalDuration } from "$lib/util/MesocycleTemplate"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:4173/mesocycles"); | ||
}); | ||
|
||
const mesocycleTemplate: MesocycleTemplate = { | ||
name: randomUUID(), | ||
caloricBalance: 0, | ||
startRIR: 3, | ||
RIRProgression: [ | ||
{ specificRIR: 3, cycles: 4 }, | ||
{ specificRIR: 2, cycles: 3 }, | ||
{ specificRIR: 1, cycles: 2 }, | ||
{ specificRIR: 0, cycles: 1 } | ||
], | ||
exerciseSplit: [ | ||
{ | ||
name: "Upper", | ||
exercises: [ | ||
{ | ||
name: "Upper exercise 1", | ||
sets: 3, | ||
targetMuscleGroup: "Chest", | ||
repRangeStart: 10, | ||
repRangeEnd: 20, | ||
weightType: "Weighted" | ||
} | ||
] | ||
}, | ||
null | ||
] | ||
}; | ||
|
||
test("create a sample mesocycle using API", async ({ page }) => { | ||
const createTemplateResponse = await page.request.post("/api/mesocycles/createTemplate", { | ||
data: { mesocycleTemplate }, | ||
headers: { "content-type": "application/json" } | ||
}); | ||
expect(createTemplateResponse.ok()).toBe(true); | ||
}); | ||
|
||
test("edit the sample mesocycle", async ({ page }) => { | ||
await page.goto("/mesocycles"); | ||
await expect(page.getByRole("main")).toContainText(mesocycleTemplate.name); | ||
await page.getByRole("link", { name: mesocycleTemplate.name }).click(); | ||
|
||
await page.getByRole("link", { name: "Edit" }).click(); | ||
await expect(page.locator("input[id='mesocycle-name']")).toHaveValue(mesocycleTemplate.name); | ||
await expect(page.locator("input[id='mesocycle-duration']")).toHaveValue( | ||
getTotalDuration(mesocycleTemplate.RIRProgression).toString() | ||
); | ||
|
||
const newMesocycleName = randomUUID(); | ||
await page.locator("input[id='mesocycle-name']").fill(newMesocycleName); | ||
await page.getByRole("button", { name: "Next" }).click(); | ||
await page.getByRole("button", { name: "Next" }).click(); | ||
await page.getByRole("button", { name: "Next" }).click(); | ||
await page.getByRole("button", { name: "Update mesocycle" }).click(); | ||
await page.locator("#Success").getByTestId("close-modal-button").click(); | ||
|
||
await expect(page.getByRole("main")).not.toContainText(mesocycleTemplate.name); | ||
await expect(page.getByRole("main")).toContainText(newMesocycleName); | ||
}); |