更新 Playwright 依赖至 1.50.1,并优化测试用例中的登录流程,提高可读性和稳定性

This commit is contained in:
LingandRX 2025-03-06 21:01:11 +08:00
parent 73cce24b80
commit 9307f09ec0
3 changed files with 15 additions and 17 deletions

24
package-lock.json generated
View File

@ -13,7 +13,7 @@
}, },
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^9.0.3", "@faker-js/faker": "^9.0.3",
"@playwright/test": "^1.48.1", "@playwright/test": "^1.50.1",
"@types/node": "^22.7.5", "@types/node": "^22.7.5",
"dotenv": "^16.4.5" "dotenv": "^16.4.5"
} }
@ -36,13 +36,13 @@
} }
}, },
"node_modules/@playwright/test": { "node_modules/@playwright/test": {
"version": "1.48.1", "version": "1.50.1",
"resolved": "https://registry.npmmirror.com/@playwright/test/-/test-1.48.1.tgz", "resolved": "https://registry.npmmirror.com/@playwright/test/-/test-1.50.1.tgz",
"integrity": "sha512-s9RtWoxkOLmRJdw3oFvhFbs9OJS0BzrLUc8Hf6l2UdCNd1rqeEyD4BhCJkvzeEoD1FsK4mirsWwGerhVmYKtZg==", "integrity": "sha512-Jii3aBg+CEDpgnuDxEp/h7BimHcUTDlpEtce89xEumlJ5ef2hqepZ+PWp1DDpYC/VO9fmWVI1IlEaoI5fK9FXQ==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"playwright": "1.48.1" "playwright": "1.50.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -96,13 +96,13 @@
} }
}, },
"node_modules/playwright": { "node_modules/playwright": {
"version": "1.48.1", "version": "1.50.1",
"resolved": "https://registry.npmmirror.com/playwright/-/playwright-1.48.1.tgz", "resolved": "https://registry.npmmirror.com/playwright/-/playwright-1.50.1.tgz",
"integrity": "sha512-j8CiHW/V6HxmbntOfyB4+T/uk08tBy6ph0MpBXwuoofkSnLmlfdYNNkFTYD6ofzzlSqLA1fwH4vwvVFvJgLN0w==", "integrity": "sha512-G8rwsOQJ63XG6BbKj2w5rHeavFjy5zynBA9zsJMMtBoe/Uf757oG12NXz6e6OirF7RCrTVAKFXbLmn1RbL7Qaw==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"playwright-core": "1.48.1" "playwright-core": "1.50.1"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
@ -115,9 +115,9 @@
} }
}, },
"node_modules/playwright-core": { "node_modules/playwright-core": {
"version": "1.48.1", "version": "1.50.1",
"resolved": "https://registry.npmmirror.com/playwright-core/-/playwright-core-1.48.1.tgz", "resolved": "https://registry.npmmirror.com/playwright-core/-/playwright-core-1.50.1.tgz",
"integrity": "sha512-Yw/t4VAFX/bBr1OzwCuOMZkY1Cnb4z/doAFSwf4huqAGWmf9eMNjmK7NiOljCdLmxeRYcGPPmcDgU0zOlzP0YA==", "integrity": "sha512-ra9fsNWayuYumt+NiM069M6OkcRb1FZSK8bgi66AtpFoWkg2+y0bJSNmkFrWhMbEBbVKC/EruAHH3g0zmtwGmQ==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"bin": { "bin": {

View File

@ -18,7 +18,7 @@
"description": "", "description": "",
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^9.0.3", "@faker-js/faker": "^9.0.3",
"@playwright/test": "^1.48.1", "@playwright/test": "^1.50.1",
"@types/node": "^22.7.5", "@types/node": "^22.7.5",
"dotenv": "^16.4.5" "dotenv": "^16.4.5"
}, },

View File

@ -7,14 +7,12 @@ setup('zhb总部管理员登录', async ({ page, baseURL }) => {
const password = process.env.ZHB_PASSWORD; const password = process.env.ZHB_PASSWORD;
await page.goto(baseURL); await page.goto(baseURL);
await page.getByText('账号登录').click(); await expect(page.getByText('登录', { exact: true })).toBeEnabled();
await page.getByPlaceholder('用户名').fill(account); await page.getByPlaceholder('用户名').fill(account);
await page.getByPlaceholder('密码', { exact: true }).fill(password); await page.getByPlaceholder('密码', { exact: true }).fill(password);
await page.getByText('登录', { exact: true }).click(); await page.getByText('登录', { exact: true }).click();
await expect(page.getByText('演示一店')).toBeVisible(); await expect(page.getByText('演示一店')).toBeVisible();
await expect(page.getByText('演示二店')).toBeVisible(); await page.getByText('演示一店', { exact: true }).click();
await page.getByText('演示一店').click();
await expect(page.locator('#tab_main li').filter({ hasText: '营业' })).toBeVisible(); await expect(page.locator('#tab_main li').filter({ hasText: '营业' })).toBeVisible();
await page.context().storageState({ path: zhbAuthFile }); await page.context().storageState({ path: zhbAuthFile });
}); });