Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexprudhomme committed Nov 26, 2024
1 parent 9eeba4a commit c34adf1
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 4 deletions.
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/samples/headless-ssr-commerce/components/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Cart() {

return (
<div>
<ul>
<ul id="cart">
{state.items.map((item, index) => (
<li key={index}>
<p>
Expand Down
5 changes: 3 additions & 2 deletions packages/samples/headless-ssr-commerce/e2e/cart/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test.describe('default', () => {

const cartItemsCount = await cart.items.count();

expect(cartItemsCount).toBe(4);
expect(cartItemsCount).toBe(3);
});
});

Expand Down Expand Up @@ -221,6 +221,7 @@ test.describe('default', () => {
});
});
});

test.describe('ssr', () => {
const numItemsInCart = 0; // Define the numResults variable
const numItemsInCartMsg = `Items in cart: ${numItemsInCart}`;
Expand All @@ -238,7 +239,7 @@ test.describe('ssr', () => {
numItemsInCartMsg
);

expect(dom.window.document.querySelectorAll('ul li').length).toBe(
expect(dom.window.document.querySelectorAll('ul#cart li').length).toBe(
numItemsInCart
);
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CartPageObject {

get items() {
const cart = this.cart;
return cart.locator('ul > li');
return cart.locator('ul#cart > li');
}

async getItemQuantity(item: Locator) {
Expand Down
1 change: 1 addition & 0 deletions packages/samples/headless-ssr-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@types/node": "20.14.12",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@playwright/test": "1.45.3",
"eslint": "8.57",
"eslint-config-next": "14.2.5",
"jsdom": "25.0.1",
Expand Down

0 comments on commit c34adf1

Please sign in to comment.