Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
import { expect, test } from '@playwright/test'
import { login } from './helpers'
const HOME_PATH = (storeId: string) => `/${storeId}`
test.describe('home dashboard', () => {
test('renders KPI tiles with the comparison chart', async ({ page }) => {
const creds = await login(page)
await page.goto(HOME_PATH(creds.store_id))
await expect(page.getByRole('heading', { name: /^dashboard$/i })).toBeVisible({
timeout: 15_000,
})
// KPI metric tiles (buttons that switch the chart metric)
await expect(page.getByRole('button', { name: /total sales/i })).toBeVisible()
await expect(page.getByRole('button', { name: /^orders\b/i })).toBeVisible()
await expect(page.getByRole('button', { name: /average order value/i })).toBeVisible()
await expect(page.getByRole('button', { name: /units sold/i })).toBeVisible()
// Comparison legend under the chart
await expect(page.getByText(/^this period$/i)).toBeVisible()
await expect(page.getByText(/^previous period$/i)).toBeVisible()
// Switching the active metric keeps the chart rendered
await page.getByRole('button', { name: /^orders\b/i }).click()
await expect(page.getByText(/^this period$/i)).toBeVisible()
})
// A store selling in several currencies sums each one separately — the
// figures are never converted — so the screen has to say which one it is
// showing and let the merchant change it.
test('scopes the figures to a currency the store sells in', async ({ page }) => {
const creds = await login(page)
await page.goto(HOME_PATH(creds.store_id))
const totalSales = page.getByRole('button', { name: /total sales/i })
await expect(totalSales).toContainText('$', { timeout: 15_000 })
await page.locator('#home-currency').click()
await page.getByRole('option', { name: /EUR/ }).click()
await expect(totalSales).toContainText('€', { timeout: 15_000 })
await expect(totalSales).not.toContainText('$')
})
test('renders the operations and rankings widgets', async ({ page }) => {
const creds = await login(page)
await page.goto(HOME_PATH(creds.store_id))
await expect(page.getByRole('heading', { name: /^dashboard$/i })).toBeVisible({
timeout: 15_000,
})
// Operations rows
await expect(page.getByText(/orders to fulfill/i)).toBeVisible()
await expect(page.getByText(/payments to collect/i)).toBeVisible()
await expect(page.getByText(/open returns/i)).toBeVisible()
await expect(page.getByText(/^low stock$/i)).toBeVisible()
await expect(page.getByText(/^out of stock$/i)).toBeVisible()
// Rankings card with customer/category tabs
await expect(page.getByText('Rankings', { exact: true })).toBeVisible()
await page.getByRole('tab', { name: /^categories$/i }).click()
await page.getByRole('tab', { name: /^customers$/i }).click()
})
test('scopes metrics by channel via the switcher', async ({ page }) => {
const creds = await login(page)
await page.goto(HOME_PATH(creds.store_id))
// Defaults to all channels
const switcher = page.getByRole('combobox').filter({ hasText: /all channels/i })
await expect(switcher).toBeVisible({ timeout: 15_000 })
await switcher.click()
await page.getByRole('option', { name: /wholesale/i }).click()
await expect(page.getByRole('combobox').filter({ hasText: /wholesale/i })).toBeVisible()
await expect(page.getByRole('button', { name: /total sales/i })).toBeVisible()
await expect(page.getByText(/orders to fulfill/i)).toBeVisible()
})
test('orders to fulfill links to the filtered orders list', async ({ page }) => {
const creds = await login(page)
await page.goto(HOME_PATH(creds.store_id))
await page.getByText(/orders to fulfill/i).click()
await expect(page).toHaveURL(/\/orders\?/, { timeout: 15_000 })
await expect(page.getByText(/fulfillment/i).first()).toBeVisible()
})
})