Skip to content

Commit 8536c41

Browse files
Merge pull request #1 from sergeyshmakov/2026-03-13-fix-list-page-object-item
2026 03 13 fix list page object item
2 parents dbc9212 + c63f426 commit 8536c41

File tree

17 files changed

+942
-293
lines changed

17 files changed

+942
-293
lines changed

.husky/pre-commit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
npx lint-staged
12
npm test
2-
npx @biomejs/biome check --write --staged --no-errors-on-unmatched
3+
npm run typecheck

.lintstagedrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*.{ts,tsx,js,jsx,json}": "npx @biomejs/biome check --write"
3+
}

example/e2e/checkout.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,18 @@ test("should use filterByText to get matching items", async ({
5757
const widgetItems = checkoutPage.CartItems.filterByText("Widget");
5858
await widgetItems.expect().toHaveCount(2);
5959
});
60+
61+
test("should use ListPageObject without itemType — items are PageObjects", async ({
62+
checkoutPage,
63+
}) => {
64+
const firstItem = checkoutPage.CartItemsAsPlainList.items[0];
65+
await firstItem.expect().toBeVisible();
66+
});
67+
68+
test("should iterate CartItemsAsPlainList with for await — items support PageObject API", async ({
69+
checkoutPage,
70+
}) => {
71+
for await (const item of checkoutPage.CartItemsAsPlainList.items) {
72+
await item.expect({ soft: true }).toBeVisible();
73+
}
74+
});

example/e2e/page-objects/CheckoutPage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export class CheckoutPage extends PageObject {
2626
@ListStrictSelector("CartItem")
2727
accessor CartItems = new ListPageObject(CartItemControl);
2828

29+
/** List without custom item type — items are plain PageObject instances */
30+
@ListStrictSelector("CartItem")
31+
accessor CartItemsAsPlainList = new ListPageObject();
32+
2933
async applyPromoCode(code: string) {
3034
await this.PromoCode.$.fill(code);
3135
await this.ApplyPromoButton.$.click();

example/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)