Added some small enchances
This commit is contained in:
@@ -171,7 +171,7 @@ The old manager account IDs are retained while the original addresses become `al
|
||||
|
||||
Head can add merchants from the directory and optionally assign a manager. Managers create merchants assigned to themselves. Company name, contact name and email are required; website, country, industry and volume can be supplied later. Compliance has no creation access. New leads begin at `NEW_LEAD` with three missing KYB checklist records and an attributed creation history. The API rejects caller-supplied stage, audit identity and public-submission fields.
|
||||
|
||||
Directory search matches company/legal name, contact name, email and website. `status`, ISO `country`, canonical `industry`, and `ownerId` combine with search. Head and Compliance may use `ownerId=unassigned` or a manager ID. Manager owner filters return 403. All records, totals and filter options use the same authorization scope. Results retain eight-record pages and clamp excessive page numbers to the last available page. Search, filters and pagination survive URL sharing, reload and browser navigation.
|
||||
Directory search matches company/legal name, contact name, email and website. `status`, ISO `country`, canonical `industry`, and `ownerId` combine with search. Head and Compliance may use `ownerId=unassigned` or a manager ID. Manager owner filters return 403. All records, totals and filter options use the same authorization scope. Results support 10, 20 or 30 records per page (`pageSize`, default 10) and clamp excessive page numbers to the last available page. Changing the page size returns to page one. Search, filters and pagination survive URL sharing, reload and browser navigation.
|
||||
|
||||
| Method | Endpoint | Purpose |
|
||||
| ------ | -------------------------------- | ---------------------------------------------------------------------- |
|
||||
|
||||
+5
-5
@@ -64,20 +64,20 @@ export class CrmController {
|
||||
});
|
||||
}
|
||||
@Get('merchants') async merchants(@Req() req: AuthRequest, @Query() query: unknown) {
|
||||
const { page: requestedPage } = merchantQuerySchema.parse(query);
|
||||
const { page: requestedPage, pageSize } = merchantQuerySchema.parse(query);
|
||||
const where = merchantWhere(req.user, query);
|
||||
return this.db.$transaction(
|
||||
async (tx) => {
|
||||
const total = await tx.merchant.count({ where });
|
||||
const page = Math.min(requestedPage, Math.max(1, Math.ceil(total / 8)));
|
||||
const page = Math.min(requestedPage, Math.max(1, Math.ceil(total / pageSize)));
|
||||
const items = await tx.merchant.findMany({
|
||||
where,
|
||||
select: merchantSelect,
|
||||
orderBy: [{ createdAt: 'desc' }, { id: 'asc' }],
|
||||
take: 8,
|
||||
skip: (page - 1) * 8,
|
||||
take: pageSize,
|
||||
skip: (page - 1) * pageSize,
|
||||
});
|
||||
return { items, total, page, pageSize: 8 };
|
||||
return { items, total, page, pageSize };
|
||||
},
|
||||
{ isolationLevel: 'RepeatableRead' },
|
||||
);
|
||||
|
||||
@@ -142,7 +142,7 @@ test('staff creation is atomic, minimally required, role-bound and strict', asyn
|
||||
test('search, combined filters, pagination and metadata apply ownership scope before counts', async () => {
|
||||
const prefix = `Directory-${randomUUID()}`;
|
||||
const ids = [];
|
||||
for (let index = 0; index < 10; index++)
|
||||
for (let index = 0; index < 31; index++)
|
||||
ids.push(
|
||||
await create('alex', {
|
||||
name: `${prefix} ${index}`,
|
||||
@@ -174,11 +174,20 @@ test('search, combined filters, pagination and metadata apply ownership scope be
|
||||
const query = `search=${prefix}&country=GB&industry=SOFTWARE&status=NEW_LEAD`;
|
||||
const page1 = (await request(`/merchants?${query}`, 'alex')).body;
|
||||
const page2 = (await request(`/merchants?${query}&page=2`, 'alex')).body;
|
||||
assert.equal(page1.total, 10);
|
||||
assert.equal(page1.items.length, 8);
|
||||
assert.equal(page2.items.length, 2);
|
||||
assert.equal(new Set([...page1.items, ...page2.items].map((m) => m.id)).size, 10);
|
||||
assert.equal((await request(`/merchants?${query}&page=10000`, 'alex')).body.page, 2);
|
||||
assert.equal(page1.total, 31);
|
||||
assert.equal(page1.items.length, 10);
|
||||
assert.equal(page2.items.length, 10);
|
||||
assert.equal(new Set([...page1.items, ...page2.items].map((m) => m.id)).size, 20);
|
||||
assert.equal((await request(`/merchants?${query}&page=10000`, 'alex')).body.page, 4);
|
||||
for (const pageSize of [10, 20, 30]) {
|
||||
const first = (await request(`/merchants?${query}&pageSize=${pageSize}`, 'alex')).body;
|
||||
const last = (await request(`/merchants?${query}&pageSize=${pageSize}&page=10000`, 'alex'))
|
||||
.body;
|
||||
assert.equal(first.pageSize, pageSize);
|
||||
assert.equal(first.items.length, pageSize);
|
||||
assert.equal(last.page, Math.ceil(31 / pageSize));
|
||||
assert.equal(last.items.length, 31 % pageSize);
|
||||
}
|
||||
assert.equal((await request(`/merchants?${query}&ownerId=user-manager2`, 'alex')).status, 403);
|
||||
assert.equal(
|
||||
(await request(`/merchants?search=${prefix}&ownerId=user-manager2`, 'head')).body.items[0].id,
|
||||
@@ -190,7 +199,17 @@ test('search, combined filters, pagination and metadata apply ownership scope be
|
||||
unassigned,
|
||||
);
|
||||
assert.equal((await request(`/merchants?search=${prefix}&country=JP`, 'alex')).body.total, 0);
|
||||
for (const invalid of ['country=ZZ', 'industry=INVALID', 'status=Live', 'page=1.5', 'page=-1'])
|
||||
for (const invalid of [
|
||||
'country=ZZ',
|
||||
'industry=INVALID',
|
||||
'status=Live',
|
||||
'page=1.5',
|
||||
'page=-1',
|
||||
'pageSize=8',
|
||||
'pageSize=0',
|
||||
'pageSize=15',
|
||||
'pageSize=1000',
|
||||
])
|
||||
assert.equal((await request(`/merchants?${invalid}`)).status, 400);
|
||||
const ownFilters = merchantFiltersSchema.parse(
|
||||
(await request('/merchants/filters', 'alex')).body,
|
||||
|
||||
@@ -172,12 +172,19 @@ function SalesDashboard({ data, user }: { data: Data; user: User }) {
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-9">
|
||||
{data.distribution.map((d) => (
|
||||
<Link
|
||||
className="min-h-11 rounded-md p-1"
|
||||
className="flex min-h-11 flex-col gap-2 rounded-md p-1"
|
||||
key={d.status}
|
||||
to={`/app/merchants?status=${d.status}`}
|
||||
>
|
||||
<span className="text-xs text-muted-foreground">{t(`statuses.${d.status}`)}</span>
|
||||
<span className="mt-2 block text-lg font-semibold tabular-nums">
|
||||
<span className="flex items-start gap-2 text-xs text-muted-foreground">
|
||||
<span
|
||||
className="mt-1 size-2 shrink-0 rounded-full"
|
||||
style={{ backgroundColor: stageColors[d.status] }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span>{t(`statuses.${d.status}`)}</span>
|
||||
</span>
|
||||
<span className="mt-auto block text-lg font-semibold tabular-nums">
|
||||
{f.number(d.count)}
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { ArrowUpRight, Check, LoaderCircle } from 'lucide-react';
|
||||
import {
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type PublicLeadInput,
|
||||
} from '@merchantflow/contracts';
|
||||
import { Input } from '@merchantflow/ui/components/input';
|
||||
import { NativeSelect } from '@merchantflow/ui/components/native-select';
|
||||
import { Select, SelectOption } from '@merchantflow/ui/components/select';
|
||||
import { FormField } from '@merchantflow/ui/components/form-field';
|
||||
import { Button } from '@merchantflow/ui/components/button';
|
||||
import { api, ApiError } from '../lib/api';
|
||||
@@ -202,37 +202,59 @@ export function LeadForm() {
|
||||
</FormField>
|
||||
))}
|
||||
<FormField id="lead-country" label={t('landing.country')} error={errorText('country')}>
|
||||
<NativeSelect
|
||||
{...form.register('country')}
|
||||
{...accessibility('country')}
|
||||
autoComplete="country"
|
||||
className="w-full"
|
||||
>
|
||||
<option value="" disabled>
|
||||
{t('landing.countryPlaceholder')}
|
||||
</option>
|
||||
{countries.map(({ code, name }) => (
|
||||
<option key={code} value={code}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<Controller
|
||||
name="country"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
name={field.name}
|
||||
disabled={mutation.isPending}
|
||||
ref={field.ref}
|
||||
value={field.value ?? ''}
|
||||
onValueChange={field.onChange}
|
||||
onBlur={field.onBlur}
|
||||
{...accessibility('country')}
|
||||
autoComplete="country"
|
||||
className="w-full"
|
||||
>
|
||||
<SelectOption value="" disabled>
|
||||
{t('landing.countryPlaceholder')}
|
||||
</SelectOption>
|
||||
{countries.map(({ code, name }) => (
|
||||
<SelectOption key={code} value={code}>
|
||||
{name}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
</FormField>
|
||||
<FormField id="lead-industry" label={t('landing.industry')} error={errorText('industry')}>
|
||||
<NativeSelect
|
||||
{...form.register('industry')}
|
||||
{...accessibility('industry')}
|
||||
className="w-full"
|
||||
>
|
||||
<option value="" disabled>
|
||||
{t('landing.industryPlaceholder')}
|
||||
</option>
|
||||
{industries.map((industry) => (
|
||||
<option key={industry} value={industry}>
|
||||
{t(`industry.${industry}`)}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<Controller
|
||||
name="industry"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
name={field.name}
|
||||
disabled={mutation.isPending}
|
||||
ref={field.ref}
|
||||
value={field.value ?? ''}
|
||||
onValueChange={field.onChange}
|
||||
onBlur={field.onBlur}
|
||||
{...accessibility('industry')}
|
||||
className="w-full"
|
||||
>
|
||||
<SelectOption value="" disabled>
|
||||
{t('landing.industryPlaceholder')}
|
||||
</SelectOption>
|
||||
{industries.map((industry) => (
|
||||
<SelectOption key={industry} value={industry}>
|
||||
{t(`industry.${industry}`)}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
</FormField>
|
||||
<div className="lead-volume">
|
||||
<FormField
|
||||
|
||||
@@ -74,6 +74,7 @@ export function ReminderInbox() {
|
||||
<TaskRow task={task} onNavigate={() => setOpen(false)} />
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mt-3"
|
||||
disabled={dismissal.isPending}
|
||||
onClick={() => dismissal.mutate(task)}
|
||||
>
|
||||
|
||||
@@ -140,7 +140,7 @@ export function ActionableTask({ task }: { task: Task }) {
|
||||
return (
|
||||
<div id={`task-${task.id}`} className="border-t first:border-0 scroll-mt-5">
|
||||
<TaskRow task={task} />
|
||||
<div className="flex flex-wrap items-center gap-2 px-5 pb-4">
|
||||
<div className="flex flex-wrap items-center gap-2 px-5 py-4">
|
||||
{task.capabilities.edit && (
|
||||
<Button variant="outline" onClick={() => setEditing(task)}>
|
||||
{t('workflow.editTask')}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId, useState, type ReactNode } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { z } from 'zod';
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
SheetDescription,
|
||||
} from '@merchantflow/ui/components/sheet';
|
||||
import { Input } from '@merchantflow/ui/components/input';
|
||||
import { NativeSelect } from '@merchantflow/ui/components/native-select';
|
||||
import { Select, SelectOption } from '@merchantflow/ui/components/select';
|
||||
import { FormField } from '@merchantflow/ui/components/form-field';
|
||||
import { api, ApiError, queryClient } from '../lib/api';
|
||||
import { Button } from './shared';
|
||||
@@ -107,13 +107,29 @@ export function Editor({
|
||||
error={errors[field.name]}
|
||||
>
|
||||
{field.options ? (
|
||||
<NativeSelect {...props}>
|
||||
{field.options.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<Controller
|
||||
name={field.name}
|
||||
control={form.control}
|
||||
render={({ field: control }) => (
|
||||
<Select
|
||||
id={fieldId}
|
||||
name={control.name}
|
||||
ref={control.ref}
|
||||
value={control.value ?? ''}
|
||||
onValueChange={control.onChange}
|
||||
onBlur={control.onBlur}
|
||||
disabled={pending || field.disabled}
|
||||
aria-invalid={!!errors[field.name]}
|
||||
aria-describedby={props['aria-describedby']}
|
||||
>
|
||||
{field.options!.map((option) => (
|
||||
<SelectOption key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
) : field.type === 'textarea' ? (
|
||||
<textarea
|
||||
{...props}
|
||||
|
||||
@@ -17,6 +17,18 @@ it('canonicalizes invalid/default query values while retaining search typing and
|
||||
).toBe('');
|
||||
expect(directoryParams(new URLSearchParams('page=1'), 'HEAD_OF_SALES').toString()).toBe('');
|
||||
});
|
||||
it('retains supported page sizes and drops unsupported values', () => {
|
||||
for (const size of ['10', '20', '30'])
|
||||
expect(
|
||||
directoryParams(new URLSearchParams(`pageSize=${size}&page=2`), 'HEAD_OF_SALES').get(
|
||||
'pageSize',
|
||||
),
|
||||
).toBe(size);
|
||||
for (const size of ['8', '15', '0', '1000', 'invalid'])
|
||||
expect(
|
||||
directoryParams(new URLSearchParams(`pageSize=${size}`), 'HEAD_OF_SALES').has('pageSize'),
|
||||
).toBe(false);
|
||||
});
|
||||
it('removes owner controls from manager URLs without dropping the rest of their search', () => {
|
||||
const result = directoryParams(
|
||||
new URLSearchParams('search=hello&ownerId=user-manager2&country=GB&page=3'),
|
||||
|
||||
@@ -11,6 +11,7 @@ export function directoryParams(input: URLSearchParams, role: Role) {
|
||||
'industry',
|
||||
'ownerId',
|
||||
'page',
|
||||
'pageSize',
|
||||
'createdFrom',
|
||||
'createdTo',
|
||||
'cohort',
|
||||
|
||||
@@ -27,6 +27,7 @@ export const en = {
|
||||
next: 'Next',
|
||||
page: 'Page {{page}} of {{total}}',
|
||||
showing: '{{from}}–{{to}} of {{total}} merchants',
|
||||
perPage: 'Show per page',
|
||||
all: 'All',
|
||||
language: 'Language',
|
||||
logout: 'Sign out',
|
||||
@@ -262,6 +263,7 @@ export const ru = {
|
||||
next: 'Далее',
|
||||
page: 'Страница {{page}} из {{total}}',
|
||||
showing: '{{from}}–{{to}} из {{total}} мерчантов',
|
||||
perPage: 'На странице',
|
||||
all: 'Все',
|
||||
language: 'Язык',
|
||||
logout: 'Выйти',
|
||||
|
||||
+60
-44
@@ -38,7 +38,7 @@ import {
|
||||
type Merchant,
|
||||
} from '@merchantflow/contracts';
|
||||
import { Input } from '@merchantflow/ui/components/input';
|
||||
import { NativeSelect } from '@merchantflow/ui/components/native-select';
|
||||
import { Select, SelectOption } from '@merchantflow/ui/components/select';
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -245,75 +245,77 @@ export function Merchants() {
|
||||
aria-label={t('workspace.filters')}
|
||||
className="grid gap-2 sm:grid-cols-2 xl:grid-cols-4"
|
||||
>
|
||||
<NativeSelect
|
||||
<Select
|
||||
aria-label={t('merchants.filter')}
|
||||
value={status}
|
||||
onChange={(e) => update('status', e.target.value)}
|
||||
onValueChange={(value) => update('status', value)}
|
||||
className="w-full bg-white sm:min-w-[190px]"
|
||||
>
|
||||
<option value="">{t('merchants.allStages')}</option>
|
||||
<SelectOption value="">{t('merchants.allStages')}</SelectOption>
|
||||
{statuses.map((s) => (
|
||||
<option key={s} value={s}>
|
||||
<SelectOption key={s} value={s}>
|
||||
{t(`statuses.${s}`)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<NativeSelect
|
||||
</Select>
|
||||
<Select
|
||||
className="w-full bg-white"
|
||||
aria-label={t('workspace.allCountries')}
|
||||
value={normalized.get('country') ?? ''}
|
||||
onChange={(event) => update('country', event.target.value)}
|
||||
onValueChange={(value) => update('country', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allCountries')}</option>
|
||||
<SelectOption value="">{t('workspace.allCountries')}</SelectOption>
|
||||
{[
|
||||
...new Set([
|
||||
...(filters.data?.countries ?? []),
|
||||
...(normalized.get('country') ? [normalized.get('country')!] : []),
|
||||
]),
|
||||
].map((country) => (
|
||||
<option key={country} value={country}>
|
||||
<SelectOption key={country} value={country}>
|
||||
{f.country(country)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<NativeSelect
|
||||
</Select>
|
||||
<Select
|
||||
className="w-full bg-white"
|
||||
aria-label={t('workspace.allIndustries')}
|
||||
value={normalized.get('industry') ?? ''}
|
||||
onChange={(event) => update('industry', event.target.value)}
|
||||
onValueChange={(value) => update('industry', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allIndustries')}</option>
|
||||
<SelectOption value="">{t('workspace.allIndustries')}</SelectOption>
|
||||
{[
|
||||
...new Set([
|
||||
...(filters.data?.industries ?? []),
|
||||
...(normalized.get('industry') ? [normalized.get('industry')!] : []),
|
||||
]),
|
||||
].map((industry) => (
|
||||
<option key={industry} value={industry}>
|
||||
<SelectOption key={industry} value={industry}>
|
||||
{t(`industry.${industry}`)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
{filters.data?.canFilterOwner && (
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="w-full bg-white"
|
||||
aria-label={t('workspace.allOwners')}
|
||||
value={normalized.get('ownerId') ?? ''}
|
||||
onChange={(event) => update('ownerId', event.target.value)}
|
||||
onValueChange={(value) => update('ownerId', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allOwners')}</option>
|
||||
<option value="unassigned">{t('workflow.unassigned')}</option>
|
||||
<SelectOption value="">{t('workspace.allOwners')}</SelectOption>
|
||||
<SelectOption value="unassigned">{t('workflow.unassigned')}</SelectOption>
|
||||
{filters.data.owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
<SelectOption key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
{normalized.get('ownerId') &&
|
||||
normalized.get('ownerId') !== 'unassigned' &&
|
||||
!filters.data.owners.some((owner) => owner.id === normalized.get('ownerId')) && (
|
||||
<option value={normalized.get('ownerId')!}>{t('workspace.notProvided')}</option>
|
||||
<SelectOption value={normalized.get('ownerId')!}>
|
||||
{t('workspace.notProvided')}
|
||||
</SelectOption>
|
||||
)}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -363,6 +365,20 @@ export function Merchants() {
|
||||
total: f.number(data.total),
|
||||
})}
|
||||
</p>
|
||||
<label className="flex items-center gap-2 text-xs text-muted-foreground sm:ml-auto">
|
||||
<span>{t('common.perPage')}</span>
|
||||
<Select
|
||||
className="w-20 bg-white"
|
||||
value={normalized.get('pageSize') ?? '10'}
|
||||
onValueChange={(value) => update('pageSize', value)}
|
||||
>
|
||||
{['10', '20', '30'].map((value) => (
|
||||
<SelectOption key={value} value={value}>
|
||||
{f.number(Number(value))}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
</label>
|
||||
<nav
|
||||
aria-label={t('common.page', {
|
||||
page: f.number(page),
|
||||
@@ -677,19 +693,19 @@ export function Pipeline() {
|
||||
<QueryBoundary query={query}>
|
||||
{(merchants) => (
|
||||
<>
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="mb-5 w-full md:hidden"
|
||||
aria-label={t('pipeline.stageSelect')}
|
||||
value={stage}
|
||||
onChange={(event) => setParams({ stage: event.target.value })}
|
||||
onValueChange={(value) => setParams({ stage: value })}
|
||||
>
|
||||
{statuses.map((value) => (
|
||||
<option key={value} value={value}>
|
||||
<SelectOption key={value} value={value}>
|
||||
{t(`statuses.${value}`)} (
|
||||
{f.number(merchants.filter((merchant) => merchant.status === value).length)})
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
<div
|
||||
className="flex gap-4 overflow-x-auto pb-4"
|
||||
aria-label={t('pipeline.title')}
|
||||
@@ -813,39 +829,39 @@ export function ReviewQueue() {
|
||||
</label>
|
||||
<label className="space-y-2 text-xs text-muted-foreground">
|
||||
<span>{t('common.owner')}</span>
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="w-full"
|
||||
value={filters.get('ownerId') ?? ''}
|
||||
onChange={(event) => update('ownerId', event.target.value)}
|
||||
onValueChange={(value) => update('ownerId', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allOwners')}</option>
|
||||
<option value="unassigned">{t('workflow.unassigned')}</option>
|
||||
<SelectOption value="">{t('workspace.allOwners')}</SelectOption>
|
||||
<SelectOption value="unassigned">{t('workflow.unassigned')}</SelectOption>
|
||||
{query.data?.owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
<SelectOption key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
</label>
|
||||
<label className="space-y-2 text-xs text-muted-foreground">
|
||||
<span>{t(decided ? 'workflow.decision' : 'onboarding.waitingTime')}</span>
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="w-full"
|
||||
value={filters.get(decided ? 'decision' : 'waiting') ?? 'ALL'}
|
||||
onChange={(event) => update(decided ? 'decision' : 'waiting', event.target.value)}
|
||||
onValueChange={(value) => update(decided ? 'decision' : 'waiting', value)}
|
||||
>
|
||||
{(decided ? ['ALL', 'APPROVED', 'CORRECTIONS', 'REJECTED'] : ['ALL', '24', '72']).map(
|
||||
(value) => (
|
||||
<option key={value} value={value}>
|
||||
<SelectOption key={value} value={value}>
|
||||
{t(
|
||||
decided && value !== 'ALL'
|
||||
? `workflow.${value}`
|
||||
: `onboarding.waiting.${value}`,
|
||||
)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
),
|
||||
)}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
</label>
|
||||
</section>
|
||||
<QueryBoundary query={query}>
|
||||
|
||||
@@ -294,7 +294,7 @@
|
||||
min-width: 0;
|
||||
}
|
||||
.lead-fields input,
|
||||
.lead-fields select {
|
||||
.lead-fields [data-slot='select-trigger'] {
|
||||
background: #fcfdf9;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,10 @@ export const merchantQuerySchema = z.object({
|
||||
industry: z.enum(['ECOMMERCE', 'SOFTWARE', 'TRAVEL', 'SERVICES', 'OTHER']).optional(),
|
||||
ownerId: z.string().min(1).max(200).optional(),
|
||||
page: z.coerce.number().int().min(1).max(10000).default(1),
|
||||
pageSize: z.coerce
|
||||
.number()
|
||||
.pipe(z.union([z.literal(10), z.literal(20), z.literal(30)]))
|
||||
.default(10),
|
||||
});
|
||||
export const taskFilters = ['TODAY', 'UPCOMING', 'OVERDUE', 'DONE', 'ALL', 'OPEN'] as const;
|
||||
export const taskQuerySchema = z.object({
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { cn } from '@merchantflow/ui/lib/utils';
|
||||
import { ChevronDownIcon } from 'lucide-react';
|
||||
|
||||
type NativeSelectProps = Omit<React.ComponentProps<'select'>, 'size'> & {
|
||||
size?: 'sm' | 'default';
|
||||
};
|
||||
|
||||
function NativeSelect({ className, size = 'default', ...props }: NativeSelectProps) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'group/native-select relative w-fit has-[select:disabled]:opacity-50',
|
||||
className,
|
||||
)}
|
||||
data-slot="native-select-wrapper"
|
||||
data-size={size}
|
||||
>
|
||||
<select
|
||||
data-slot="native-select"
|
||||
data-size={size}
|
||||
className="h-11 w-full min-w-0 appearance-none rounded-lg border border-input bg-transparent py-1 pr-8 pl-2.5 text-base transition-colors outline-none select-none selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=sm]:h-11 data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-[size=sm]:py-0.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40"
|
||||
{...props}
|
||||
/>
|
||||
<ChevronDownIcon
|
||||
className="pointer-events-none absolute top-1/2 right-2.5 size-4 -translate-y-1/2 text-muted-foreground select-none"
|
||||
aria-hidden="true"
|
||||
data-slot="native-select-icon"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function NativeSelectOption({ className, ...props }: React.ComponentProps<'option'>) {
|
||||
return (
|
||||
<option
|
||||
data-slot="native-select-option"
|
||||
className={cn('bg-[Canvas] text-[CanvasText]', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function NativeSelectOptGroup({ className, ...props }: React.ComponentProps<'optgroup'>) {
|
||||
return (
|
||||
<optgroup
|
||||
data-slot="native-select-optgroup"
|
||||
className={cn('bg-[Canvas] text-[CanvasText]', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { NativeSelect, NativeSelectOptGroup, NativeSelectOption };
|
||||
@@ -0,0 +1,91 @@
|
||||
import * as React from 'react';
|
||||
import { Select as SelectPrimitive } from '@base-ui/react/select';
|
||||
import { CheckIcon, ChevronDownIcon } from 'lucide-react';
|
||||
import { cn } from '@merchantflow/ui/lib/utils';
|
||||
|
||||
type SelectProps = Omit<React.ComponentProps<'button'>, 'value' | 'defaultValue' | 'onChange'> & {
|
||||
value: string;
|
||||
onValueChange: (value: string) => void;
|
||||
autoComplete?: string;
|
||||
};
|
||||
|
||||
function Select({
|
||||
children,
|
||||
className,
|
||||
value,
|
||||
onValueChange,
|
||||
name,
|
||||
autoComplete,
|
||||
disabled,
|
||||
id,
|
||||
...props
|
||||
}: SelectProps) {
|
||||
const items = React.Children.toArray(children)
|
||||
.filter(React.isValidElement<{ value: string; children: React.ReactNode }>)
|
||||
.map((child) => ({ value: child.props.value, label: child.props.children }));
|
||||
return (
|
||||
<SelectPrimitive.Root
|
||||
items={items}
|
||||
value={value}
|
||||
onValueChange={(next) => {
|
||||
if (next !== null) onValueChange(next);
|
||||
}}
|
||||
name={name}
|
||||
autoComplete={autoComplete}
|
||||
disabled={disabled}
|
||||
id={id}
|
||||
>
|
||||
<SelectPrimitive.Trigger
|
||||
{...props}
|
||||
data-slot="select-trigger"
|
||||
className={cn(
|
||||
'flex h-11 w-full min-w-0 items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-3 py-1 text-left text-base text-foreground outline-none transition-colors focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<SelectPrimitive.Value className="min-w-0 truncate" />
|
||||
<SelectPrimitive.Icon className="shrink-0 text-muted-foreground">
|
||||
<ChevronDownIcon className="size-4" aria-hidden="true" />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Positioner
|
||||
sideOffset={6}
|
||||
align="start"
|
||||
alignItemWithTrigger={false}
|
||||
className="z-[60]"
|
||||
>
|
||||
<SelectPrimitive.Popup className="max-h-[min(20rem,var(--available-height))] w-[var(--anchor-width)] min-w-32 max-w-[var(--available-width)] overflow-y-auto overscroll-contain rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg outline-none">
|
||||
<SelectPrimitive.List>{children}</SelectPrimitive.List>
|
||||
</SelectPrimitive.Popup>
|
||||
</SelectPrimitive.Positioner>
|
||||
</SelectPrimitive.Portal>
|
||||
</SelectPrimitive.Root>
|
||||
);
|
||||
}
|
||||
|
||||
function SelectOption({
|
||||
value,
|
||||
children,
|
||||
disabled,
|
||||
}: {
|
||||
value: string;
|
||||
children: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<SelectPrimitive.Item
|
||||
value={value}
|
||||
disabled={disabled}
|
||||
data-value={value}
|
||||
className="relative flex min-h-11 cursor-pointer items-center rounded-md py-2 pr-8 pl-3 text-sm outline-none select-none data-highlighted:bg-accent data-selected:font-medium data-disabled:pointer-events-none data-disabled:opacity-50"
|
||||
>
|
||||
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||
<SelectPrimitive.ItemIndicator className="absolute right-2.5">
|
||||
<CheckIcon className="size-4" aria-hidden="true" />
|
||||
</SelectPrimitive.ItemIndicator>
|
||||
</SelectPrimitive.Item>
|
||||
);
|
||||
}
|
||||
|
||||
export { Select, SelectOption };
|
||||
@@ -0,0 +1,7 @@
|
||||
import { expect, type Locator } from '@playwright/test';
|
||||
|
||||
export async function selectOption(trigger: Locator, value: string) {
|
||||
await trigger.click();
|
||||
await trigger.page().locator(`[role="option"][data-value="${value}"]`).click();
|
||||
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { selectOption } from './helpers/select';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { createDatabase } from '../packages/database/dist/index.js';
|
||||
|
||||
@@ -34,8 +35,8 @@ async function fill(page: Page) {
|
||||
await page.locator('#lead-contactName').fill('Test Contact');
|
||||
await page.locator('#lead-contactEmail').fill(email);
|
||||
await page.locator('#lead-website').fill('example.test');
|
||||
await page.locator('#lead-country').selectOption('GB');
|
||||
await page.locator('#lead-industry').selectOption('OTHER');
|
||||
await selectOption(page.locator('#lead-country'), 'GB');
|
||||
await selectOption(page.locator('#lead-industry'), 'OTHER');
|
||||
await page.locator('#lead-estimatedMonthlyVolumeUsd').fill('12500,50');
|
||||
return email;
|
||||
}
|
||||
@@ -84,7 +85,7 @@ for (const language of ['en', 'ru'])
|
||||
.click();
|
||||
await expect(page.locator('#lead-name')).toHaveValue('MerchantFlow browser fixture');
|
||||
await expect(page.locator('#lead-estimatedMonthlyVolumeUsd')).toHaveValue('12500,50');
|
||||
await expect(page.locator('#lead-country')).toHaveValue('GB');
|
||||
await expect(page.locator('#lead-country')).toHaveText(/United Kingdom|Великобритания/);
|
||||
await page
|
||||
.getByRole('button', { name: language === 'en' ? 'English' : 'Русский', exact: true })
|
||||
.click();
|
||||
|
||||
+15
-11
@@ -1,3 +1,4 @@
|
||||
import { selectOption } from './helpers/select';
|
||||
import { test, expect, type APIRequestContext } from '@playwright/test';
|
||||
import { createDatabase } from '../packages/database/dist/index.js';
|
||||
|
||||
@@ -74,21 +75,24 @@ for (const language of ['en', 'ru'])
|
||||
await page.goto('/app/review-queue');
|
||||
const search = page.getByRole('textbox', { name: /Search merchants|Поиск мерчантов/ });
|
||||
await search.fill(name);
|
||||
await page
|
||||
.getByRole('combobox', { name: /Account manager|Аккаунт-менеджер/ })
|
||||
.selectOption('user-manager1');
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /Account manager|Аккаунт-менеджер/ }),
|
||||
'user-manager1',
|
||||
);
|
||||
await expect(page.locator('article')).toHaveCount(1);
|
||||
await expect(page.locator('article')).toContainText(/Waiting|Ожидание/);
|
||||
await page
|
||||
.getByRole('combobox', { name: /Waiting time|Время ожидания/ })
|
||||
.selectOption('24');
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /Waiting time|Время ожидания/ }),
|
||||
'24',
|
||||
);
|
||||
await expect(page.locator('article')).toHaveCount(0);
|
||||
await expect(page).toHaveURL(/waiting=24/);
|
||||
await page.reload();
|
||||
await expect(search).toHaveValue(name);
|
||||
await page
|
||||
.getByRole('combobox', { name: /Waiting time|Время ожидания/ })
|
||||
.selectOption('ALL');
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /Waiting time|Время ожидания/ }),
|
||||
'ALL',
|
||||
);
|
||||
await expect(page.locator('article')).toHaveCount(1);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(
|
||||
true,
|
||||
@@ -110,7 +114,7 @@ for (const language of ['en', 'ru'])
|
||||
'aria-invalid',
|
||||
'true',
|
||||
);
|
||||
await dialog.getByLabel(/Decision$|^Решение$/).selectOption('REJECTED');
|
||||
await selectOption(dialog.getByLabel(/Decision$|^Решение$/), 'REJECTED');
|
||||
await expect(dialog.getByLabel(/Risk level|Уровень риска/)).toHaveCount(0);
|
||||
await dialog.getByRole('button', { name: /^(Reject|Отклонить)$/ }).click();
|
||||
const reason = dialog.getByLabel(/Rejection reason|Причина отклонения/);
|
||||
@@ -166,7 +170,7 @@ test('an open decision form stays bound to its original cycle after another revi
|
||||
await page.goto(`/app/merchants/${merchant.id}?tab=onboarding`);
|
||||
await page.getByRole('button', { name: 'Record decision', exact: true }).click();
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.getByLabel('Risk level', { exact: true }).selectOption('LOW');
|
||||
await selectOption(dialog.getByLabel('Risk level', { exact: true }), 'LOW');
|
||||
await dialog
|
||||
.getByLabel('Approval rationale (required)', { exact: true })
|
||||
.fill('Assessment of the original submission.');
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { selectOption } from './helpers/select';
|
||||
import { createHash, randomBytes } from 'node:crypto';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
import { createDatabase } from '../packages/database/dist/index.js';
|
||||
|
||||
@@ -5,9 +7,12 @@ if (!process.env.DATABASE_URL?.endsWith('/merchantflow_test'))
|
||||
throw new Error('Daily sales browser tests require the isolated database');
|
||||
const db = createDatabase(process.env.DATABASE_URL);
|
||||
const names = new Set<string>();
|
||||
const sessions = new Set<string>();
|
||||
test.afterEach(async () => {
|
||||
await db.merchant.deleteMany({ where: { name: { in: [...names] } } });
|
||||
names.clear();
|
||||
await db.session.deleteMany({ where: { id: { in: [...sessions] } } });
|
||||
sessions.clear();
|
||||
});
|
||||
test.afterAll(() => db.$disconnect());
|
||||
async function login(page: Page, account = 'head') {
|
||||
@@ -65,19 +70,19 @@ for (const language of ['en', 'ru'])
|
||||
page.getByText(/Log a call or email before|Запишите звонок или письмо/),
|
||||
).toBeVisible();
|
||||
await page.getByRole('button', { name: /^(Assign manager|Назначить менеджера)$/ }).click();
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel(/^(Account manager|Аккаунт-менеджер)$/)
|
||||
.selectOption('user-manager1');
|
||||
await selectOption(
|
||||
page.getByRole('dialog').getByLabel(/^(Account manager|Аккаунт-менеджер)$/),
|
||||
'user-manager1',
|
||||
);
|
||||
await save(page);
|
||||
await page.getByRole('tab', { name: /^(Activity|Активность)$/ }).click();
|
||||
await page
|
||||
.getByRole('button', { name: /^(Log interaction|Добавить взаимодействие)$/ })
|
||||
.click();
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel(/^(Interaction type|Тип взаимодействия)$/)
|
||||
.selectOption('CALL');
|
||||
await selectOption(
|
||||
page.getByRole('dialog').getByLabel(/^(Interaction type|Тип взаимодействия)$/),
|
||||
'CALL',
|
||||
);
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel(/^(Details|Подробности)$/)
|
||||
@@ -114,7 +119,7 @@ for (const language of ['en', 'ru'])
|
||||
const dialog = page.getByRole('dialog');
|
||||
await dialog.getByLabel(/^(Website|Сайт)$/).fill('https://daily.example.test');
|
||||
await dialog.getByLabel(/^(Country code|Код страны)$/).fill('GB');
|
||||
await dialog.getByLabel(/^(Industry|Отрасль)$/).selectOption('OTHER');
|
||||
await selectOption(dialog.getByLabel(/^(Industry|Отрасль)$/), 'OTHER');
|
||||
await dialog
|
||||
.getByLabel(/^(Estimated monthly processing \(USD\)|Месячный объём обработки \(USD\))$/)
|
||||
.fill('0');
|
||||
@@ -123,15 +128,18 @@ for (const language of ['en', 'ru'])
|
||||
await page
|
||||
.getByRole('textbox', { name: /Search merchants|Название мерчанта/ })
|
||||
.fill(`Contact ${name}`);
|
||||
await page
|
||||
.getByRole('combobox', { name: /^(All countries|Все страны)$/ })
|
||||
.selectOption('GB');
|
||||
await page
|
||||
.getByRole('combobox', { name: /^(All industries|Все отрасли)$/ })
|
||||
.selectOption('OTHER');
|
||||
await page
|
||||
.getByRole('combobox', { name: /^(All managers|Все менеджеры)$/ })
|
||||
.selectOption('user-manager1');
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /^(All countries|Все страны)$/ }),
|
||||
'GB',
|
||||
);
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /^(All industries|Все отрасли)$/ }),
|
||||
'OTHER',
|
||||
);
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /^(All managers|Все менеджеры)$/ }),
|
||||
'user-manager1',
|
||||
);
|
||||
await expect(page).toHaveURL(/country=GB.*industry=OTHER.*ownerId=user-manager1/);
|
||||
await expect(page.getByRole('link', { name: new RegExp(name) }).first()).toBeVisible();
|
||||
await noOverflow(page);
|
||||
@@ -158,7 +166,7 @@ for (const language of ['en', 'ru'])
|
||||
await expect
|
||||
.poll(async () => (await (await page.request.get(`/api/merchants/${id}`)).json()).status)
|
||||
.toBe('CONTACTED');
|
||||
if (width === 390) await page.getByRole('combobox').selectOption('CONTACTED');
|
||||
if (width === 390) await selectOption(page.getByRole('combobox'), 'CONTACTED');
|
||||
const contactedCard = page
|
||||
.getByRole('region', {
|
||||
name: language === 'en' ? 'Contacted' : 'Контакт установлен',
|
||||
@@ -237,3 +245,74 @@ test('manager creation assigns self and stale edits keep unsaved form values', a
|
||||
await page.goto('/app/merchants');
|
||||
await expect(page.getByRole('button', { name: 'Add merchant', exact: true })).toHaveCount(0);
|
||||
});
|
||||
|
||||
for (const width of [390, 1440]) {
|
||||
test(`custom dropdown keyboard navigation and merchant page sizes at ${width}px`, async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
// Login has dedicated coverage; these checks must not exhaust its rate limit.
|
||||
const user = await db.user.findUniqueOrThrow({ where: { email: '[email protected]' } });
|
||||
const token = randomBytes(32).toString('hex');
|
||||
const id = createHash('sha256').update(token).digest('hex');
|
||||
sessions.add(id);
|
||||
await db.session.create({
|
||||
data: { id, userId: user.id, expiresAt: new Date(Date.now() + 3600000) },
|
||||
});
|
||||
await page.context().addCookies([
|
||||
{
|
||||
name: 'mf_session',
|
||||
value: token,
|
||||
domain: '127.0.0.1',
|
||||
path: '/api',
|
||||
httpOnly: true,
|
||||
sameSite: 'Lax',
|
||||
},
|
||||
]);
|
||||
await page.goto('/app/merchants');
|
||||
const size = page.getByRole('combobox', { name: 'Show per page' });
|
||||
await expect(size).toHaveText('10');
|
||||
await expect(page.locator('select:visible')).toHaveCount(0);
|
||||
await page.getByRole('button', { name: 'Next', exact: true }).click();
|
||||
await expect(page).toHaveURL(/page=2/);
|
||||
for (const count of [20, 30, 10]) {
|
||||
const response = page.waitForResponse((response) => {
|
||||
const url = new URL(response.url());
|
||||
return (
|
||||
url.pathname === '/api/merchants' && url.searchParams.get('pageSize') === String(count)
|
||||
);
|
||||
});
|
||||
await selectOption(size, String(count));
|
||||
const result = await (await response).json();
|
||||
expect(result.page).toBe(1);
|
||||
expect(result.pageSize).toBe(count);
|
||||
expect(result.items).toHaveLength(Math.min(count, result.total));
|
||||
await expect(
|
||||
page.getByText(`1–${Math.min(count, result.total)} of ${result.total} merchants`, {
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible();
|
||||
expect(new URL(page.url()).searchParams.has('page')).toBe(false);
|
||||
await noOverflow(page);
|
||||
}
|
||||
await selectOption(size, '20');
|
||||
await page.reload();
|
||||
await expect(size).toHaveText('20');
|
||||
const stage = page.getByRole('combobox', { name: 'Filter by stage' });
|
||||
await stage.focus();
|
||||
await stage.press('ArrowDown');
|
||||
await expect(page.getByRole('listbox')).toBeVisible();
|
||||
await expect(page.getByRole('option', { name: 'All stages', exact: true })).toBeFocused();
|
||||
await page.keyboard.press('End');
|
||||
await expect(page.getByRole('option', { name: 'Rejected', exact: true })).toBeFocused();
|
||||
await page.keyboard.press('Enter');
|
||||
await expect(stage).toHaveText('Rejected');
|
||||
await expect(stage).toBeFocused();
|
||||
await expect(page).toHaveURL(/status=REJECTED/);
|
||||
await stage.press('ArrowDown');
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.getByRole('listbox')).not.toBeVisible();
|
||||
await expect(stage).toBeFocused();
|
||||
await expect(stage).toHaveText('Rejected');
|
||||
});
|
||||
}
|
||||
|
||||
+24
-22
@@ -1,3 +1,4 @@
|
||||
import { selectOption } from './helpers/select';
|
||||
import { test, expect, type Page } from '@playwright/test';
|
||||
async function signIn(page: Page, account = 'head') {
|
||||
await page.goto('/login');
|
||||
@@ -94,9 +95,10 @@ for (const language of ['en', 'ru'])
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||
await page.goto('/app/merchants');
|
||||
await page
|
||||
.getByRole('combobox', { name: /Filter by stage|Фильтр по этапу/ })
|
||||
.selectOption('LIVE');
|
||||
await selectOption(
|
||||
page.getByRole('combobox', { name: /Filter by stage|Фильтр по этапу/ }),
|
||||
'LIVE',
|
||||
);
|
||||
await expect(page.getByRole('link', { name: /Sunday Market/ }).first()).toBeVisible();
|
||||
await page.getByRole('textbox').fill('no-such-merchant');
|
||||
await expect(page.getByText(/No merchants found|Мерчанты не найдены/)).toBeVisible();
|
||||
@@ -104,9 +106,9 @@ for (const language of ['en', 'ru'])
|
||||
await expect(page.getByRole('textbox')).toHaveValue('');
|
||||
await page.goto('/app/pipeline');
|
||||
await expect(page.locator('h1')).toHaveText(language === 'en' ? 'Pipeline' : 'Воронка');
|
||||
if (width === 390) await page.getByRole('combobox').selectOption('KYB');
|
||||
if (width === 390) await selectOption(page.getByRole('combobox'), 'KYB');
|
||||
await expect(page.getByRole('link', { name: /Luma Labs/ })).toBeVisible();
|
||||
if (width === 390) await page.getByRole('combobox').selectOption('REJECTED');
|
||||
if (width === 390) await selectOption(page.getByRole('combobox'), 'REJECTED');
|
||||
await expect(page.getByRole('heading', { name: /^(Rejected|Отклонён)$/ })).toBeVisible();
|
||||
await noOverflow(page);
|
||||
await page.screenshot({ path: info.outputPath('pipeline.png'), fullPage: true });
|
||||
@@ -238,7 +240,7 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
await page.goto(merchantPath);
|
||||
await expect(page.getByText('Unassigned', { exact: true })).toBeVisible();
|
||||
await page.getByRole('button', { name: 'Assign manager', exact: true }).click();
|
||||
await page.getByRole('dialog').getByLabel('Account manager').selectOption('user-manager1');
|
||||
await selectOption(page.getByRole('dialog').getByLabel('Account manager'), 'user-manager1');
|
||||
await save();
|
||||
await switchAccount('alex');
|
||||
await expect(page.getByRole('button', { name: 'Assign manager', exact: true })).toHaveCount(0);
|
||||
@@ -255,7 +257,7 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
await expect(page.getByText('Director of Partnerships', { exact: true })).toBeVisible();
|
||||
await page.getByRole('tab', { name: 'Activity', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Log interaction', exact: true }).click();
|
||||
await page.getByRole('dialog').getByLabel('Interaction type').selectOption('CALL');
|
||||
await selectOption(page.getByRole('dialog').getByLabel('Interaction type'), 'CALL');
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Details', { exact: true })
|
||||
@@ -280,10 +282,10 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
await page.getByRole('tab', { name: 'Onboarding', exact: true }).click();
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await page.getByRole('button', { name: 'Update collection', exact: true }).nth(i).click();
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Collection status', { exact: true })
|
||||
.selectOption('RECEIVED');
|
||||
await selectOption(
|
||||
page.getByRole('dialog').getByLabel('Collection status', { exact: true }),
|
||||
'RECEIVED',
|
||||
);
|
||||
await save();
|
||||
}
|
||||
await advance('Compliance Review');
|
||||
@@ -291,10 +293,10 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
await switchAccount('compliance');
|
||||
await page.getByRole('tab', { name: 'Onboarding', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Record decision', exact: true }).click();
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Decision', { exact: true })
|
||||
.selectOption('CORRECTIONS');
|
||||
await selectOption(
|
||||
page.getByRole('dialog').getByLabel('Decision', { exact: true }),
|
||||
'CORRECTIONS',
|
||||
);
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Required changes (required)', { exact: true })
|
||||
@@ -314,10 +316,10 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
.locator('#checklist > div > div')
|
||||
.filter({ hasText: 'Ownership structure' });
|
||||
await ownership.getByRole('button', { name: 'Update collection', exact: true }).click();
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Collection status', { exact: true })
|
||||
.selectOption('RECEIVED');
|
||||
await selectOption(
|
||||
page.getByRole('dialog').getByLabel('Collection status', { exact: true }),
|
||||
'RECEIVED',
|
||||
);
|
||||
await page
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Collection notes', { exact: true })
|
||||
@@ -331,7 +333,7 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
.getByRole('dialog')
|
||||
.getByLabel('Approval rationale (required)', { exact: true })
|
||||
.fill('All evidence checked and approved.');
|
||||
await page.getByRole('dialog').getByLabel('Risk level', { exact: true }).selectOption('LOW');
|
||||
await selectOption(page.getByRole('dialog').getByLabel('Risk level', { exact: true }), 'LOW');
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Approve', exact: true }).click();
|
||||
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'Edit merchant', exact: true })).toHaveCount(0);
|
||||
@@ -347,7 +349,7 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
.locator('article')
|
||||
.filter({ has: page.getByRole('heading', { name, exact: true }) });
|
||||
await row.getByRole('button', { name: 'Update demo check' }).click();
|
||||
await page.getByRole('dialog').getByLabel('Result', { exact: true }).selectOption(result);
|
||||
await selectOption(page.getByRole('dialog').getByLabel('Result', { exact: true }), result);
|
||||
await save();
|
||||
};
|
||||
await expect(page.getByRole('button', { name: 'Move to Testing', exact: true })).toBeDisabled();
|
||||
@@ -364,7 +366,7 @@ test('Head assignment, manager editing, Compliance decisions and manager activat
|
||||
await page.screenshot({ path: info.outputPath('approved-live-merchant.png'), fullPage: true });
|
||||
await switchAccount('head');
|
||||
await page.getByRole('button', { name: 'Assign manager', exact: true }).click();
|
||||
await page.getByRole('dialog').getByLabel('Account manager').selectOption('user-manager2');
|
||||
await selectOption(page.getByRole('dialog').getByLabel('Account manager'), 'user-manager2');
|
||||
await save();
|
||||
await switchAccount('sam');
|
||||
await expect(page.getByText('Director of Partnerships', { exact: true })).toBeVisible();
|
||||
|
||||
Reference in New Issue
Block a user