feat: the venue and products reports on v2 (platform-v2 step 6.12b)
- Reports -> Venue (src/pages/reports/store): business days (revenue/profit trend, each day's times, orders, revenue, fees, refunds, cost, profit; a day opens with its orders and shifts, a shift opens the overview's shift dialog; the owner corrects a closing time, deletes an empty day or a shift), orders (filters by status, person, table; per-order products / fees / refunds), busy times (by hour, by weekday of the business date), trends (days, weeks, months, the 7-day average), tables (time at the table, per visit, revenue) - Reports -> Products (src/pages/reports/products): products (units, revenue, refunded, cost, profit, margin, waste, share; top 10 by revenue, units or profit) and categories (share bars, profit share) - kit: PrintDialog (receipt printer, summary / full, or print the page), TrendChart and BarList on tokens (no chart animation), printBody() - access: deleting a business day or a shift (which erases its orders) is owner-only (core.settings.manage; was any dashboard user) - v1 StorePage, ProductsReportPage and their seven views removed - tests: reports.test.mjs (+1), e2e manager.mjs (every tab, a day, products revenue = the backend's, Greek) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,8 @@ const term = await startTerminalVite({ port: 5188, backendUrl: backend.url })
|
||||
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||
const r = reporter('manager: login + bootstrap on @xenia/api / @xenia/access')
|
||||
|
||||
const addDaysIso = (key, n) => new Date(Date.parse(`${key}T12:00:00Z`) + n * 86_400_000).toISOString().slice(0, 10)
|
||||
|
||||
async function api(method, url, { token, body } = {}) {
|
||||
const res = await fetch(backend.url + url, {
|
||||
method, headers: { 'content-type': 'application/json', ...(token ? { authorization: `Bearer ${token}` } : {}) },
|
||||
@@ -1186,8 +1188,34 @@ try {
|
||||
await page.waitForFunction(() => document.querySelector('[data-testid="report-today"] h1')?.textContent === 'Σήμερα', null, { timeout: 5000 }).catch(() => {})
|
||||
r.check(`${rp} Today in Greek`, (await page.locator('[data-testid="report-today"] h1').textContent()) === 'Σήμερα' && (await todayRevenue.textContent()).includes('Έσοδα'))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-report-today-el.png'), fullPage: true })
|
||||
// 6.12b: the venue and products reports, still in Greek for one tab
|
||||
await page.goto(`${APP}/reports/store?tab=traffic`)
|
||||
r.check(`${rp} Venue → Busy times in Greek`, await page.getByTestId('traffic-weekdays').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false)
|
||||
&& (await page.locator('[data-testid="report-store"] h1').textContent()) === 'Κατάστημα')
|
||||
await page.getByTestId('user-menu').click()
|
||||
await page.getByRole('menuitemradio', { name: 'English' }).click()
|
||||
await page.goto(`${APP}/reports/store`)
|
||||
const dayRow = page.getByTestId('report-day').first()
|
||||
r.check(`${rp} Venue → Business days lists the days`, await dayRow.waitFor({ timeout: 10_000 }).then(() => true).catch(() => false))
|
||||
await dayRow.click()
|
||||
r.check(`${rp} a day opens with its orders and shifts`, await page.getByTestId('report-day-dialog').waitFor({ timeout: 8000 }).then(() => true).catch(() => false))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-report-day.png'), fullPage: true })
|
||||
await page.keyboard.press('Escape')
|
||||
for (const [tab, testId] of [['orders', 'report-order'], ['trends', 'trend-chart'], ['tables', 'report-period']]) {
|
||||
await page.getByTestId(`report-tab-${tab}`).click()
|
||||
r.check(`${rp} Venue → ${tab} opens`, await page.getByTestId(testId).first().waitFor({ timeout: 10_000 }).then(() => true).catch(() => false))
|
||||
}
|
||||
await page.goto(`${APP}/reports/products`)
|
||||
const prodRevenue = page.getByTestId('products-revenue')
|
||||
await prodRevenue.waitFor({ timeout: 10_000 }).catch(() => {})
|
||||
const venueDay = new Intl.DateTimeFormat('en-CA', { timeZone: 'Europe/Athens' }).format(new Date()) // the venue's date, as the page's default period
|
||||
const perf = (await api('GET', `/api/reports/products/performance?from=${addDaysIso(venueDay, -29)}T00:00:00&to=${venueDay}T23:59:59`, { token: boss })).products
|
||||
const perfTotal = perf.reduce((s, p) => s + p.revenue, 0)
|
||||
r.check(`${rp} Products: the revenue is the backend's (no delivery-fee product)`, (await prodRevenue.textContent()).replace(/[\s,]/g, '').includes(perfTotal.toFixed(2))
|
||||
&& !perf.some(p => /delivery|αποστολ/i.test(p.product_name)), `${perfTotal} vs ${await prodRevenue.textContent()}`)
|
||||
await page.getByTestId('report-tab-categories').click()
|
||||
r.check(`${rp} Products → Categories opens`, await page.getByTestId('categories-share').waitFor({ timeout: 10_000 }).then(() => true).catch(() => false))
|
||||
await page.screenshot({ path: path.join(OUT, 'manager-report-categories.png'), fullPage: true })
|
||||
|
||||
await api('PUT', '/api/platform/modules/connect_orders', { token: boss, body: { enabled: true } })
|
||||
await page.goto(`${APP}/online-orders`)
|
||||
|
||||
Reference in New Issue
Block a user