浏览代码

test: 迁移测试文件到test目录并添加playwright配置

- 将pages_know_info.test.ts移动到test目录
- 新增package.json和package-lock.json
- 添加playwright.config.ts配置文件
yourname 7 月之前
父节点
当前提交
96130ff3f5
共有 7 个文件被更改,包括 109 次插入31 次删除
  1. 2 0
      .gitignore
  2. 1 2
      deno.json
  3. 0 26
      deno.lock
  4. 75 0
      test/package-lock.json
  5. 14 0
      test/package.json
  6. 4 3
      test/pages_know_info.test.ts
  7. 13 0
      test/playwright.config.ts

+ 2 - 0
.gitignore

@@ -1 +1,3 @@
 .aider*
+node_modules
+test-results

+ 1 - 2
deno.json

@@ -38,8 +38,7 @@
     "aliyun-rtc-sdk":"https://esm.d8d.fun/aliyun-rtc-sdk@6.14.6?standalone",
     "@testing-library/react": "https://esm.d8d.fun/@testing-library/react@16.3.0?dev&deps=react@19.0.0,react-dom@19.0.0",
     "@testing-library/user-event":"npm:@testing-library/user-event@14.6.1",
-    "jsdom":"npm:jsdom@26.0.0",
-    "@playwright/test":"npm:@playwright/test@1.52.0"
+    "jsdom":"npm:jsdom@26.0.0"
   },
   "compilerOptions": {
     "lib": ["dom", "dom.iterable", "esnext", "deno.ns"]

+ 0 - 26
deno.lock

@@ -4,7 +4,6 @@
     "npm:@alicloud/live-interaction20201214@2.1.6": "2.1.6",
     "npm:@alicloud/live20161101@^1.1.1": "1.1.1",
     "npm:@alicloud/openapi-client@~0.4.14": "0.4.14",
-    "npm:@playwright/test@1.52.0": "1.52.0",
     "npm:@testing-library/user-event@14.6.1": "14.6.1_@testing-library+dom@10.4.0",
     "npm:@types/node@*": "22.12.0",
     "npm:jsdom@26.0.0": "26.0.0"
@@ -187,14 +186,6 @@
       ],
       "tarball": "https://registry.npmmirror.com/@darabonba/typescript/-/typescript-1.0.3.tgz"
     },
-    "@playwright/test@1.52.0": {
-      "integrity": "sha512-uh6W7sb55hl7D6vsAeA+V2p5JnlAqzhqFyF0VcJkKZXkgnFcVG9PziERRHQfPLfNGx1C292a4JqbWzhR8L4R1g==",
-      "dependencies": [
-        "playwright"
-      ],
-      "bin": true,
-      "tarball": "https://registry.npmmirror.com/@playwright/test/-/test-1.52.0.tgz"
-    },
     "@testing-library/dom@10.4.0": {
       "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==",
       "dependencies": [
@@ -605,22 +596,6 @@
       "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
       "tarball": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz"
     },
-    "playwright-core@1.52.0": {
-      "integrity": "sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==",
-      "bin": true,
-      "tarball": "https://registry.npmmirror.com/playwright-core/-/playwright-core-1.52.0.tgz"
-    },
-    "playwright@1.52.0": {
-      "integrity": "sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==",
-      "dependencies": [
-        "playwright-core"
-      ],
-      "optionalDependencies": [
-        "fsevents"
-      ],
-      "bin": true,
-      "tarball": "https://registry.npmmirror.com/playwright/-/playwright-1.52.0.tgz"
-    },
     "pretty-format@27.5.1": {
       "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
       "dependencies": [
@@ -1011,7 +986,6 @@
       "npm:@alicloud/live20161101@^1.1.1",
       "npm:@alicloud/openapi-client@~0.4.14",
       "npm:@alicloud/pop-core@1.8.0",
-      "npm:@playwright/test@1.52.0",
       "npm:@testing-library/user-event@14.6.1",
       "npm:jsdom@26.0.0"
     ]

+ 75 - 0
test/package-lock.json

@@ -0,0 +1,75 @@
+{
+  "name": "test",
+  "version": "1.0.0",
+  "lockfileVersion": 3,
+  "requires": true,
+  "packages": {
+    "": {
+      "name": "test",
+      "version": "1.0.0",
+      "license": "ISC",
+      "dependencies": {
+        "@playwright/test": "1.51.1"
+      }
+    },
+    "node_modules/@playwright/test": {
+      "version": "1.51.1",
+      "resolved": "https://registry.npmmirror.com/@playwright/test/-/test-1.51.1.tgz",
+      "integrity": "sha512-nM+kEaTSAoVlXmMPH10017vn3FSiFqr/bh4fKg9vmAdMfd9SDqRZNvPSiAHADc/itWak+qPvMPZQOPwCBW7k7Q==",
+      "license": "Apache-2.0",
+      "dependencies": {
+        "playwright": "1.51.1"
+      },
+      "bin": {
+        "playwright": "cli.js"
+      },
+      "engines": {
+        "node": ">=18"
+      }
+    },
+    "node_modules/fsevents": {
+      "version": "2.3.2",
+      "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz",
+      "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
+      "hasInstallScript": true,
+      "license": "MIT",
+      "optional": true,
+      "os": [
+        "darwin"
+      ],
+      "engines": {
+        "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+      }
+    },
+    "node_modules/playwright": {
+      "version": "1.51.1",
+      "resolved": "https://registry.npmmirror.com/playwright/-/playwright-1.51.1.tgz",
+      "integrity": "sha512-kkx+MB2KQRkyxjYPc3a0wLZZoDczmppyGJIvQ43l+aZihkaVvmu/21kiyaHeHjiFxjxNNFnUncKmcGIyOojsaw==",
+      "license": "Apache-2.0",
+      "dependencies": {
+        "playwright-core": "1.51.1"
+      },
+      "bin": {
+        "playwright": "cli.js"
+      },
+      "engines": {
+        "node": ">=18"
+      },
+      "optionalDependencies": {
+        "fsevents": "2.3.2"
+      }
+    },
+    "node_modules/playwright-core": {
+      "version": "1.51.1",
+      "resolved": "https://registry.npmmirror.com/playwright-core/-/playwright-core-1.51.1.tgz",
+      "integrity": "sha512-/crRMj8+j/Nq5s8QcvegseuyeZPxpQCZb6HNk3Sos3BlZyAknRjoyJPFWkpNn8v0+P3WiwqFF8P+zQo4eqiNuw==",
+      "license": "Apache-2.0",
+      "bin": {
+        "playwright-core": "cli.js"
+      },
+      "engines": {
+        "node": ">=18"
+      }
+    }
+  }
+}

+ 14 - 0
test/package.json

@@ -0,0 +1,14 @@
+{
+  "name": "test",
+  "version": "1.0.0",
+  "main": "index.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "dependencies": {
+    "@playwright/test":"1.51.1"
+  },
+  "author": "",
+  "license": "ISC",
+  "description": ""
+}

+ 4 - 3
client/admin/pages_know_info.test.ts → test/pages_know_info.test.ts

@@ -2,9 +2,10 @@ import { test, expect } from '@playwright/test';
 
 test.describe('知识库管理CRUD测试', () => {
   test.beforeEach(async ({ page }) => {
-    await page.goto('https://pre-117-77-template-23969.d.d8d.fun/admin/know-info');
+    // await page.goto('https://pre-117-77-template-23969.d.d8d.fun/admin/know-info');
+    await page.goto('https://pre-117-77-template.r.d8d.fun/admin/know-info');
     await page.evaluate(() => {
-      localStorage.setItem('token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwidXNlcm5hbWUiOiJhZG1pbiIsInNlc3Npb25JZCI6Im1DeG40MXZRRGd6S3NSQkNWOWw5WCIsInJvbGVJbmZvIjpudWxsLCJpYXQiOjE3NDYxOTY3ODksImV4cCI6MTc0NjI4MzE4OX0.Sqg5zapPc_DLxQYDtNUS5MVVCblbyW9vSWCONWPWnRc');
+      localStorage.setItem('token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwidXNlcm5hbWUiOiJhZG1pbiIsInNlc3Npb25JZCI6ImxCMXNPWTE5czhRVEgxY2tDeWlrZyIsInJvbGVJbmZvIjpudWxsLCJpYXQiOjE3NDYzNjA0NzMsImV4cCI6MTc0NjQ0Njg3M30.Og7RmROGcGNZlduE8mFqFz8ou6diwWAuSZntrUUnIJM');
     });
     await page.reload();
   });
@@ -17,7 +18,7 @@ test.describe('知识库管理CRUD测试', () => {
   });
 
   test('搜索测试文章', async ({ page }) => {
-    await page.fill('input[placeholder="请输入文章标题"]', '测试文章-自动化测试');
+    await page.fill('input[placeholder="要搜索的文章标题"]', '测试文章-自动化测试');
     await page.click('button:has-text("搜 索")');
     await expect(page.locator('text=测试文章-自动化测试')).toBeVisible();
     await page.click('button:has-text("重 置")');

+ 13 - 0
test/playwright.config.ts

@@ -0,0 +1,13 @@
+// playwright.config.js
+const { defineConfig } = require('@playwright/test');
+
+module.exports = defineConfig({
+    projects: [
+        {
+            name: 'chromium',
+            use: {
+                browserName: 'chromium',
+            },
+        },
+    ],
+});