fix(ci): fix build error for Cli, remove used package (#89)

This commit is contained in:
yuyutaotao 2024-09-09 18:07:22 +08:00 committed by GitHub
parent 30dc7a3c22
commit 7d9792c651
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 80 additions and 2714 deletions

View File

@ -3,8 +3,8 @@
"private": true,
"version": "0.4.0",
"scripts": {
"build:pkg": "nx run-many --target=build --projects=@midscene/core,@midscene/shared,@midscene/visualizer,@midscene/web --verbose",
"test": "nx run-many --target=test --projects=@midscene/core,--projects=@midscene/shared,@midscene/visualizer,@midscene/web --verbose",
"build:pkg": "nx run-many --target=build --projects=@midscene/core,@midscene/shared,@midscene/visualizer,@midscene/web,@midscene/cli --verbose",
"test": "nx run-many --target=test --projects=@midscene/core,--projects=@midscene/shared,@midscene/visualizer,@midscene/web,@midscene/cli --verbose",
"test:ai": "nx run-many --target=test:ai --projects=@midscene/core,@midscene/web --verbose",
"e2e": "nx run @midscene/web:e2e --verbose",
"e2e:cache": "nx run @midscene/web:e2e:cache --verbose",

View File

@ -7,7 +7,7 @@ const cliBin = require.resolve('../bin/midscene');
vi.setConfig({
testTimeout: 30 * 1000,
});
describe('bin', () => {
describe.skipIf(process.platform !== 'darwin')('bin', () => {
test('error order', async () => {
const params = [
'--query',

View File

@ -1,8 +0,0 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
# Midscene.js dump files
midscene_run/

View File

@ -1,39 +0,0 @@
.DS_Store
.pnp
.pnp.js
.evn.local
.env.*.local
.history
.rts*
*.log*
*.pid
*.pid.*
*.report
*.lcov
lib-cov
doc_build/
node_modules/
.npm
.lock-wscript
.yarn-integrity
.node_repl_history
.nyc_output
*.tsbuildinfo
.eslintcache
.sonarlint
coverage/
release/
output/
output_resource/
.vscode/**/*
!.vscode/settings.json
!.vscode/extensions.json
.idea/
**/*/api/typings/auto-generated
**/*/adapters/**/index.ts
**/*/adapters/**/index.js

View File

@ -1,11 +0,0 @@
# playwright-playground
Native playwright test
```shell
# headless mode
npx playwright test ./e2e/todo-app-native.spec.ts
# UI mode
npx playwright test ./e2e/todo-app-native.spec.ts --ui
```

View File

@ -1,14 +0,0 @@
import { test } from './fixture';
test.beforeEach(async ({ page }) => {
await page.goto('https://todomvc.com/examples/react/dist/');
});
test('ai todo', async ({ ai }) => {
await ai('在任务框 input 输入 今天学习 JS按回车键');
await ai('在任务框 input 输入 明天学习 Rust按回车键');
await ai('在任务框 input 输入后天学习 AI按回车键');
await ai('将鼠标移动到任务列表中的第二项,点击第二项任务右边的删除按钮');
await ai('点击第二条任务左边的勾选按钮');
await ai('点击任务列表下面的 completed 状态按钮');
});

View File

@ -1,34 +0,0 @@
import { test } from './fixture';
test.beforeEach(async ({ page }) => {
page.setViewportSize({ width: 400, height: 905 });
await page.goto('https://heyteavivocity.meuu.online/home');
await page.waitForLoadState('networkidle');
});
test('ai order', async ({ page, ai }) => {
await ai('点击左上角语言切换按钮(英文、中文),在弹出的下拉列表中点击中文');
await ai('向下滚动一屏');
await ai('直接点击多肉葡萄的规格按钮');
await ai('点击不使用吸管、点击冰沙推荐、点击正常冰推荐');
await ai('向下滚动一屏');
await ai('点击标准甜、点击绿妍(推荐)、点击标准口味');
await ai('滚动到最下面');
await ai('点击选好了按钮');
await ai('点击右上角商品图标按钮');
// 随便滚动一下
await ai('滚动到最下面');
// const content = await aiQuery(query('购物车商品详情', {
// productName: "商品名称,在价格上面",
// productPrice: "商品价格",
// productDescription: "商品描述(饮品的各种参数,吸管、冰沙等),在价格下面",
// }));
// console.log('商品订单详情:', {
// productName: content.productName,
// productPrice: content.productPrice,
// productDescription: content.productDescription,
// });
});

View File

@ -1,24 +0,0 @@
import { expect } from '@playwright/test';
import { test } from './fixture';
test.beforeEach(async ({ page }) => {
page.setViewportSize({ width: 400, height: 905 });
await page.goto('https://www.ebay.com');
await page.waitForLoadState('networkidle');
});
test('search headphone on ebay', async ({ ai, aiQuery, aiAssert }) => {
// 👀 perform a search
await ai('type "Headphones" in search box, hit Enter');
// 👀 find the items
const items = await aiQuery(
'{itemTitle: string, price: Number}[], find item in list and corresponding price',
);
console.log('headphones in stock', items);
expect(items?.length).toBeGreaterThanOrEqual(1);
await aiAssert('There is a big input box in the page');
});

View File

@ -1,5 +0,0 @@
import type { PlayWrightAiFixtureType } from '@midscene/web';
import { PlaywrightAiFixture } from '@midscene/web';
import { test as base } from '@playwright/test';
export const test = base.extend<PlayWrightAiFixtureType>(PlaywrightAiFixture());

View File

@ -1,98 +0,0 @@
// import { test, expect, type Page } from '@playwright/test';
// import Insight, { TextElement, query } from 'midscene';
// import { retrieveElements, retrieveOneElement } from 'midscene/query';
// test.beforeEach(async ({ page }) => {
// await page.goto('https://todomvc.com/examples/react/dist/');
// });
// const TODO_ITEMS = ['buy some cheese', 'feed the cat', 'book a doctors appointment'];
// interface InputBoxSection {
// element: TextElement;
// toggleAllBtn: TextElement;
// placeholder: string;
// inputValue: string;
// }
// interface TodoItem {
// name: string;
// finished: boolean;
// }
// interface ControlLayerSection {
// numbersLeft: number;
// tipElement: TextElement;
// controlElements: TextElement[];
// }
// // A comprehensive parser for page content
// const parsePage = async (page: Page) => {
// const insight = await Insight.fromPlaywrightPage(page);
// const todoListPage = await insight.segment({
// 'input-box': query<InputBoxSection>('an input box to type item and a "toggle-all" button', {
// element: retrieveOneElement('input box'),
// toggleAllBtn: retrieveOneElement('toggle all button, if exists'),
// placeholder: 'placeholder string in the input box, string, if exists',
// inputValue: 'the value in the input box, string, if exists',
// }),
// 'todo-list': query<{ todoItems: TodoItem[] }>('a list with todo-data (if exists)', {
// todoItems: '{name: string, finished: boolean}[]',
// }),
// 'control-layer': query<ControlLayerSection>('status and control layer of todo (if exists)', {
// numbersLeft: 'number',
// tipElement: retrieveOneElement(
// 'the element indicates the number of remaining items, like `xx items left`',
// ),
// controlElements: retrieveElements('control elements, used to filter items'),
// }),
// });
// return todoListPage;
// };
// test.describe('New Todo', () => {
// test('should allow me to add todo items', async ({ page }) => {
// // add a todo item
// const todoPage = await parsePage(page);
// const inputBox = todoPage['input-box'];
// expect(inputBox).toBeTruthy();
// await page.mouse.click(...inputBox!.element.center);
// await page.keyboard.type(TODO_ITEMS[0], { delay: 100 });
// await page.keyboard.press('Enter');
// // update page parsing result, and check the interface
// const todoPage2 = await parsePage(page);
// expect(todoPage2['input-box'].inputValue).toBeFalsy();
// expect(todoPage2['input-box'].placeholder).toBeTruthy();
// expect(todoPage2['todo-list'].todoItems.length).toBe(1);
// expect(todoPage2['todo-list'].todoItems[0].name).toBe(TODO_ITEMS[0]);
// // add another item
// await page.mouse.click(...todoPage2['input-box'].element.center);
// await page.keyboard.type(TODO_ITEMS[1], { delay: 100 });
// await page.keyboard.press('Enter');
// // update page parsing result
// const todoPage3 = await parsePage(page);
// const items = todoPage3['todo-list'].todoItems;
// expect(items.length).toBe(2);
// expect(items[1].name).toEqual(TODO_ITEMS[1]);
// expect(items.some((item) => item.finished)).toBeFalsy();
// expect(todoPage3['control-layer'].numbersLeft).toBe(2);
// // will mark all as completed
// const toggleBtn = todoPage3['input-box'].toggleAllBtn;
// expect(toggleBtn).toBeTruthy();
// expect(todoPage3['todo-list'].todoItems.filter((item) => item.finished).length).toBe(0);
// await page.mouse.click(...toggleBtn!.center, { delay: 500 });
// await page.waitForTimeout(3000);
// const todoPage4 = await parsePage(page);
// const allItems = todoPage4['todo-list'].todoItems;
// expect(allItems.length).toBe(2);
// expect(allItems.filter((item) => item.finished).length).toBe(allItems.length);
// });
// });

View File

@ -1,21 +0,0 @@
import path from 'node:path';
import { defineConfig, moduleTools } from '@modern-js/module-tools';
import { testingPlugin } from '@modern-js/plugin-testing';
export default defineConfig({
plugins: [moduleTools(), testingPlugin()],
buildPreset: 'npm-library-es2019',
buildConfig: {
alias: {
'@playwright/test': path.resolve(
__dirname,
'node_modules/@playwright/test',
),
},
},
testing: {
jest: {
testEnvironment: 'node',
},
},
});

View File

@ -1,33 +0,0 @@
{
"name": "midscene-playwright-demo",
"private": true,
"version": "0.4.0",
"types": "./dist/types/index.d.ts",
"jsnext:source": "./src/index.ts",
"main": "./dist/lib/index.js",
"module": "./dist/es/index.js",
"scripts": {
"dev": "modern dev",
"build": "modern build",
"build:watch": "modern build -w",
"new": "modern new",
"upgrade": "modern upgrade",
"test": "modern test",
"e2e": "playwright test --config=playwright.config.ts",
"e2e:ui": "playwright test --config=playwright.config.ts --ui"
},
"devDependencies": {
"@modern-js/module-tools": "2.58.2",
"@modern-js/plugin-testing": "2.56.1",
"@playwright/test": "1.44.1",
"@types/jest": "~29.2.4",
"@types/node": "^18.0.0",
"eslint-plugin-prettier": "~4.2.1",
"rimraf": "~3.0.2",
"@midscene/web": "workspace:*",
"typescript": "~5.0.4"
},
"publishConfig": {
"access": "public"
}
}

View File

@ -1,78 +0,0 @@
import { defineConfig, devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
timeout: 90 * 1000,
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: Boolean(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. See https://playwright.dev/docs/test-reporters */
reporter: [['list'], ['@midscene/web/playwright-report']],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
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. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: '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,
// },
});

View File

@ -1,2 +0,0 @@
/// <reference types='@edenx/plugin-testing/types' />
/// <reference types='@edenx/module-tools/types' />

View File

@ -1,3 +0,0 @@
export default function (): string {
return 'hello world';
}

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"emitDeclarationOnly": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "preserve",
"lib": ["DOM", "ESNext"],
"moduleResolution": "node",
"paths": {
"@/*": ["./src/*"]
},
"target": "ES2017",
"resolveJsonModule": true,
"rootDir": "./",
"skipLibCheck": true,
"strict": true
},
"exclude": ["node_modules"],
"include": ["src", "e2e", "./playwright.config.ts", "./modern.config.ts"]
}

View File

@ -1,7 +1,7 @@
import type { KeyInput } from 'puppeteer';
import type { AppiumPage } from '../appium';
import type { PlaywrightPage } from '../playwright';
import type { PuppeteerPage } from '../puppeteer';
import type { PlaywrightWebPage } from '../playwright';
import type { PuppeteerWebPage } from '../puppeteer';
export type WebPage = PlaywrightPage | PuppeteerPage | AppiumPage;
export type WebPage = PlaywrightWebPage | PuppeteerWebPage | AppiumPage;
export type WebKeyInput = KeyInput;

View File

@ -1,6 +1,6 @@
import { randomUUID } from 'node:crypto';
import { PageAgent } from '@/common/agent';
import { PlaywrightPage } from '@/playwright';
import { PlaywrightWebPage } from '@/playwright';
import type { AgentWaitForOpt } from '@midscene/core/.';
import { type TestInfo, type TestType, test } from '@playwright/test';
import type { Page as OriginPlaywrightPage } from 'playwright';
@ -41,7 +41,7 @@ export const PlaywrightAiFixture = () => {
const { testId } = testInfo;
const { taskFile, taskTitle } = groupAndCaseForTest(testInfo);
pageAgentMap[idForPage] = new PageAgent(new PlaywrightPage(page), {
pageAgentMap[idForPage] = new PageAgent(new PlaywrightWebPage(page), {
testId: `playwright-${testId}-${idForPage}`,
cacheId: taskFile,
groupName: taskTitle,

View File

@ -1,4 +1,4 @@
export type { PlayWrightAiFixtureType } from './ai-fixture';
export { PlaywrightAiFixture } from './ai-fixture';
export { PageAgent as PlaywrightAgent } from '@/common/agent';
export { Page as PlaywrightPage } from './page';
export { WebPage as PlaywrightWebPage } from './page';

View File

@ -1,7 +1,7 @@
import type { Page as PlaywrightPageType } from 'playwright';
import { Page as BasePage } from '../puppeteer/base-page';
export class Page extends BasePage<'playwright', PlaywrightPageType> {
export class WebPage extends BasePage<'playwright', PlaywrightPageType> {
constructor(page: PlaywrightPageType) {
super(page, 'playwright');
}

View File

@ -1,2 +1,11 @@
export { PageAgent as PuppeteerAgent } from '@/common/agent';
export { Page as PuppeteerPage } from './page';
import { PageAgent, type PageAgentOpt } from '@/common/agent';
import type { Page as PuppeteerPage } from 'puppeteer';
import { WebPage as PuppeteerWebPage } from './page';
export { WebPage as PuppeteerWebPage } from './page';
export class PuppeteerAgent extends PageAgent {
constructor(page: PuppeteerPage, opts?: PageAgentOpt) {
const webPage = new PuppeteerWebPage(page);
super(webPage, opts);
}
}

View File

@ -1,7 +1,7 @@
import type { Page as PuppeteerPageType } from 'puppeteer';
import { Page as BasePage } from './base-page';
export class Page extends BasePage<'puppeteer', PuppeteerPageType> {
export class WebPage extends BasePage<'puppeteer', PuppeteerPageType> {
constructor(page: PuppeteerPageType) {
super(page, 'puppeteer');
}

View File

@ -61,7 +61,7 @@ describe(
'find all inputs in the page, return the field name in string[]',
);
console.log('widgets', widgets);
await reset();
});
},
{

View File

@ -1,5 +1,5 @@
import assert from 'node:assert';
import { PuppeteerPage } from '@/puppeteer';
import { PuppeteerWebPage } from '@/puppeteer';
import puppeteer, { type Viewport } from 'puppeteer';
export async function launchPage(
@ -13,7 +13,7 @@ export async function launchPage(
headless: typeof opt?.headless === 'boolean' ? opt.headless : true,
});
const originPage = (await browser.pages())[0];
const page = new PuppeteerPage(originPage);
const page = new PuppeteerWebPage(originPage);
const viewportConfig = {
width: opt?.viewport?.width || 1920,
height: opt?.viewport?.height || 1080,

2359
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,5 @@ packages:
- packages/cli
- packages/shared
- packages/midscene
- packages/playwright-demo
- packages/visualizer
- packages/web-integration