Files
weiguang-jewelry-ledger/新账系统/e2e/writes/operations.mjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
3.2 KiB
JavaScript
Raw Normal View History

import { action, postFrom, section } from './operations-helpers.mjs';
import { inventoryWrites } from './operations-inventory.mjs';
import { recoveryWrites } from './operations-recoveries.mjs';
async function peopleWrites(ctx, owner, staff) {
const url = '/api/private-operations/people';
await section(owner, ctx, 'private-operations');
await action(owner, 'private-people-open').click();
const ownerDialog = owner.locator('#private-people-dialog[open]');
await ctx.step('私域店主代员工登记总人数', async () => {
const form = ownerDialog.locator('form');
await form.locator('[name=member]').selectOption('assistant');
await form.locator('[name=total_count]').fill('10');
await postFrom(owner, url, () => form.locator('[type=submit]').click());
await ownerDialog.waitFor({ state: 'hidden' });
});
await section(staff, ctx, 'people-entry');
const staffDialog = staff.locator('#private-people-dialog[open]');
await action(staff, 'private-people-open').click();
await staff.waitForFunction(
() => document.querySelector('#private-people-dialog [name=total_count]')?.value === '10',
);
await owner.getByRole('button', { name: '修改娜娜 ' + ctx.day + '人数' }).click();
await ctx.step('私域店主更正同一日人数为零', async () => {
await ownerDialog.locator('[name=total_count]').fill('0');
await postFrom(owner, url, () => ownerDialog.locator('[type=submit]').click());
await ownerDialog.waitFor({ state: 'hidden' });
});
await ctx.step('私域店员持旧版本修改人数并收到冲突', async () => {
await staffDialog.locator('[name=total_count]').fill('8');
await postFrom(staff, url, () => staffDialog.locator('[type=submit]').click(), 409);
await staffDialog.getByRole('button', { name: '重新读取后核对' }).click();
await staff.waitForFunction(
() => document.querySelector('#private-people-dialog [name=total_count]')?.value === '0',
);
});
await ctx.step('私域店员核对最新人数后保存', async () => {
await staffDialog.locator('[name=total_count]').fill('15');
await postFrom(staff, url, () => staffDialog.locator('[type=submit]').click());
await staffDialog.waitFor({ state: 'hidden' });
await staff.locator('#people-entry-history').getByText('15', { exact: true }).first().waitFor();
});
}
export default async function operations(ctx) {
const owner = await ctx.pageFor('owner');
const staff = await ctx.pageFor('assistant');
await inventoryWrites(ctx, owner, staff);
await recoveryWrites(ctx, owner, staff);
await peopleWrites(ctx, owner, staff);
const staff2 = await ctx.pageFor('assistant2');
await section(staff2, ctx, 'people-entry');
await action(staff2, 'private-people-open').click();
const dialog = staff2.locator('#private-people-dialog[open]');
await ctx.step('私域第二名店员首次登记并核对历史', async () => {
await dialog.locator('[name=total_count]').fill('6');
await postFrom(staff2, '/api/private-operations/people', () => dialog.locator('[type=submit]').click());
await dialog.waitFor({ state: 'hidden' });
await staff2.locator('#people-entry-history').getByText('6', { exact: true }).first().waitFor();
});
}