Skip to content

Commit

Permalink
Update the timeout (30s) for Playwright
Browse files Browse the repository at this point in the history
Signed-off-by: ytimocin <ytimocin@microsoft.com>
  • Loading branch information
ytimocin committed Apr 12, 2024
1 parent f173dee commit 8b85e27
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 66 deletions.
7 changes: 4 additions & 3 deletions .github/scripts/cleanup-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

set -e

echo "cleaning up cluster"
echo "Cleaning up cluster"

# Delete all test resources in queuemessages.
if kubectl get crd queuemessages.ucp.dev >/dev/null 2>&1; then
Expand All @@ -39,9 +39,10 @@ if kubectl get crd resources.ucp.dev >/dev/null 2>&1; then
fi

# Delete all test namespaces.
echo "delete all test namespaces"
# Any namespace that is not in the list below will be deleted.
echo "Delete all test namespaces"
namespaces=$(kubectl get namespace |
grep -E '^containers.*|^dapr |^dapr-dapr.*|^demo.*|^demo-demo-.*|^eshop-containers.*|^volumes.*|^volumes-myapp.*|^azure.*' |
grep -vE '(radius-system|kube-system|kube-public|kube-node-lease|gatekeeper-system|default|dapr-system|cert-manager)' |
awk '{print $1}')
for ns in $namespaces; do
if [ -z "$ns" ]; then
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test-aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: az CLI login
run: |
az login --service-principal \
Expand Down Expand Up @@ -107,20 +107,20 @@ jobs:
- name: eshop-azure
os: ubuntu-latest-m
runOnPullRequest: true
app: eshop
app: eshop-azure
env: azure
path: ./samples/eshop/eshop.bicep
uiTestFile: tests/eshop/eshop.app.spec.ts
deployArgs: -p environment='/planes/radius/local/resourceGroups/eshop-azure/providers/Applications.Core/environments/azure'
deployArgs: -p environment='/planes/radius/local/resourceGroups/eshop-azure/providers/Applications.Core/environments/azure' -p applicationName=eshop-azure
credential: azure
- name: eshop-aws
os: ubuntu-latest-m
runOnPullRequest: true
app: eshop
app: eshop-aws
env: aws
path: ./samples/eshop/eshop.bicep
uiTestFile: tests/eshop/eshop.app.spec.ts
deployArgs: -p environment='/planes/radius/local/resourceGroups/eshop-aws/providers/Applications.Core/environments/aws'
deployArgs: -p environment='/planes/radius/local/resourceGroups/eshop-aws/providers/Applications.Core/environments/aws' -p applicationName=eshop-aws
credential: aws
env:
BRANCH: ${{ github.base_ref || github.ref_name }}
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
if: steps.gen-id.outputs.RUN_TEST == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: az CLI login
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
if: steps.gen-id.outputs.RUN_TEST == 'true'
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
- name: az CLI login
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'azure'
run: |
Expand Down Expand Up @@ -300,7 +300,7 @@ jobs:
# Create pod-logs directory
mkdir -p playwright/pod-logs/${{ matrix.name }}
# Get pod logs and save to file
namespace="default-${{ matrix.app }}"
namespace="${{ matrix.env }}-${{ matrix.app }}"
label="radapp.io/application=${{ matrix.app }}"
pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
Expand Down
8 changes: 4 additions & 4 deletions playwright/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 playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.43.0",
"@types/node": "^20.12.5",
"@types/node": "^20.12.6",
"@types/uuid": "^9.0.8",
"typescript": "^5.4.4"
},
Expand Down
25 changes: 14 additions & 11 deletions playwright/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, devices } from '@playwright/test';
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
Expand All @@ -10,7 +10,7 @@ import { defineConfig, devices } from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand All @@ -20,31 +20,34 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
trace: "on-first-retry",
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],
timeout: 1 * 60 * 1000,
expect: {
timeout: 30 * 1000,
},
});
71 changes: 36 additions & 35 deletions playwright/tests/eshop/eshop.app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,73 +19,74 @@ test("eShop on Containers App Basic UI and Functionality Checks", async ({
await page.goto(endpoint);

// Expect page to have proper URL
expect(page).toHaveURL(new RegExp(`${endpoint}/catalog.*`));

await expect(page).toHaveURL(new RegExp(`${endpoint}/catalog.*`));
// Expect page to have proper title
expect(page).toHaveTitle("eShopOnContainers - SPA");

// Check for the LOGIN button
await expect(page.getByText("LOGIN")).toBeVisible();
await expect(page).toHaveTitle("eShopOnContainers - SPA");

// Click on the LOGIN button
await page.getByText("LOGIN").click();
// Check for the LOGIN button in the home page
const loginButton = page.getByText("LOGIN");
await expect(loginButton).toBeVisible();
await loginButton.click();

// Expect page to have proper title
expect(page).toHaveTitle("eShopOnContainers - Identity");
// Expect login page to have proper title
await expect(page).toHaveTitle("eShopOnContainers - Identity");

// Fill in the username and password
expect(page.getByPlaceholder("Username")).toBeVisible();
await page.getByPlaceholder("Username").click();
await page.getByPlaceholder("Username").fill("alice");
const username = page.getByPlaceholder("Username");
await expect(username).toBeVisible();
await username.click();
await username.fill("alice");

expect(page.getByPlaceholder("Password")).toBeVisible();
await page.getByPlaceholder("Password").click();
await page.getByPlaceholder("Password").fill("Pass123$");
const password = page.getByPlaceholder("Password");
await expect(password).toBeVisible();
await password.click();
await password.fill("Pass123$");

// Click on the LOGIN button
await page.getByRole("button", { name: "Login" }).click();

// After login, expect to be redirected to the catalog page
// Expect page to have proper URL
expect(page).toHaveURL(new RegExp(`${endpoint}/catalog.*`));

await expect(page).toHaveURL(new RegExp(`${endpoint}/catalog.*`));
// Expect page to have proper title
expect(page).toHaveTitle("eShopOnContainers - SPA");
await expect(page).toHaveTitle("eShopOnContainers - SPA");

// Logged user details should be visible
expect(page.getByText("AliceSmith@email.com")).toBeVisible();

const user = page.getByText("AliceSmith@email.com");
await expect(user).toBeVisible();
// Click on the user details
await page.getByText("AliceSmith@email.com").click();
await user.click();

// Check dropdown menu
expect(page.getByText("My orders")).toBeVisible();
expect(page.getByText("Log Out")).toBeVisible();
await expect(page.getByText("My orders")).toBeVisible();
await expect(page.getByText("Log Out")).toBeVisible();

let numberOfItemsAdded = 0;
// Add an item to the cart
await page
.locator(
"div:nth-child(2) > .esh-catalog-item > .esh-catalog-thumbnail-wrapper > .esh-catalog-thumbnail-icon > .esh-catalog-thumbnail-icon-svg"
)
.click();
const firstItem = page.locator("div:nth-child(1) > .esh-catalog-item");
await expect(firstItem).toBeVisible();
await firstItem.click();
numberOfItemsAdded++;

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

// Go to the cart
await page.getByRole("link", { name: `${numberOfItemsAdded}` }).click();
const cartLink = page.getByRole("link", { name: `${numberOfItemsAdded}` });
await expect(cartLink).toBeVisible();
await cartLink.click();

// Expect page to have proper URL
expect(page).toHaveURL(new RegExp(`${endpoint}/basket.*`));

await expect(page).toHaveURL(new RegExp(`${endpoint}/basket.*`));
// Checkout
await page.getByRole("button", { name: "Checkout" }).click();

// Place the order
await page.getByRole("button", { name: "Place Order" }).click();

// Continue Shopping
await page.getByRole("link", { name: "Continue Shopping" }).click();

// Logout
await page.locator("div").filter({ hasText: "Log Out" }).nth(0).click();
});
5 changes: 1 addition & 4 deletions samples/eshop/infra/networking.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import radius as rad
@description('Radius application ID')
param application string

// GATEWAY RESOURCE NAME - Unique string generated from the application and gw
param gatewayName string = 'gw${uniqueString(application)}'

// GATEWAY ---------------------------------------------------------

resource gateway 'Applications.Core/gateways@2023-10-01-preview' = {
name: gatewayName
name: 'gateway'
properties: {
application: application
routes: [
Expand Down

0 comments on commit 8b85e27

Please sign in to comment.