-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#8581 mod listing page object model and organizing page editor POMs #8742
Changes from all commits
f811220
4c61914
b6d0193
fac68b8
0c1e215
3aab251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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 { BasePageObject } from "../basePageObject"; | ||
import { uuidv4 } from "@/types/helpers"; | ||
import { type Locator } from "@playwright/test"; | ||
|
||
export type StarterBrickUIName = | ||
| "Context Menu" | ||
| "Trigger" | ||
| "Button" | ||
| "Quick Bar Action" | ||
| "Dynamic Quick Bar" | ||
| "Sidebar Panel"; | ||
|
||
export class ModListItem extends BasePageObject { | ||
saveButton = this.locator("[data-icon=save]"); | ||
get menuButton() { | ||
return this.getByLabel(`${this.modComponentName} - Ellipsis`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, I didn't realize we had that aria label on those buttons |
||
} | ||
|
||
constructor( | ||
root: Locator, | ||
readonly modComponentName: string, | ||
) { | ||
super(root); | ||
} | ||
|
||
async activate() { | ||
return this.root.click(); | ||
} | ||
} | ||
|
||
export class ModListingPanel extends BasePageObject { | ||
addButton = this.getByRole("button", { name: "Add", exact: true }); | ||
|
||
/** | ||
* Adds a starter brick in the Page Editor. Generates a unique mod name to prevent | ||
* test collision. | ||
* | ||
* @param starterBrickName the starter brick name to add, corresponding to the name shown in the Page Editor UI, | ||
* not the underlying type | ||
* @returns modName the generated mod name | ||
*/ | ||
async addStarterBrick(starterBrickName: StarterBrickUIName) { | ||
const modUuid = uuidv4(); | ||
const modComponentName = `Test ${starterBrickName} ${modUuid}`; | ||
await this.addButton.click(); | ||
await this.locator("[role=button].dropdown-item", { | ||
hasText: starterBrickName, | ||
}).click(); | ||
|
||
return { modComponentName, modUuid }; | ||
} | ||
|
||
getModListItemByName(modName: string) { | ||
return new ModListItem( | ||
this.locator(".list-group-item", { hasText: modName }).first(), | ||
modName, | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,12 @@ export default defineConfig<{ chromiumChannel: string }>({ | |
|
||
/* Collect trace when retrying the failed test in CI, and always on failure when running locally. See https://playwright.dev/docs/trace-viewer */ | ||
trace: CI ? "on-first-retry" : "retain-on-failure", | ||
|
||
/* Set the default timeout for actions such as `click` */ | ||
actionTimeout: 5_000, | ||
|
||
/* Set the default timeout for page navigations */ | ||
navigationTimeout: 10_000, | ||
Comment on lines
+40
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. waiting the whole test timeout for a failed click action is annoying so I defined a default action and nav timeouts. |
||
}, | ||
/* Configure projects for major browsers */ | ||
projects: [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not directly related to this PR, but I had to add this timeout after defining a default timeout for actions