WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 647229b

Browse files
resolve comflicts with main
2 parents e30eacd + d1c5c25 commit 647229b

File tree

6 files changed

+91
-17
lines changed

6 files changed

+91
-17
lines changed

.github/workflows/playwright.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Playwright Tests
2+
on:
3+
push:
4+
branches: [ main, master ]
5+
pull_request:
6+
branches: [ main, master ]
7+
jobs:
8+
test:
9+
timeout-minutes: 60
10+
runs-on: ubuntu-latest
11+
env:
12+
VALID_USER_NAME: ${{ secrets.VALID_USER_NAME }}
13+
VALID_PASSWORD: ${{ secrets.VALID_PASSWORD }}
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: lts/*
19+
- name: Install dependencies
20+
run: npm ci
21+
- name: Install Playwright Browsers
22+
run: npx playwright install --with-deps
23+
- name: Run Playwright tests
24+
run: npx playwright test
25+
- uses: actions/upload-artifact@v4
26+
if: ${{ !cancelled() }}
27+
with:
28+
name: playwright-report
29+
path: playwright-report/
30+
retention-days: 30

.gitignore

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
# Ignore Mac system files
2+
.DS_store
3+
# Ignore node_modules folder
4+
node_modules
5+
# Ignore all text files
6+
*.txt
7+
# Ignore files related to API keys
8+
.env
9+
# Ignore SASS config files
10+
.sass-cache
111

2-
# Playwright
3-
node_modules/
412
/test-results/
513
/playwright-report/
614
/blob-report/

package-lock.json

Lines changed: 5 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"license": "ISC",
1010
"devDependencies": {
1111
"@playwright/test": "^1.50.1",
12-
"@types/node": "^22.13.0",
12+
"@types/node": "^22.13.0"
13+
},
14+
"dependencies": {
1315
"dotenv": "^16.4.7"
1416
}
1517
}

playwright.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig, devices } from '@playwright/test';
2-
import dotenv from 'dotenv';
2+
3+
import * as dotenv from 'dotenv';
34
dotenv.config();
45

56
export const validUserName = process.env.VALID_USER_NAME;
@@ -12,7 +13,6 @@ export const validPassword = process.env.VALID_PASSWORD;
1213
// import dotenv from 'dotenv';
1314
// import path from 'path';
1415
// dotenv.config({ path: path.resolve(__dirname, '.env') });
15-
// require('dotenv').config()
1616

1717
/**
1818
* See https://playwright.dev/docs/test-configuration.
@@ -82,4 +82,4 @@ export default defineConfig({
8282
// url: 'http://127.0.0.1:3000',
8383
// reuseExistingServer: !process.env.CI,
8484
// },
85-
});
85+
});

tests/example.spec.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { test, expect, request } from '@playwright/test';
2+
import { validUserName, validPassword } from '../playwright.config';
3+
4+
test('has title', async ({ page }) => {
5+
await page.goto('https://playwright.dev/');
6+
7+
// Expect a title "to contain" a substring.
8+
await expect(page).toHaveTitle(/Playwright/);
9+
});
10+
11+
test('get started link', async ({ page }) => {
12+
await page.goto('https://playwright.dev/');
13+
14+
// Click the get started link.
15+
await page.getByRole('link', { name: 'Get started' }).click();
16+
17+
// Expects page to have a heading with the name of Installation.
18+
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
19+
});
20+
21+
test.describe('Positive login test', () => {
22+
test('Login', async ({ request }) => {
23+
24+
if (!validUserName || !validPassword) {
25+
throw new Error('Username or password is undefined');
26+
}
27+
const response = await request.get('https://petstore.swagger.io/v2/user/login', {
28+
29+
params: {
30+
username: validUserName,
31+
password: validPassword,
32+
},
33+
});
34+
35+
expect(response.status()).toBe(200);
36+
37+
const responseBody = await response.json();
38+
console.log('Login response:', responseBody);
39+
});
40+
});

0 commit comments

Comments
 (0)