Skip to content
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

Use retry and update eshop playwright tests to wait for the catalog to appear #1213

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,25 @@ jobs:
- name: Run Playwright Test
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.uiTestFile != ''
id: run-playwright-test
run: |
if [[ "${{ matrix.container }}" != "" ]]; then
rad resource expose containers ${{ matrix.container }} ${{ matrix.exposeArgs }} --port ${{ matrix.port }} &
echo "Endpoint: http://localhost:${{ matrix.port }}"
export ENDPOINT="http://localhost:${{ matrix.port }}"
else
endpoint="$(rad app status -a ${{ matrix.app }} | sed 's/ /\n/g' | grep http)"
echo "Endpoint: $endpoint"
export ENDPOINT=$endpoint
fi
cd playwright/
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }} --retries 3
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: |
if [[ "${{ matrix.container }}" != "" ]]; then
rad resource expose containers ${{ matrix.container }} ${{ matrix.exposeArgs }} --port ${{ matrix.port }} &
echo "Endpoint: http://localhost:${{ matrix.port }}"
export ENDPOINT="http://localhost:${{ matrix.port }}"
else
endpoint="$(rad app status -a ${{ matrix.app }} | sed 's/ /\n/g' | grep http)"
echo "Endpoint: $endpoint"
export ENDPOINT=$endpoint
fi
cd playwright/
npm ci
npx playwright install --with-deps
npx playwright test ${{ matrix.uiTestFile }} --retries 3
- name: Upload Playwright Results
uses: actions/upload-artifact@v3
if: always() && ( steps.run-playwright-test.outcome == 'success' || steps.run-playwright-test.outcome == 'failure' )
Expand Down
20 changes: 18 additions & 2 deletions playwright/tests/eshop/eshop.app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,33 @@ test("eShop on Containers App Basic UI and Functionality Checks", async ({
await expect(page.getByText("My orders")).toBeVisible();
await expect(page.getByText("Log Out")).toBeVisible();

// Find the catalog
console.log("Finding the catalog");
const catalogSelector = "esh-catalog";
await page.waitForSelector(catalogSelector);
const catalog = page.locator(catalogSelector);
await expect(catalog).toBeVisible();
console.log("Catalog found");

let numberOfItemsAdded = 0;
// Add an item to the cart
const firstItem = page.locator("div:nth-child(1) > .esh-catalog-item");
console.log("Adding the first item to the cart");
const firstItemSelector = "div:nth-child(1) > .esh-catalog-item";
await page.waitForSelector(firstItemSelector);
const firstItem = page.locator(firstItemSelector);
await expect(firstItem).toBeVisible();
await firstItem.click();
console.log("Item added to the cart");
numberOfItemsAdded++;

// Add an item to the cart
const secondItem = page.locator("div:nth-child(2) > .esh-catalog-item");
console.log("Adding the second item to the cart");
const secondItemSelector = "div:nth-child(2) > .esh-catalog-item";
await page.waitForSelector(secondItemSelector);
const secondItem = page.locator(secondItemSelector);
await expect(secondItem).toBeVisible();
await secondItem.click();
console.log("Item added to the cart");
numberOfItemsAdded++;

// Go to the cart
Expand Down
Loading