diff --git a/tests/fixtures/userconfig.js b/tests/common/userconfig.ts similarity index 100% rename from tests/fixtures/userconfig.js rename to tests/common/userconfig.ts diff --git a/tests/touch/boss_cashier.spec.ts b/tests/touch/boss_cashier.spec.ts index ae1998d..727fc2e 100644 --- a/tests/touch/boss_cashier.spec.ts +++ b/tests/touch/boss_cashier.spec.ts @@ -1,6 +1,6 @@ // @ts-check import { test, expect } from '@/fixtures/boss_common.js'; //使用公共套件 -import { Feature, Employees, ProjectName, CardType, Coupons } from '@/fixtures/userconfig.js'; +import { Feature, Employees, ProjectName, CardType, Coupons } from '@/common/userconfig'; import { decodeQR, KeepOnlyNumbers } from '@/utils/utils.js'; import { faker } from '@faker-js/faker/locale/zh_CN'; import path from 'path'; diff --git a/tests/touch/boss_customer.spec.ts b/tests/touch/boss_customer.spec.ts index 1b1878c..f063d9a 100644 --- a/tests/touch/boss_customer.spec.ts +++ b/tests/touch/boss_customer.spec.ts @@ -3,7 +3,7 @@ import { test, expect } from '@/fixtures/boss_common.js'; import { faker } from '@faker-js/faker/locale/zh_CN'; import { Customer } from '@/utils/customer'; import { waitSpecifyApiLoad, convertAmountText, waitStable } from '@/utils/utils.js'; -import { Employees, ProjectName } from '@/fixtures/userconfig.js'; +import { Employees, ProjectName } from '@/common/userconfig'; import path from 'path'; import fs from 'fs'; import { HomeNavigation } from '@/pages/homeNavigationPage.js'; @@ -11,48 +11,18 @@ import { CustomerPage } from '@/pages/customer/customerPage.js'; test.describe('顾客通用', () => { test.describe('快捷查询', () => { - const customer = new Customer(1, 1, { - archive: 'ABC' + faker.string.alpha(3), - employees: [ - { - name: '周慧', - level: '咨询师', - }, - ], - }); - /**@type {import('playwright').BrowserContext} */ - let browserContext; - /**@type {import('playwright').Page} */ - let page; - let homeNavigation; - let customerPage; - test.beforeAll(async ({ browser, baseURL }) => { - browserContext = await browser.newContext(); - page = await browserContext.newPage(); - if (!baseURL) throw new Error('baseURL is required'); - await page.goto(baseURL); - await page.waitForLoadState('networkidle'); - await page.reload(); - await page.getByRole('button', { name: /开\s单/ }).waitFor(); - homeNavigation = new HomeNavigation(page); - customerPage = new CustomerPage(page); - await homeNavigation.gotoModule('顾客'); - await customerPage.createCustomer(customer); - }); - - test.afterAll(async () => { - homeNavigation = new HomeNavigation(page); - customerPage = new CustomerPage(page); - await homeNavigation.gotoModule('顾客'); - await customerPage.setInvalidCustomer(customer); - await page.close(); - await browserContext.close(); - }); - - test('精准查询', async ({ page, homeNavigation, customerPage }) => { - /**@type{Set} 搜索历史 */ + test('精准查询', async ({ page, homeNavigation, createCustomCustomer, customerPage }) => { let historySet = new Set(); - + const customer = new Customer(1, 1, { + archive: 'ABC' + faker.string.alpha(3), + employees: [ + { + name: '周慧', + level: '咨询师', + }, + ], + }); + await createCustomCustomer(customer); // 去创建顾客 const username = customer.username; const phone = customer.phone; @@ -101,7 +71,18 @@ test.describe('顾客通用', () => { }); }); - test('顾客概要', async ({ page, homeNavigation, customerPage, tablePage }) => { + test('顾客概要', async ({ page, homeNavigation, createCustomCustomer, customerPage, tablePage }) => { + const customer = new Customer(1, 1, { + archive: 'ABC' + faker.string.alpha(3), + employees: [ + { + name: '周慧', + level: '咨询师', + }, + ], + }); + await createCustomCustomer(customer); + // 第一个顾客 const $firstCustomer = tablePage.fixedLeftTable.locator('tr td:nth-child(2)').locator('.name ').first(); await test.step('选择部门一,查看顾客详情', async () => { @@ -138,7 +119,18 @@ test.describe('顾客通用', () => { }); }); - test('顾客分配', async ({ page, homeNavigation, customerPage, tablePage }) => { + test('顾客分配', async ({ page, homeNavigation, createCustomCustomer, customerPage, tablePage }) => { + const customer = new Customer(1, 1, { + archive: 'ABC' + faker.string.alpha(3), + employees: [ + { + name: '周慧', + level: '咨询师', + }, + ], + }); + await createCustomCustomer(customer); + // 第一个顾客 const $firstCustomer = tablePage.fixedLeftTable.locator('tr td:nth-child(2)').locator('.name ').first(); await test.step('顾客分配', async () => { @@ -163,7 +155,18 @@ test.describe('顾客通用', () => { }); }); - test('顾客动态', async ({ page, homeNavigation, customerPage, tablePage }) => { + test('顾客动态', async ({ page, homeNavigation, createCustomCustomer, customerPage, tablePage }) => { + const customer = new Customer(1, 1, { + archive: 'ABC' + faker.string.alpha(3), + employees: [ + { + name: '周慧', + level: '咨询师', + }, + ], + }); + await createCustomCustomer(customer); + // 第一个顾客 const $firstCustomer = tablePage.fixedLeftTable.locator('tr td:nth-child(2)').locator('.name ').first(); await test.step('选择部门一,查看顾客详情', async () => { @@ -195,7 +198,18 @@ test.describe('顾客通用', () => { }); }); - test('顾客分析', async ({ page, homeNavigation, customerPage, tablePage }) => { + test('顾客分析', async ({ page, homeNavigation, createCustomCustomer, customerPage, tablePage }) => { + const customer = new Customer(1, 1, { + archive: 'ABC' + faker.string.alpha(3), + employees: [ + { + name: '周慧', + level: '咨询师', + }, + ], + }); + await createCustomCustomer(customer); + // 第一个顾客 const $firstCustomer = tablePage.fixedLeftTable.locator('tr td:nth-child(2)').locator('.name ').first(); await test.step('选择部门一,查看顾客详情', async () => { @@ -790,11 +804,11 @@ test.describe('顾客动态', () => { test.describe('顾客详情', () => { test('修改顾客资料(标签、档案、到店周期、备注)', async ({ - page, - homeNavigation, - customerPage, - createCustomer, - }) => { + page, + homeNavigation, + customerPage, + createCustomer, + }) => { const customer = createCustomer; const infoBox = page.locator('.info_box'); @@ -807,7 +821,7 @@ test.describe('顾客详情', () => { const noSignLocator = infoBox.getByText('暂未添加标签'); await expect(noSignLocator).toBeVisible(); await infoBox.locator('.sign i').click(); - await expect(page.getByRole('button', { name: '移除所有选中' })).toBeVisible(); + await expect(page.getByRole('button', { name: '移除所有选中' })).toBeVisible(); const signSelectLocator = page.getByRole('treeitem', { name: '顾客六期管理' }); await signSelectLocator.getByText('问题期').click(); await signSelectLocator.getByText('铺垫期').click(); @@ -2524,13 +2538,13 @@ test.describe('顾客分析', () => { }); test('查看项目余量分析', async ({ - page, - homeNavigation, - customerPage, - createCustomer, - customerAnalysisPage, - numberInput, - }) => { + page, + homeNavigation, + customerPage, + createCustomer, + customerAnalysisPage, + numberInput, + }) => { const customer = createCustomer; let billNo = ''; diff --git a/tests/touch/boss_goal.spec.ts b/tests/touch/boss_goal.spec.ts index f533541..63e1a60 100644 --- a/tests/touch/boss_goal.spec.ts +++ b/tests/touch/boss_goal.spec.ts @@ -1,7 +1,7 @@ // @ts-check import { expect, test } from '@/fixtures/boss_common.js'; import { staffData } from '@/common/staff'; -import { Employees } from '@/fixtures/userconfig.js'; +import { Employees } from '@/common/userconfig'; import { Customer } from '@/utils/customer'; import { KeepOnlyNumbers } from '@/utils/utils.js'; diff --git a/tests/touch/boss_inventory.spec.ts b/tests/touch/boss_inventory.spec.ts index 106a470..0f64444 100644 --- a/tests/touch/boss_inventory.spec.ts +++ b/tests/touch/boss_inventory.spec.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker/locale/zh_CN'; import { expect, test } from '@/fixtures/boss_common.js'; import { CleanPunctuation, getListIndexForTargetElement, KeepOnlyNumbers } from '@/utils/utils.js'; -import { ProjectName } from '@/fixtures/userconfig.js'; +import { ProjectName } from '@/common/userconfig'; test.describe('出入库管理', () => { test.describe('入库单', () => { @@ -2800,7 +2800,7 @@ test.describe('调货管理', () => { }; const remarkA = '调货管理' + faker.helpers.fromRegExp(/[a-d]{2}[0-9]{2}/); const remarkB = '调货管理' + faker.helpers.fromRegExp(/[a-d]{2}[0-9]{2}/); - let billA:string, billB:string; + let billA: string, billB: string; let quantity = 0; // 数量 let outQuantity = 0; // 调出数量 @@ -3529,7 +3529,7 @@ test.describe.serial('盘点', () => { let ProductMargin; // 获取单号的ID - let billId; + let billId: string; let billNo: string; await test.step('记录各自批次数量', async () => { diff --git a/tests/touch/boss_report.spec.ts b/tests/touch/boss_report.spec.ts index 8c66a56..619a34b 100644 --- a/tests/touch/boss_report.spec.ts +++ b/tests/touch/boss_report.spec.ts @@ -4,7 +4,7 @@ import { expect, test } from '@/fixtures/merchantFixture.js'; import { faker } from '@faker-js/faker/locale/zh_CN'; import { Customer } from '@/utils/customer'; import { KeepOnlyNumbers, waitSpecifyApiLoad } from '@/utils/utils.js'; -import { CardType, Employees, ProjectName } from '@/fixtures/userconfig.js'; +import { CardType, Employees, ProjectName } from '@/common/userconfig'; test.describe('业绩明细表', () => { test('数据校验', async ({ page, createCustomer, homeNavigation, reportPage, customerPage }) => { diff --git a/tests/touch/boss_wastebook.spec.ts b/tests/touch/boss_wastebook.spec.ts index f6999ee..4093249 100644 --- a/tests/touch/boss_wastebook.spec.ts +++ b/tests/touch/boss_wastebook.spec.ts @@ -5,7 +5,7 @@ import { Customer } from '@/utils/customer'; import { KeepOnlyNumbers } from '@/utils/utils.js'; import fs from 'fs'; import path from 'path'; -import { Employees, ProjectName } from '@/fixtures/userconfig.js'; +import { Employees, ProjectName } from '@/common/userconfig'; import { staffData } from '@/common/staff'; test.describe('营业记录', () => { diff --git a/tests/touch/staff_goal.spec.ts b/tests/touch/staff_goal.spec.ts index 45521ce..3d7c814 100644 --- a/tests/touch/staff_goal.spec.ts +++ b/tests/touch/staff_goal.spec.ts @@ -1,6 +1,6 @@ // @ts-check import { test, expect } from '@/fixtures/staff_common.js'; -import { Employees } from '@/fixtures/userconfig.js'; +import { Employees } from '@/common/userconfig'; test.describe('目标-目标设置', () => { test('门店设置一店', async ({ page, baseURL, numberInput }) => {