-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* initial * wip * wip * can save a mod * update via workshop * cleanup mod * adds additional assertions * separate out editWorkshopModPage * cleanup modName, modComponentName, modUuid * separate adding and configuring starterbrick concerns * more cleanup * fixed typo in method name * update snapshots
- Loading branch information
1 parent
3d3c1cb
commit 63db07b
Showing
15 changed files
with
337 additions
and
15 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
end-to-end-tests/pageObjects/extensionConsole/editWorkshopModPage.ts
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,50 @@ | ||
/* | ||
* Copyright (C) 2024 PixieBrix, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { type Page } from "@playwright/test"; | ||
|
||
export class EditWorkshopModPage { | ||
constructor(private readonly page: Page) {} | ||
|
||
async findText(text: string) { | ||
await this.page | ||
.getByLabel("Editor") | ||
.locator("div") | ||
.filter({ hasText: text }) | ||
.nth(2) | ||
.click(); | ||
|
||
await this.page.getByRole("textbox").nth(0).press("ControlOrMeta+f"); | ||
await this.page.getByPlaceholder("Search for").fill(text); | ||
} | ||
|
||
async findAndReplaceText(findText: string, replaceText: string) { | ||
await this.findText(findText); | ||
await this.page.getByText("+", { exact: true }).click(); | ||
await this.page.getByPlaceholder("Replace with").fill(replaceText); | ||
await this.page.getByText("Replace").click(); | ||
} | ||
|
||
async updateBrick() { | ||
await this.page.getByRole("button", { name: "Update Brick" }).click(); | ||
} | ||
|
||
async deleteBrick() { | ||
await this.page.getByRole("button", { name: "Delete Brick" }).click(); | ||
await this.page.getByRole("button", { name: "Permanently Delete" }).click(); | ||
} | ||
} |
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
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
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
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,126 @@ | ||
/* | ||
* Copyright (C) 2024 PixieBrix, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { expect, test } from "../fixtures/extensionBase"; | ||
// @ts-expect-error -- https://youtrack.jetbrains.com/issue/AQUA-711/Provide-a-run-configuration-for-Playwright-tests-in-specs-with-fixture-imports-only | ||
import { type Page, test as base } from "@playwright/test"; | ||
import { ModsPage } from "../pageObjects/extensionConsole/modsPage"; | ||
import { clickAndWaitForNewPage } from "end-to-end-tests/utils"; | ||
import { WorkshopPage } from "end-to-end-tests/pageObjects/extensionConsole/workshopPage"; | ||
|
||
test("create, run, package, and update mod", async ({ | ||
page, | ||
extensionId, | ||
newPageEditorPage, | ||
context, | ||
}) => { | ||
await page.goto("/create-react-app/table"); | ||
const pageEditorPage = await newPageEditorPage(page.url()); | ||
|
||
const { modComponentName, modUuid } = | ||
await pageEditorPage.addStarterBrick("Button"); | ||
|
||
await test.step("Configure the Button brick", async () => { | ||
await page.bringToFront(); | ||
await page.getByRole("button", { name: "Action #3" }).click(); | ||
|
||
await pageEditorPage.bringToFront(); | ||
await pageEditorPage.getByLabel("Button text").fill("Search Youtube"); | ||
await pageEditorPage.setStarterBrickName(modComponentName); | ||
}); | ||
|
||
await test.step("Add the Extract from Page brick and configure it", async () => { | ||
await pageEditorPage.addBrickToModComponent("extract from page"); | ||
|
||
await pageEditorPage.getByPlaceholder("Property name").fill("searchText"); | ||
await expect(pageEditorPage.getByPlaceholder("Property name")).toHaveValue( | ||
"searchText", | ||
); | ||
|
||
await pageEditorPage.selectConnectedPageElement(page); | ||
}); | ||
|
||
await test.step("Add the YouTube search brick and configure it", async () => { | ||
await pageEditorPage.addBrickToModComponent("YouTube search in new tab", { | ||
index: 1, | ||
}); | ||
|
||
await pageEditorPage.getByLabel("Query").click(); | ||
await pageEditorPage.fillInBrickField( | ||
"Query", | ||
"{{ @data.searchText }} + Foo", | ||
); | ||
|
||
await pageEditorPage.waitForReduxUpdate(); | ||
}); | ||
|
||
const { modId } = await pageEditorPage.createModFromModComponent({ | ||
modNameRoot: "Lifecycle Test", | ||
modComponentName, | ||
modUuid, | ||
}); | ||
|
||
let newPage: Page | undefined; | ||
await test.step("Run the mod", async () => { | ||
newPage = await clickAndWaitForNewPage( | ||
page.getByRole("button", { name: "Search Youtube" }), | ||
context, | ||
); | ||
await expect(newPage).toHaveURL( | ||
"https://www.youtube.com/results?search_query=Transaction+Table+%2B+Foo", | ||
); | ||
}); | ||
|
||
await test.step("View and update mod in the Workshop", async () => { | ||
const workshopPage = new WorkshopPage(newPage, extensionId); | ||
await workshopPage.goto(); | ||
const editWorkshopModPage = await workshopPage.findAndSelectMod(modId); | ||
await editWorkshopModPage.findAndReplaceText( | ||
"version: 1.0.0", | ||
"version: 1.0.1", | ||
); | ||
await editWorkshopModPage.findAndReplaceText( | ||
"description: Created with the PixieBrix Page Editor", | ||
"description: Created through Playwright Automation", | ||
); | ||
await editWorkshopModPage.updateBrick(); | ||
}); | ||
|
||
await test.step("View the updated mod on the mods page", async () => { | ||
const modsPage = new ModsPage(newPage, extensionId); | ||
await modsPage.goto(); | ||
|
||
await modsPage.viewActiveMods(); | ||
const modListing = modsPage.modTableItemById(modId); | ||
|
||
await expect( | ||
modListing.getByRole("button", { name: "Update" }), | ||
).toBeVisible(); | ||
await modListing.getByRole("button", { name: "Update" }).click(); | ||
|
||
await expect(newPage.locator("form")).toContainText( | ||
"Created through Playwright Automation", | ||
); | ||
|
||
await expect( | ||
newPage.getByRole("button", { name: "Reactivate" }), | ||
).toBeVisible(); | ||
await newPage.getByRole("button", { name: "Reactivate" }).click(); | ||
|
||
await expect(modListing).toContainText("version 1.0.1"); | ||
}); | ||
}); |
Oops, something went wrong.