Commit the working vertical slices for inventory image processing and the Sale workflow, including Sale history, audited voiding, multi-item persistence, admin UI, migrations, documentation, and tests.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test('signs in and creates a product and physical copy from the admin workspace', async ({ page }) => {
|
||||
const tinyPng = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', 'base64');
|
||||
|
||||
test('signs in and publishes a listing after adding an inventory image', async ({ page }) => {
|
||||
const email = process.env.INITIAL_ADMIN_EMAIL;
|
||||
const password = process.env.INITIAL_ADMIN_PASSWORD;
|
||||
|
||||
@@ -24,8 +26,39 @@ test('signs in and creates a product and physical copy from the admin workspace'
|
||||
await page.getByLabel('Condition', { exact: true }).selectOption({ index: 1 });
|
||||
await page.getByRole('button', { name: 'Create copy' }).click();
|
||||
|
||||
await expect(page.getByText('Manage images')).toBeVisible();
|
||||
await page.getByText('Manage images').last().click();
|
||||
const inventoryLink = page.locator('section[aria-labelledby="inventory-title"]').getByRole('link', { name: 'Manage images' }).last();
|
||||
await expect(inventoryLink).toBeVisible();
|
||||
const createdInventoryId = await page.getByLabel('Inventory copy').locator('option').last().getAttribute('value');
|
||||
await inventoryLink.click();
|
||||
await expect(page).toHaveURL(/\/admin\/inventory\/[^/]+\/images$/);
|
||||
await expect(page.getByRole('heading', { name: 'Manage images' })).toBeVisible();
|
||||
await page.getByLabel('Add image').setInputFiles({
|
||||
name: 'front.png',
|
||||
mimeType: 'image/png',
|
||||
buffer: tinyPng,
|
||||
});
|
||||
await expect(page.getByLabel('Alt text')).toHaveValue('front.png');
|
||||
|
||||
await page.goto('/admin');
|
||||
await expect(page.getByRole('heading', { name: 'Create listing draft' })).toBeVisible();
|
||||
await page.getByLabel('Inventory copy', { exact: true }).first().selectOption(createdInventoryId);
|
||||
await page.getByLabel('Asking price (cents)').fill('2499');
|
||||
await page.getByRole('button', { name: 'Create listing' }).click();
|
||||
await expect(page.getByText('Add at least one image before publishing.')).toHaveCount(0);
|
||||
await page.getByRole('button', { name: 'Publish' }).last().click();
|
||||
await expect(page.getByText('AVAILABLE').last()).toBeVisible();
|
||||
|
||||
await page.getByLabel('Inventory copy', { exact: true }).last().selectOption(createdInventoryId);
|
||||
await page.getByLabel('Sale date').fill('2026-09-09');
|
||||
await page.getByLabel('Sold price (cents)').fill('2499');
|
||||
await page.getByLabel('Cost basis (cents)').fill('1200');
|
||||
await page.getByRole('button', { name: 'Record sale' }).click();
|
||||
await expect(page.locator('section[aria-labelledby="inventory-title"]').getByText(`${createdInventoryId} · SOLD`)).toBeVisible();
|
||||
await expect(page.getByRole('heading', { name: 'Sale history' })).toBeVisible();
|
||||
const latestSale = page.locator('section[aria-labelledby="sales-title"] li').first();
|
||||
await expect(latestSale).toContainText('Profit $12.99');
|
||||
await latestSale.getByLabel('Void reason').fill('Browser test correction');
|
||||
await latestSale.getByRole('button', { name: 'Void sale' }).click();
|
||||
await expect(latestSale).toContainText('VOIDED');
|
||||
await expect(page.locator('section[aria-labelledby="inventory-title"]').getByText(`${createdInventoryId} · ACTIVE`)).toBeVisible();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user