Compare commits
4 Commits
jest
...
playwright
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6dec5b6e82 | ||
![]() |
b2194e5950 | ||
![]() |
a1fc1b2863 | ||
![]() |
b2321c7ee7 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# tests
|
||||||
|
test-results/
|
||||||
|
playwright-report/
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"require":"ts-node/register",
|
|
||||||
"spec":"./tests/**/*.ts"
|
|
||||||
}
|
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"Orta.vscode-jest",
|
"ms-playwright.playwright",
|
||||||
],
|
],
|
||||||
"unwantedRecommendations": []
|
"unwantedRecommendations": []
|
||||||
}
|
}
|
@@ -4,7 +4,7 @@
|
|||||||
* GIT
|
* GIT
|
||||||
* vscode
|
* vscode
|
||||||
* nodejs
|
* nodejs
|
||||||
* vscode-jest插件
|
* vscode playwright 插件
|
||||||
|
|
||||||
### 安装依赖
|
### 安装依赖
|
||||||
```
|
```
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
const esModules = ['.*\\.mjs$', 'lodash-es'].join('|');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
transform: {
|
|
||||||
// '^.+\\.vue$': '@vue/vue2-jest', // Update to match your installed version
|
|
||||||
'^.+\\.(t|j)sx?$': '@swc/jest',
|
|
||||||
},
|
|
||||||
extensionsToTreatAsEsm: ['.ts', '.tsx'], // .vue
|
|
||||||
// testEnvironment: '@happy-dom/jest-environment',
|
|
||||||
moduleNameMapper: {
|
|
||||||
// '@/(.*)': '<rootDir>/src/$1',
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: [`node_modules/(?!${esModules})`],
|
|
||||||
};
|
|
12
package.json
12
package.json
@@ -6,17 +6,15 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"init": "playwright install",
|
"init": "playwright install",
|
||||||
"codegen": "playwright codegen",
|
"codegen": "playwright codegen",
|
||||||
"test": "jest"
|
"test": "playwright test"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b",
|
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/globals": "^29.7.0",
|
"@playwright/test": "^1.52.0",
|
||||||
"@swc/core": "^1.7.4",
|
"@types/node": "^22.15.16",
|
||||||
"@swc/jest": "^0.2.36",
|
"playwright": "^1.52.0",
|
||||||
"jest": "^29.7.0",
|
"typescript": "^5.8.3"
|
||||||
"playwright": "^1.45.3",
|
|
||||||
"typescript": "^5.5.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
playwright.config.ts
Normal file
42
playwright.config.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
// Look for test files in the "tests" directory, relative to this configuration file.
|
||||||
|
testDir: 'tests',
|
||||||
|
|
||||||
|
// Run all tests in parallel.
|
||||||
|
fullyParallel: true,
|
||||||
|
|
||||||
|
// Fail the build on CI if you accidentally left test.only in the source code.
|
||||||
|
// forbidOnly: !!process.env.CI,
|
||||||
|
|
||||||
|
// Retry on CI only.
|
||||||
|
// retries: process.env.CI ? 2 : 0,
|
||||||
|
|
||||||
|
// Opt out of parallel tests on CI.
|
||||||
|
// workers: process.env.CI ? 1 : undefined,
|
||||||
|
|
||||||
|
// Reporter to use
|
||||||
|
reporter: 'html',
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
// trace: 'on-first-retry',
|
||||||
|
// },
|
||||||
|
// Configure projects for major browsers.
|
||||||
|
// projects: [
|
||||||
|
// {
|
||||||
|
// name: 'chromium',
|
||||||
|
// use: { ...devices['Desktop Chrome'] },
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// Run your local dev server before starting the tests.
|
||||||
|
// webServer: {
|
||||||
|
// command: 'npm run start',
|
||||||
|
// url: 'http://127.0.0.1:3000',
|
||||||
|
// reuseExistingServer: !process.env.CI,
|
||||||
|
// },
|
||||||
|
});
|
2669
pnpm-lock.yaml
generated
2669
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
54
tests/cad/cd.test.ts
Normal file
54
tests/cad/cd.test.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('webcad-cd', async ({ page }) => {
|
||||||
|
await page.goto('https://t.cfcad.cn/');
|
||||||
|
await page.getByPlaceholder('请输入您的账号').click();
|
||||||
|
await page.getByPlaceholder('请输入您的账号').fill('zc3');
|
||||||
|
await page.getByPlaceholder('请输入您的账号').press('Tab');
|
||||||
|
await page.getByPlaceholder('请输入您的密码').fill('123456');
|
||||||
|
await page.getByRole('button', { name: '登录' }).click();
|
||||||
|
await page.getByRole('button', { name: '开始设计>>' }).click();
|
||||||
|
await page.getByRole('listitem', { name: '左右侧板 LEFTRIGHTBOARD' }).getByRole('img').click();
|
||||||
|
await page.getByRole('button', { name: '确定' }).click();
|
||||||
|
await page.locator('canvas').nth(1).click({
|
||||||
|
position: {
|
||||||
|
x: 483,
|
||||||
|
y: 381
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await page.getByText('顶底板').click();
|
||||||
|
await page.getByRole('button', { name: '确定' }).click();
|
||||||
|
await page.locator('canvas').nth(1).click({
|
||||||
|
position: {
|
||||||
|
x: 520,
|
||||||
|
y: 377
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await page.getByPlaceholder('请输入命令:').click();
|
||||||
|
await page.getByPlaceholder('请输入命令:').fill('cd');
|
||||||
|
await page.getByPlaceholder('请输入命令:').press('Enter');
|
||||||
|
await page.locator('canvas').nth(1).click({
|
||||||
|
position: {
|
||||||
|
x: 826,
|
||||||
|
y: 447
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await page.locator('canvas').nth(1).click({
|
||||||
|
position: {
|
||||||
|
x: 402,
|
||||||
|
y: 57
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await page.locator('body').press('Enter');
|
||||||
|
await page.frameLocator('iframe').getByRole('cell', { name: '|||' }).click();
|
||||||
|
await page.frameLocator('iframe').locator('td:nth-child(3) > .cell').first().dblclick();
|
||||||
|
await page.frameLocator('iframe').getByRole('button', { name: '下一步' }).click();
|
||||||
|
await page.frameLocator('iframe').getByPlaceholder('请输入内容').nth(1).click();
|
||||||
|
await page.frameLocator('iframe').getByPlaceholder('请输入内容').nth(1).fill('11');
|
||||||
|
await page.frameLocator('iframe').getByPlaceholder('请输入内容').nth(2).click();
|
||||||
|
await page.frameLocator('iframe').getByPlaceholder('请输入内容').nth(2).fill('2222');
|
||||||
|
await page.frameLocator('iframe').locator('#app').click();
|
||||||
|
const page1Promise = page.waitForEvent('popup');
|
||||||
|
await page.frameLocator('iframe').getByRole('button', { name: '保存' }).click();
|
||||||
|
const page1 = await page1Promise;
|
||||||
|
});
|
@@ -1,9 +1,9 @@
|
|||||||
import { describe, it, expect } from '@jest/globals'
|
import { test } from '@playwright/test'
|
||||||
import { chromium } from "playwright";
|
import { chromium } from "playwright";
|
||||||
|
|
||||||
describe("mes登录", function () {
|
test.describe("mes登录", function () {
|
||||||
|
|
||||||
it('login', async function () {
|
test('login', async function () {
|
||||||
const browser = await chromium.launch({
|
const browser = await chromium.launch({
|
||||||
// headless: false
|
// headless: false
|
||||||
});
|
});
|
||||||
@@ -32,7 +32,7 @@ describe("mes登录", function () {
|
|||||||
|
|
||||||
await page.waitForTimeout(1000)
|
await page.waitForTimeout(1000)
|
||||||
let path = await page.evaluateHandle(()=>window.location.hash.substr(1))
|
let path = await page.evaluateHandle(()=>window.location.hash.substr(1))
|
||||||
expect(await path.jsonValue()).toEqual('/dashboard')
|
test.expect(await path.jsonValue()).toEqual('/dashboard')
|
||||||
|
|
||||||
|
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { describe, it, expect } from '@jest/globals'
|
import { test } from '@playwright/test'
|
||||||
import { chromium } from "playwright";
|
import { chromium } from "playwright";
|
||||||
|
|
||||||
describe('平台', function(){
|
test.describe('平台', function(){
|
||||||
|
|
||||||
it('登陆', async function(){
|
test('登陆', async function(){
|
||||||
|
|
||||||
const browser = await chromium.launch({
|
const browser = await chromium.launch({
|
||||||
// headless: false
|
// headless: false
|
||||||
@@ -30,7 +30,7 @@ describe('平台', function(){
|
|||||||
|
|
||||||
let path = await page.evaluateHandle(()=>window.location.pathname);
|
let path = await page.evaluateHandle(()=>window.location.pathname);
|
||||||
|
|
||||||
expect(await path.jsonValue()).not.toEqual('/user-login.html')
|
test.expect(await path.jsonValue()).not.toEqual('/user-login.html')
|
||||||
|
|
||||||
// ---------------------
|
// ---------------------
|
||||||
await context.close();
|
await context.close();
|
||||||
|
Reference in New Issue
Block a user