Skip to content
Open

Qa #23

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
10 changes: 10 additions & 0 deletions .claude/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mcpServers": {
"TestDino": {
"command": "/opt/homebrew/bin/testdino-mcp",
"env": {
"TESTDINO_PAT": "tpu_d50a352ff1a128668ecaeba1da1026825eb314678cf47751d50c55503c89297e"
}
}
}
}
89 changes: 21 additions & 68 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ on:
push:
pull_request:
schedule:
- cron: '30 3 * * 1-5' # 11:00 AM IST
- cron: '30 3 * * *' # 9:00 AM IST everyday # 11:00 AM IST
workflow_dispatch:

jobs:
run-tests:
name: Run Playwright tests ${{ matrix.shardIndex }}/3
name: Run shard ${{ matrix.shardIndex }}/5
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3]
shardTotal: [3]
shardIndex: [1, 2, 3, 4, 5]
shardTotal: [5]

steps:
- uses: actions/checkout@v4
- name: Checkout repo
uses: actions/checkout@v4

# ✅ REQUIRED: Node 20
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: '20'
node-version: "20"

- name: Create .env file
run: |
Expand All @@ -38,52 +38,22 @@ jobs:
echo "STATE=${{ secrets.STATE }}" >> .env
echo "COUNTRY=${{ secrets.COUNTRY }}" >> .env
echo "ZIP_CODE=${{ secrets.ZIP_CODE }}" >> .env

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install deps + browsers
- name: Install dependencies
run: |
npm ci
npx playwright install --with-deps chromium firefox webkit

# ✅ FULL + RERUN LOGIC
- name: Run Playwright (rerun failed tests if applicable)
env:
TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
npx playwright install --with-deps
- name: Run Playwright Tests
run: |
echo "GitHub run attempt: ${{ github.run_attempt }}"
if [[ "${{ github.run_attempt }}" -gt 1 ]]; then
echo "Detected re-run. Checking failed test metadata from TestDino."
npx tdpw last-failed \
--shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} \
> last-failed-flags.txt
EXTRA_PW_FLAGS="$(cat last-failed-flags.txt)"
if [[ -n "$EXTRA_PW_FLAGS" ]]; then
echo "Running only failed tests for this shard:"
echo "$EXTRA_PW_FLAGS"
# IMPORTANT: JSON + BLOB BOTH REQUIRED
# Ensure playwright-report directory exists
mkdir -p ./playwright-report
eval "npx playwright test $EXTRA_PW_FLAGS"
exit 0
fi
echo "No failed test metadata found. Falling back to full shard."
fi
# First run (full shard)
# Ensure playwright-report directory exists
mkdir -p ./playwright-report
npx playwright test \
--grep="@chromium|@firefox|@webkit" \
--shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}

- name: Upload blob report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
Expand All @@ -92,15 +62,6 @@ jobs:
path: ./blob-report
retention-days: 1

# ✅ THIS WILL SHOW "Metadata cached successfully ✔" WHEN JSON EXISTS
- name: Cache tdpw last failed metadata
if: always()
env:
TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
SHARD_INDEX: ${{ matrix.shardIndex }}
SHARD_TOTAL: ${{ matrix.shardTotal }}
run: |
npx tdpw cache --verbose
merge-reports:
name: Merge Reports
needs: run-tests
Expand All @@ -110,20 +71,12 @@ jobs:
steps:
- uses: actions/checkout@v4

# ✅ Node 20 here as well
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: '20'
node-version: "20"

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install deps + browsers
- name: Install dependencies
run: |
npm ci
npx playwright install --with-deps
Expand All @@ -135,19 +88,19 @@ jobs:
merge-multiple: true

- name: Merge HTML & JSON reports
run: npx playwright merge-reports --config=playwright.config.js ./all-blob-reports

- name: Upload combined report
run: |
npx playwright merge-reports \
--config=playwright.config.js \
./all-blob-reports
- name: Upload combined Playwright report
uses: actions/upload-artifact@v4
with:
name: Playwright Test Report
path: ./playwright-report
retention-days: 14

- name: Send TestDino report
- name: Upload report to TestDino
env:
TESTDINO_TOKEN: ${{ secrets.TESTDINO_TOKEN }}
run: |
npx --yes tdpw ./playwright-report \
--token="${{ secrets.TESTDINO_TOKEN }}" \
--upload-html \
--upload-traces \
--verbose
npx tdpw upload ./playwright-report --token="$TESTDINO_TOKEN"
46 changes: 33 additions & 13 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
// @ts-check
import { defineConfig, devices } from '@playwright/test';
import * as dotenv from 'dotenv';
import dotenv from 'dotenv';

// Load environment variables
dotenv.config();

dotenv.config({ quiet: true });
const isCI = !!process.env.CI;

export default defineConfig({
testDir: './tests',
snapshotDir: './__screenshots__',
fullyParallel: true,
forbidOnly: isCI,
retries: isCI ? 0 : 0,
workers: isCI ? 1 : 1,

retries: isCI ? 1 : 1, // Enable retries for flaky test behavior
workers: isCI ? 5 : 5,

timeout: 30 * 1000,
timeout: 60 * 1000,
expect: {
timeout: 10 * 1000,
},

reporter: [
['html', {
outputFolder: 'playwright-report',
open: 'never'
}],
['blob', { outputDir: 'blob-report' }], // Blob reporter for merging
['blob'], // ✅ REQUIRED for sharding
['html', { outputDir: './playwright-report' }],
['json', { outputFile: './playwright-report/report.json' }],
],

use: {
baseURL: 'https://storedemo.testdino.com',
baseURL: 'https://storedemo.testdino.com/products',
headless: true,
trace: 'on-first-retry',
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
actionTimeout: 15 * 1000,
navigationTimeout: 30 * 1000,
},

projects: [
Expand All @@ -47,5 +52,20 @@ export default defineConfig({
use: { ...devices['Desktop Safari'] },
grep: /@webkit/, // only run tests tagged @webkit
},
{
name: 'android',
use: { ...devices['Pixel 5'] },
grep: /@android/, // only run tests tagged @android
},
{
name: 'ios',
use: { ...devices['iPhone 14'] },
grep: /@ios/, // only run tests tagged @ios
},
{
name: 'api',
use: { ...devices['API'] },
grep: /@api/, // only run tests tagged @api
},
],
});
Loading
Loading