-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests related to saving/loading (#52)
* test: added 4 tests for saving/loading: backpack, blockly/C++ workspace and starting a new project
- Loading branch information
Showing
1 changed file
with
94 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,94 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { goToHomePage, openExample as loadExample } from "./utils"; | ||
|
||
test.beforeEach(goToHomePage); | ||
|
||
test("Saving - Backpack", async ({ page }) => { | ||
await page.getByText("Leaphy Original").click(); | ||
await page.getByText("Original Uno").click(); | ||
|
||
await loadExample(page, "blink"); | ||
|
||
// Put something in the backpack | ||
await page | ||
.getByText("repeat forever") | ||
.dragTo(page.locator(".blocklyBackpack")); | ||
|
||
// Check that its in the backpack | ||
await expect(page.getByText("repeat forever")).toBeHidden(); | ||
await page.locator(".blocklyBackpack").click(); | ||
await expect(page.getByText("repeat forever")).toBeVisible(); | ||
|
||
// Start a new project, why not? | ||
await page.getByRole("button", { name: "My projects" }).click(); | ||
await page.getByRole("cell", { name: "New" }).click(); | ||
|
||
await page.reload(); | ||
|
||
// Load a different robot type than before, cause why not | ||
await page.getByRole("button", { name: "Leaphy Click Leaphy Click" }).click(); | ||
|
||
await expect(page.getByText("repeat forever")).toBeHidden(); | ||
await page.locator(".blocklyBackpack").click(); | ||
await expect(page.getByText("repeat forever")).toBeVisible(); | ||
|
||
await page.getByText("repeat forever").dragTo(page.getByText("Leaphy"), { | ||
force: true, | ||
targetPosition: { | ||
x: 30, | ||
y: 30, | ||
}, | ||
}); | ||
|
||
// Check that the blocks have been loaded properly | ||
await page.locator(".side").first().click(); // Open code | ||
await expect(page.locator(".view-lines")).toContainText("delay(1000)"); | ||
}); | ||
|
||
test("Saving - Blockly", async ({ page }) => { | ||
await page.getByText("Leaphy Original").click(); | ||
await page.getByText("Original Uno").click(); | ||
|
||
await loadExample(page, "blink"); | ||
|
||
await page.reload(); | ||
|
||
await page.getByText("Leaphy Original").click(); | ||
await page.getByText("Original Uno").click(); | ||
|
||
await expect(page.getByText("repeat forever")).toBeVisible(); | ||
}); | ||
|
||
test("Saving - C++", async ({ page }) => { | ||
await page.getByRole("button", { name: "Leaphy C++ Leaphy C++" }).click(); | ||
await page.getByText("setup").click(); | ||
await page.getByLabel("Editor content;Press Alt+F1").fill("testing"); | ||
|
||
await expect(page.getByText("setup")).toBeHidden(); | ||
await expect(page.getByText("testing")).toBeVisible(); | ||
|
||
await page.reload(); | ||
|
||
await page.getByRole("button", { name: "Leaphy C++ Leaphy C++" }).click(); | ||
|
||
await expect(page.getByText("setup")).toBeHidden(); | ||
await expect(page.getByText("testing")).toBeVisible(); | ||
}); | ||
|
||
test("Saving - New project", async ({ page }) => { | ||
await page.getByText("Leaphy Original").click(); | ||
await page.getByText("Original Uno").click(); | ||
|
||
await loadExample(page, "blink"); | ||
|
||
// Start a new project, should reset to the default | ||
await page.getByRole("button", { name: "My projects" }).click(); | ||
await page.getByRole("cell", { name: "New" }).click(); | ||
|
||
// Open the same editor | ||
await page.getByText("Leaphy Original").click(); | ||
await page.getByText("Original Uno").click(); | ||
|
||
// Its a new project, it should not be here! | ||
await expect(page.getByText("repeat forever")).toBeHidden(); | ||
}); |