Implemented the database, authentication, access rules, and seed data

This commit is contained in:
Oleksandr Prokhorenko
2026-09-24 19:08:55 +03:00
parent 3aa47d825f
commit 5de240fda3
27 changed files with 3793 additions and 277 deletions
+157 -8
View File
@@ -64,12 +64,23 @@ for (const language of ['en', 'ru'])
.first()
.click();
await expect(page.locator('h1')).toHaveText('Luma Labs');
await expect(page.getByText(/Please clarify the beneficial ownership/)).toBeVisible();
await expect(
page.getByText(/Please clarify the beneficial ownership/).first(),
).toBeVisible();
await noOverflow(page);
await page.reload();
await expect(page.locator('h1')).toHaveText('Luma Labs');
await expect(page.locator('html')).toHaveAttribute('lang', language);
await page.screenshot({ path: info.outputPath('merchant.png'), fullPage: true });
const editButton = page.getByRole('button', {
name: /^(Edit merchant|Изменить мерчанта)$/,
});
await editButton.click();
await expect(page.getByRole('dialog')).toBeVisible();
await noOverflow(page);
await page.screenshot({ path: info.outputPath('merchant-editor.png'), fullPage: true });
await page.keyboard.press('Escape');
await expect(page.getByRole('dialog')).not.toBeVisible();
await page.goto('/app/merchants');
await page.getByRole('combobox').selectOption('LIVE');
await expect(page.getByRole('link', { name: /Sunday Market/ }).first()).toBeVisible();
@@ -105,24 +116,23 @@ test('account switching removes old data, manager isolation and Compliance navig
await expect(page.locator('h1')).toHaveText('Northstar Studio');
await page.getByRole('button', { name: 'Sign out' }).click();
await expect(page).toHaveURL(/login/);
await signIn(page, 'manager1');
await signIn(page, 'alex');
const dashboard = await page.request.get('/api/dashboard');
expect((await dashboard.json()).merchantCount).toBe(9);
expect((await dashboard.json()).merchantCount).toBe(20);
await page.goto('/app/merchants/merchant-02');
await expect(
page.getByText('This merchant was not found or is outside your portfolio.'),
).toBeVisible();
await page.getByRole('button', { name: 'Sign out' }).click();
await signIn(page, 'compliance');
expect((await (await page.request.get('/api/dashboard')).json()).merchantCount).toBe(4);
expect((await (await page.request.get('/api/dashboard')).json()).merchantCount).toBe(45);
await page.getByRole('link', { name: 'Review queue', exact: true }).click();
await expect(page.getByRole('heading', { name: '2 merchants awaiting review' })).toBeVisible();
await expect(page.getByRole('heading', { name: '6 merchants awaiting review' })).toBeVisible();
await page.getByRole('link', { name: 'View checklist' }).first().click();
await expect(page.getByRole('heading', { name: 'KYB checklist' })).toBeVisible();
await page.goto('/app/merchants/merchant-15');
await expect(
page.getByText('This merchant was not found or is outside your portfolio.'),
).toBeVisible();
await expect(page.locator('h1')).toHaveText('Sunday Market');
await expect(page.getByRole('button', { name: 'Edit merchant', exact: true })).toHaveCount(0);
});
test('translated validation, persistent language changes and accessible form errors', async ({
page,
@@ -182,3 +192,142 @@ test('loading, retryable errors, empty states, session expiry and reduced motion
await page.goto('/app/merchants');
await expect(page).toHaveURL(/\/login\?next=/);
});
test('Head assignment, manager editing, Compliance decisions and manager activation work through the UI', async ({
page,
}, info) => {
const merchantPath = '/app/merchants/merchant-19';
const save = async () => {
await page.getByRole('button', { name: 'Save changes', exact: true }).click();
await expect(page.getByRole('dialog')).not.toBeVisible();
};
const switchAccount = async (account: string) => {
await page.getByRole('button', { name: 'Sign out', exact: true }).click();
await signIn(page, account);
await page.goto(merchantPath);
await expect(page.locator('h1')).toHaveText('Willow Ceramics');
};
const advance = async (stage: string) => {
await page.getByRole('button', { name: `Move to ${stage}`, exact: true }).click();
await expect(
page.getByRole('status').filter({ hasText: 'Changes saved.' }).first(),
).toBeVisible();
await expect
.poll(
async () => (await (await page.request.get('/api/merchants/merchant-19')).json()).status,
)
.toBe(stage.toUpperCase().replaceAll(' ', '_'));
};
await signIn(page);
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 save();
await switchAccount('alex');
await expect(page.getByRole('button', { name: 'Assign manager', exact: true })).toHaveCount(0);
await page.getByRole('button', { name: 'Edit merchant', exact: true }).click();
await page
.getByRole('dialog')
.getByLabel('Contact title', { exact: true })
.fill('Director of Partnerships');
await page
.getByRole('dialog')
.getByLabel('Estimated monthly processing (USD)', { exact: true })
.fill('246000.75');
await save();
await expect(page.getByText('Director of Partnerships', { exact: true })).toBeVisible();
await page.getByRole('button', { name: 'Log interaction', exact: true }).click();
await page.getByRole('dialog').getByLabel('Interaction type').selectOption('CALL');
await page
.getByRole('dialog')
.getByLabel('Details', { exact: true })
.fill('Confirmed the launch requirements in a discovery call.');
await save();
await expect(
page.getByText('Confirmed the launch requirements in a discovery call.', { exact: true }),
).toBeVisible();
await page.getByRole('button', { name: 'Add task', exact: true }).click();
await page
.getByRole('dialog')
.getByLabel('Task title', { exact: true })
.fill('Send the integration guide');
await save();
const taskRow = page.locator('#tasks > div').filter({ hasText: 'Send the integration guide' });
await taskRow.getByRole('button', { name: 'Complete task', exact: true }).click();
await expect(taskRow.getByText('Completed', { exact: true }).first()).toBeVisible();
await advance('Contacted');
await advance('Qualified');
await advance('KYB');
for (let i = 0; i < 4; i++) {
await page.getByRole('button', { name: 'Update document', exact: true }).nth(i).click();
await page
.getByRole('dialog')
.getByLabel('Document status', { exact: true })
.selectOption('RECEIVED');
await save();
}
await advance('Compliance Review');
await expect(page.getByRole('button', { name: 'Record decision', exact: true })).toHaveCount(0);
await switchAccount('compliance');
await page.getByRole('button', { name: 'Record decision', exact: true }).click();
await page
.getByRole('dialog')
.getByLabel('Decision', { exact: true })
.selectOption('CORRECTIONS');
await page
.getByRole('dialog')
.getByLabel('Decision reason', { exact: true })
.fill('The ownership declaration needs a current signature.');
await page
.getByRole('dialog')
.getByLabel('Ownership structure', { exact: true })
.fill('Please sign and date the declaration.');
await save();
await switchAccount('alex');
const ownership = page
.locator('#checklist > div > div')
.filter({ hasText: 'Ownership structure' });
await ownership.getByRole('button', { name: 'Update document', exact: true }).click();
await page
.getByRole('dialog')
.getByLabel('Document status', { exact: true })
.selectOption('RECEIVED');
await page
.getByRole('dialog')
.getByLabel('Note', { exact: true })
.fill('Updated signature received.');
await save();
await advance('Compliance Review');
await switchAccount('compliance');
await page.getByRole('button', { name: 'Record decision', exact: true }).click();
await page
.getByRole('dialog')
.getByLabel('Decision reason', { exact: true })
.fill('All evidence checked and approved.');
await save();
await expect(page.getByRole('button', { name: 'Edit merchant', exact: true })).toHaveCount(0);
await switchAccount('alex');
await page.getByRole('button', { name: 'Edit merchant', exact: true }).click();
await expect(
page.getByRole('dialog').getByLabel('Legal company name', { exact: true }),
).toBeDisabled();
await page.getByRole('button', { name: 'Cancel', exact: true }).click();
await advance('Testing');
await advance('Live');
await noOverflow(page);
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 save();
await switchAccount('sam');
await expect(page.getByText('Director of Partnerships', { exact: true })).toBeVisible();
const hidden = await page.request.get('/api/merchants/merchant-01');
expect(hidden.status()).toBe(404);
expect(
await page.evaluate(() =>
Object.keys(localStorage).every((key) => key === 'merchantflow.language'),
),
).toBe(true);
});