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
Added end-to-end tests for the untested admin settings screens
Claude704fef489eb5
diff --git a/packages/dashboard/e2e/gift-cards.spec.ts b/packages/dashboard/e2e/gift-cards.spec.tsindex 0aca7b6bb9..8c1cd57d0d 100644--- a/packages/dashboard/e2e/gift-cards.spec.ts+++ b/packages/dashboard/e2e/gift-cards.spec.ts@@ -102,4 +102,16 @@ test.describe('gift cards', () => {await expect(rowButton(page, code)).toHaveCount(0, { timeout: 15_000 })})++ // Gift cards used to live under Promotions; bookmarks to the old address+ // must keep working, filters included.+ test('the old promotions address opens the gift cards list', async ({ page }) => {+ const creds = await login(page)+ await page.goto(`/${creds.store_id}/promotions/gift-cards?new=true`)++ await expect(page).toHaveURL(new RegExp(`${GIFT_CARDS_PATH(creds.store_id)}\\?new=true`), {+ timeout: 15_000,+ })+ await expect(page.getByRole('heading', { name: /new gift card/i })).toBeVisible()+ })})diff --git a/packages/dashboard/e2e/helpers.ts b/packages/dashboard/e2e/helpers.tsindex 5cf450b30f..430cc7f53b 100644--- a/packages/dashboard/e2e/helpers.ts+++ b/packages/dashboard/e2e/helpers.ts@@ -283,6 +283,17 @@ export async function openRowMenu(page: Page, rowText: string) {.click()}+/**+ * Wait for every toast to leave. Toasts stack over the bottom-right corner,+ * where the last row's action menu sits, and a toast under the pointer pauses+ * its own timer — so the pointer is moved away first, or a click aimed at that+ * row can wait on it forever.+ */+export async function waitForToastsToClear(page: Page) {+ await page.mouse.move(0, 0)+ await expect(page.locator('[role="status"][data-type]')).toHaveCount(0, { timeout: 15_000 })+}+/*** Click a bulk action by name. The `<BulkActionBar>` measures available width* and pushes overflowing actions into a "More actions" dropdown — at thediff --git a/packages/dashboard/e2e/integrations.spec.ts b/packages/dashboard/e2e/integrations.spec.tsnew file mode 100644index 0000000000..454d3d2b5b--- /dev/null+++ b/packages/dashboard/e2e/integrations.spec.ts@@ -0,0 +1,17 @@+import { expect, test } from '@playwright/test'+import { login } from './helpers'++test.describe('integrations', () => {+ // Integrations come from provider gems, and the test app installs none —+ // so the page has to explain where they come from rather than sit blank.+ test('explains where integrations come from when none are installed', async ({ page }) => {+ const creds = await login(page)+ await page.goto(`/${creds.store_id}/settings/integrations`)++ await expect(page.getByRole('heading', { name: /^integrations$/i })).toBeVisible({+ timeout: 15_000,+ })+ await expect(page.getByText(/no integrations installed/i)).toBeVisible()+ await expect(page.getByText(/install a provider gem/i)).toBeVisible()+ })+})diff --git a/packages/dashboard/e2e/marketplace-settings.spec.ts b/packages/dashboard/e2e/marketplace-settings.spec.tsnew file mode 100644index 0000000000..476b4295fe--- /dev/null+++ b/packages/dashboard/e2e/marketplace-settings.spec.ts@@ -0,0 +1,48 @@+import { expect, test } from '@playwright/test'+import { login } from './helpers'++const MARKETPLACE_PATH = (storeId: string) => `/${storeId}/settings/marketplace`++test.describe('marketplace settings', () => {+ test('saves the payout minimum and commission tax, and they survive a reload', async ({+ page,+ }) => {+ const creds = await login(page)+ await page.goto(MARKETPLACE_PATH(creds.store_id))+ await expect(page.getByRole('heading', { name: /^marketplace$/i })).toBeVisible({+ timeout: 15_000,+ })++ const minimum = page.locator('#payout-minimum')+ const taxRate = page.locator('#marketplace-commission-tax-rate')+ const originalMinimum = await minimum.inputValue()+ const originalTaxRate = await taxRate.inputValue()++ await minimum.fill('25')+ await taxRate.fill('8')+ await page.getByRole('button', { name: /^save$/i }).click()+ await expect(page.getByText(/store settings updated/i).first()).toBeVisible({+ timeout: 15_000,+ })++ await page.reload()+ await expect(minimum).toHaveValue(/^25(\.0+)?$/, { timeout: 15_000 })+ await expect(taxRate).toHaveValue(/^8(\.0+)?$/)++ // Put the store back so the sellers and payout specs read the defaults.+ await minimum.fill(originalMinimum)+ await taxRate.fill(originalTaxRate)+ await page.getByRole('button', { name: /^save$/i }).click()+ await expect(page.getByRole('button', { name: /^save$/i })).toBeDisabled({ timeout: 15_000 })+ })++ test('the old payouts settings address opens this page', async ({ page }) => {+ const creds = await login(page)+ await page.goto(`/${creds.store_id}/settings/payouts`)++ await expect(page).toHaveURL(new RegExp(`${MARKETPLACE_PATH(creds.store_id)}$`), {+ timeout: 15_000,+ })+ await expect(page.getByRole('heading', { name: /^marketplace$/i })).toBeVisible()+ })+})diff --git a/packages/dashboard/e2e/package-types.spec.ts b/packages/dashboard/e2e/package-types.spec.tsnew file mode 100644index 0000000000..bbef19c4d1--- /dev/null+++ b/packages/dashboard/e2e/package-types.spec.ts@@ -0,0 +1,73 @@+import { expect, type Page, test } from '@playwright/test'+import { gotoIndex, login, openRowMenu, rowButton } from './helpers'++const PACKAGE_TYPES_PATH = (storeId: string) => `/${storeId}/settings/package-types`+const CTA = /add package type/i++async function createPackageType(page: Page, name: string) {+ await page.getByRole('button', { name: CTA }).click()+ await page.locator('#package-type-name').fill(name)+ await page.locator('#package-type-length').fill('40')+ await page.locator('#package-type-width').fill('30')+ await page.locator('#package-type-height').fill('20')+ await page.locator('#package-type-weight').fill('0.5')+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^save$/i })+ .click()+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })+}++test.describe('package types', () => {+ test('adds a carton and lists its measurements', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, PACKAGE_TYPES_PATH(creds.store_id), CTA)++ const name = `E2E Carton ${Date.now()}`+ await createPackageType(page, name)++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row.getByText(/40(\.0+)? × 30(\.0+)? × 20(\.0+)?/)).toBeVisible()+ })++ test('edits a package type', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, PACKAGE_TYPES_PATH(creds.store_id), CTA)++ const name = `E2E Resized ${Date.now()}`+ await createPackageType(page, name)++ await rowButton(page, name).click()+ await expect(page.locator('#package-type-length')).toHaveValue(/^40(\.0+)?$/, {+ timeout: 15_000,+ })+ await page.locator('#package-type-length').fill('45')+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^save$/i })+ .click()++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row.getByText(/45(\.0+)? × 30(\.0+)? × 20(\.0+)?/)).toBeVisible({+ timeout: 15_000,+ })+ })++ test('deletes a package type after confirming', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, PACKAGE_TYPES_PATH(creds.store_id), CTA)++ const name = `E2E Retired Box ${Date.now()}`+ await createPackageType(page, name)++ await openRowMenu(page, name)+ await page.getByRole('menuitem', { name: /^delete$/i }).click()+ await expect(page.getByRole('heading', { name: /delete package type\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^delete$/i })+ .click()++ await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })+ })+})diff --git a/packages/dashboard/e2e/policies.spec.ts b/packages/dashboard/e2e/policies.spec.tsnew file mode 100644index 0000000000..2d9e984918--- /dev/null+++ b/packages/dashboard/e2e/policies.spec.ts@@ -0,0 +1,67 @@+import { expect, type Page, test } from '@playwright/test'+import { gotoIndex, login, openRowMenu, rowButton } from './helpers'++const POLICIES_PATH = (storeId: string) => `/${storeId}/settings/policies`+const CTA = /add policy/i++async function createPolicy(page: Page, name: string) {+ await page.getByRole('button', { name: CTA }).click()+ await expect(page.getByRole('heading', { name: /^add policy$/i })).toBeVisible()+ await page.locator('#policy-name').fill(name)+ await page.getByRole('button', { name: /create policy/i }).click()+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })+}++test.describe('policies', () => {+ test('creates a policy whose address follows its name', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, POLICIES_PATH(creds.store_id), CTA)++ const suffix = Date.now()+ const name = `E2E Warranty ${suffix}`+ await createPolicy(page, name)++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row.getByText(`e2e-warranty-${suffix}`)).toBeVisible()+ // Nothing written yet, and the list says so rather than showing a blank.+ await expect(row.getByText(/nothing written yet/i)).toBeVisible()+ })++ test('writes the policy content', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, POLICIES_PATH(creds.store_id), CTA)++ const name = `E2E Shipping Policy ${Date.now()}`+ await createPolicy(page, name)++ await rowButton(page, name).click()+ await expect(page.locator('#policy-name')).toHaveValue(name, { timeout: 15_000 })+ const editor = page.locator('#policy-body')+ await editor.click()+ await editor.pressSequentially('Orders ship within two business days.')+ await page.getByRole('button', { name: /^save$/i }).click()++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row.getByText(/orders ship within two business days/i)).toBeVisible({+ timeout: 15_000,+ })+ })++ test('deletes a policy after confirming', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, POLICIES_PATH(creds.store_id), CTA)++ const name = `E2E Delete Policy ${Date.now()}`+ await createPolicy(page, name)++ await openRowMenu(page, name)+ await page.getByRole('menuitem', { name: /^delete$/i }).click()+ await expect(page.getByRole('heading', { name: /delete policy\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^delete$/i })+ .click()++ await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })+ })+})diff --git a/packages/dashboard/e2e/reasons.spec.ts b/packages/dashboard/e2e/reasons.spec.tsnew file mode 100644index 0000000000..00f5616500--- /dev/null+++ b/packages/dashboard/e2e/reasons.spec.ts@@ -0,0 +1,89 @@+import { expect, type Page, test } from '@playwright/test'+import { login, openRowMenu } from './helpers'++const REASONS_PATH = (storeId: string) => `/${storeId}/settings/reasons`++/** One of the four reason lists on the page, found by its card title. */+function reasonCard(page: Page, title: RegExp) {+ return page+ .locator('[data-slot="card"]')+ .filter({ has: page.locator('[data-slot="card-title"]', { hasText: title }) })+}++async function addReason(page: Page, cardTitle: RegExp, name: string) {+ await reasonCard(page, cardTitle)+ .getByRole('button', { name: /add reason/i })+ .click()+ await expect(page.getByRole('heading', { name: /^add reason$/i })).toBeVisible()+ await page.locator('#reason-name').fill(name)+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^create$/i })+ .click()+ await expect(reasonCard(page, cardTitle).getByText(name)).toBeVisible({ timeout: 15_000 })+}++test.describe('reasons', () => {+ test('lists the seeded vocabularies, one card per kind', async ({ page }) => {+ const creds = await login(page)+ await page.goto(REASONS_PATH(creds.store_id))++ await expect(page.getByRole('heading', { name: /returns & reasons/i })).toBeVisible({+ timeout: 15_000,+ })+ await expect(reasonCard(page, /^claim reasons$/i).getByText('Wrong item sent')).toBeVisible()+ await expect(+ reasonCard(page, /^return reasons$/i).getByText('Better price available'),+ ).toBeVisible()+ await expect(reasonCard(page, /^refund reasons$/i)).toBeVisible()+ await expect(reasonCard(page, /^order cancellation reasons$/i)).toBeVisible()+ })++ test('adds a reason to the list it was added from only', async ({ page }) => {+ const creds = await login(page)+ await page.goto(REASONS_PATH(creds.store_id))++ const name = `E2E Too small ${Date.now()}`+ await addReason(page, /^return reasons$/i, name)++ await expect(reasonCard(page, /^claim reasons$/i).getByText(name)).toHaveCount(0)+ })++ test('retires a reason so new records stop offering it', async ({ page }) => {+ const creds = await login(page)+ await page.goto(REASONS_PATH(creds.store_id))++ const name = `E2E Retired ${Date.now()}`+ await addReason(page, /^claim reasons$/i, name)++ await openRowMenu(page, name)+ await page.getByRole('menuitem', { name: /^edit$/i }).click()+ await expect(page.getByRole('heading', { name: /edit reason/i })).toBeVisible()+ await page.getByRole('switch', { name: /available on new records/i }).click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^save$/i })+ .click()++ const row = page.getByRole('row').filter({ hasText: name })+ await expect(row.getByText(/^inactive$/i)).toBeVisible({ timeout: 15_000 })+ })++ test('deletes an unused reason after confirming', async ({ page }) => {+ const creds = await login(page)+ await page.goto(REASONS_PATH(creds.store_id))++ const name = `E2E Doomed ${Date.now()}`+ await addReason(page, /^refund reasons$/i, name)++ await openRowMenu(page, name)+ await page.getByRole('menuitem', { name: /^delete$/i }).click()+ await expect(page.getByRole('heading', { name: /delete reason\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^delete$/i })+ .click()++ await expect(page.getByText(name)).toHaveCount(0, { timeout: 15_000 })+ })+})diff --git a/packages/dashboard/e2e/seller-requirements.spec.ts b/packages/dashboard/e2e/seller-requirements.spec.tsnew file mode 100644index 0000000000..cdac4e79fc--- /dev/null+++ b/packages/dashboard/e2e/seller-requirements.spec.ts@@ -0,0 +1,59 @@+import { expect, test } from '@playwright/test'+import { gotoIndex, login, openRowMenu, rowButton, waitForToastsToClear } from './helpers'++const REQUIREMENTS_PATH = (storeId: string) => `/${storeId}/settings/seller-requirements`+const CTA = /add requirement/i++test.describe('seller requirements', () => {+ test('lists the starting checklist every marketplace gets', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, REQUIREMENTS_PATH(creds.store_id), CTA)++ await expect(rowButton(page, 'Accept terms')).toBeVisible()+ })++ // One flow rather than three: a required requirement left behind would+ // stand between every later seller spec and approval, so the record this+ // creates is deleted before the test ends.+ test('adds a seller confirmation, switches it off, and deletes it', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, REQUIREMENTS_PATH(creds.store_id), CTA)++ const name = `E2E Licence ${Date.now()}`++ await page.getByRole('button', { name: CTA }).click()+ await expect(page.getByRole('heading', { name: /add a requirement/i })).toBeVisible()+ await page.getByLabel(/^type$/i).click()+ await page.getByRole('option', { name: /seller confirmation/i }).click()+ await page.getByLabel(/^name/i).fill(name)+ await page.getByLabel(/^instructions$/i).fill('Confirm you hold a trading licence.')+ await page.getByRole('switch', { name: /^required$/i }).click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^save$/i })+ .click()++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row).toBeVisible({ timeout: 15_000 })+ await expect(row.getByText(/seller confirmation/i)).toBeVisible()+ await expect(row.getByText(/^recommended$/i)).toBeVisible()++ await rowButton(page, name).click()+ await page.getByRole('switch', { name: /^active$/i }).click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^save$/i })+ .click()+ await expect(row.getByText(/^off$/i)).toBeVisible({ timeout: 15_000 })++ await waitForToastsToClear(page)+ await openRowMenu(page, name)+ await page.getByRole('menuitem', { name: /^delete$/i }).click()+ await expect(page.getByRole('heading', { name: /delete requirement\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^delete$/i })+ .click()+ await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })+ })+})diff --git a/packages/dashboard/e2e/settings-index.spec.ts b/packages/dashboard/e2e/settings-index.spec.tsnew file mode 100644index 0000000000..01a66d1709--- /dev/null+++ b/packages/dashboard/e2e/settings-index.spec.ts@@ -0,0 +1,42 @@+import { expect, test } from '@playwright/test'+import { login } from './helpers'++const SETTINGS_PATH = (storeId: string) => `/${storeId}/settings`++test.describe('settings index', () => {+ test('each card opens its settings page', async ({ page }) => {+ const creds = await login(page)+ await page.goto(SETTINGS_PATH(creds.store_id))++ const main = page.getByRole('main')+ await expect(main.getByRole('heading', { name: /^settings$/i })).toBeVisible({+ timeout: 15_000,+ })+ // The card, not the sidebar entry: the card's name carries its description.+ await main.getByRole('link', { name: /^tax rates rates applied/i }).click()++ await expect(page).toHaveURL(new RegExp(`${SETTINGS_PATH(creds.store_id)}/tax-rates`))+ await expect(page.getByRole('button', { name: /add tax rate/i })).toBeVisible({+ timeout: 15_000,+ })+ })++ // Below the desktop breakpoint the settings sidebar is gone, so the page's+ // own search is the only way to narrow the list.+ test('searches settings on a narrow screen', async ({ page }) => {+ await page.setViewportSize({ width: 390, height: 844 })+ const creds = await login(page)+ await page.goto(SETTINGS_PATH(creds.store_id))++ const main = page.getByRole('main')+ const search = main.getByRole('searchbox', { name: /search settings/i })+ await expect(search).toBeVisible({ timeout: 15_000 })++ await search.fill('webhook')+ await expect(main.getByRole('link', { name: /^webhooks/i })).toBeVisible()+ await expect(main.getByRole('link', { name: /^tax rates/i })).toHaveCount(0)++ await search.fill('zzz-nothing-matches')+ await expect(main.getByText(/no settings match/i)).toBeVisible()+ })+})diff --git a/packages/dashboard/e2e/staff.spec.ts b/packages/dashboard/e2e/staff.spec.tsnew file mode 100644index 0000000000..8863b1d624--- /dev/null+++ b/packages/dashboard/e2e/staff.spec.ts@@ -0,0 +1,144 @@+import { expect, type Page, request, test } from '@playwright/test'+import {+ type E2ELoginSession,+ escapeRegex,+ invitationAcceptancePath,+ login,+ openRowMenu,+} from './helpers'++const STAFF_PATH = (storeId: string) => `/${storeId}/settings/staff`++async function inviteFromDialog(page: Page, email: string) {+ await page.getByRole('button', { name: /invite teammate/i }).click()+ await page.locator('#invite-email').fill(email)+ await page.locator('#invite-role').click()+ await page.getByRole('option').first().click()+ await page.getByRole('button', { name: /send invitation/i }).click()+ await expect(page.getByRole('row').filter({ hasText: email })).toBeVisible({ timeout: 15_000 })+}++/**+ * Puts a second teammate on the store through the API: an invitation, then+ * its acceptance. Accepting signs the invitee in, so it happens in a request+ * context of its own — sharing the page's would swap the admin's session+ * cookie for the invitee's.+ */+async function addTeammate(page: Page, session: E2ELoginSession, email: string) {+ const headers = { Authorization: `Bearer ${session.accessToken}` }+ const roles = await page.request.get('/api/v3/admin/roles', { headers }).then((res) => res.json())+ const created = await page.request.post('/api/v3/admin/invitations', {+ headers,+ data: { email, role_id: roles.data[0].id },+ })+ expect(created.status(), await created.text()).toBe(201)+ const invitation = (await created.json()) as { id: string }++ const acceptance = new URL(+ await invitationAcceptancePath(page, session, `/api/v3/admin/invitations/${invitation.id}`),+ 'http://localhost',+ )+ const invitee = await request.newContext({ baseURL: new URL(page.url()).origin })+ try {+ const accepted = await invitee.post(`/api/v3/admin/auth/invitations/${invitation.id}/accept`, {+ data: {+ token: acceptance.searchParams.get('token'),+ password: 'e2e-password-123',+ password_confirmation: 'e2e-password-123',+ first_name: 'Robin',+ last_name: 'Teammate',+ },+ })+ expect(accepted.ok(), await accepted.text()).toBeTruthy()+ } finally {+ await invitee.dispose()+ }+}++test.describe('staff', () => {+ test('lists the signed-in admin as a member', async ({ page }) => {+ const creds = await login(page)+ await page.goto(STAFF_PATH(creds.store_id))++ await expect(+ page.getByRole('row', { name: new RegExp(escapeRegex(creds.admin_email), 'i') }),+ ).toBeVisible({ timeout: 15_000 })+ })++ test('an invitation needs a role', async ({ page }) => {+ const creds = await login(page)+ await page.goto(STAFF_PATH(creds.store_id))++ await page.getByRole('button', { name: /invite teammate/i }).click()+ await page.locator('#invite-email').fill(`e2e-no-role-${Date.now()}@example.com`)+ await page.getByRole('button', { name: /send invitation/i }).click()++ await expect(page.getByRole('alert').filter({ hasText: /pick a role/i })).toBeVisible()+ })++ test('resends a pending invitation', async ({ page }) => {+ const creds = await login(page)+ await page.goto(STAFF_PATH(creds.store_id))++ const email = `e2e-resend-${Date.now()}@example.com`+ await inviteFromDialog(page, email)++ await openRowMenu(page, email)+ await page.getByRole('menuitem', { name: /^resend$/i }).click()+ await expect(page.getByText(/invitation resent/i)).toBeVisible({ timeout: 15_000 })+ })++ test('revokes a pending invitation after confirming', async ({ page }) => {+ const creds = await login(page)+ await page.goto(STAFF_PATH(creds.store_id))++ const email = `e2e-revoke-${Date.now()}@example.com`+ await inviteFromDialog(page, email)++ await openRowMenu(page, email)+ await page.getByRole('menuitem', { name: /^revoke$/i }).click()+ await expect(page.getByRole('heading', { name: /revoke invitation\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^revoke$/i })+ .click()++ await expect(page.getByRole('row').filter({ hasText: email })).toHaveCount(0, {+ timeout: 15_000,+ })+ })++ test('renames a teammate and then removes them from the store', async ({ page }) => {+ const session = await login(page)+ const email = `e2e-teammate-${Date.now()}@example.com`+ await addTeammate(page, session, email)++ await page.goto(STAFF_PATH(session.store_id))+ await expect(page.getByRole('row').filter({ hasText: email })).toBeVisible({+ timeout: 15_000,+ })++ await openRowMenu(page, email)+ await page.getByRole('menuitem', { name: /^edit$/i }).click()+ await page.locator('#staff-first-name').fill('Morgan')+ await page.getByRole('button', { name: /^save$/i }).click()+ await expect(+ page+ .getByRole('row')+ .filter({ hasText: email })+ .getByText(/morgan/i),+ ).toBeVisible({ timeout: 15_000 })++ await openRowMenu(page, email)+ await page.getByRole('menuitem', { name: /remove from staff/i }).click()+ await expect(page.getByRole('heading', { name: /remove from store\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^remove$/i })+ .click()++ await expect(page.getByRole('row').filter({ hasText: email })).toHaveCount(0, {+ timeout: 15_000,+ })+ })+})diff --git a/packages/dashboard/e2e/tax-rates.spec.ts b/packages/dashboard/e2e/tax-rates.spec.tsnew file mode 100644index 0000000000..5149641c80--- /dev/null+++ b/packages/dashboard/e2e/tax-rates.spec.ts@@ -0,0 +1,89 @@+import { expect, type Page, test } from '@playwright/test'+import { gotoIndex, login, openRowMenu, rowButton } from './helpers'++const TAX_RATES_PATH = (storeId: string) => `/${storeId}/settings/tax-rates`+const CTA = /add tax rate/i++async function createTaxRate(+ page: Page,+ attrs: { name: string; amount: string; country?: string },+) {+ await page.getByRole('button', { name: CTA }).click()+ await expect(page.getByRole('heading', { name: /new tax rate/i })).toBeVisible()++ await page.locator('#name').fill(attrs.name)+ await page.locator('#amount_percentage').fill(attrs.amount)+ // The seeded store always carries a `Default` tax category.+ await page.locator('#tax_category_id').click()+ await page.getByRole('option', { name: /^default$/i }).click()++ if (attrs.country) {+ await page.getByRole('combobox', { name: /^country$/i }).click()+ await page.getByPlaceholder(/^search countries/i).fill(attrs.country)+ await page.getByRole('option', { name: attrs.country }).first().click()+ }++ await page.getByRole('button', { name: /create tax rate/i }).click()+}++test.describe('tax rates', () => {+ test('asks for a tax category before creating a rate', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, TAX_RATES_PATH(creds.store_id), CTA)++ await page.getByRole('button', { name: CTA }).click()+ await page.locator('#name').fill(`E2E Uncategorised ${Date.now()}`)+ await page.getByRole('button', { name: /create tax rate/i }).click()++ await expect(page.locator('#tax_category_id')).toHaveAttribute('aria-invalid', 'true')+ })++ test('creates a rate for one country and shows it as a percentage', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, TAX_RATES_PATH(creds.store_id), CTA)++ const name = `E2E VAT ${Date.now()}`+ await createTaxRate(page, { name, amount: '21', country: 'Spain' })++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row).toBeVisible({ timeout: 15_000 })+ await expect(row.getByText('21%')).toBeVisible()+ await expect(row.getByText(/spain/i)).toBeVisible()+ })++ test('edits a rate', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, TAX_RATES_PATH(creds.store_id), CTA)++ const name = `E2E Edit Rate ${Date.now()}`+ await createTaxRate(page, { name, amount: '10' })+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })++ await rowButton(page, name).click()+ await expect(page.locator('#amount_percentage')).toHaveValue('10', { timeout: 15_000 })+ await page.locator('#amount_percentage').fill('12.5')+ await page.getByRole('button', { name: /^save$/i }).click()++ const row = page.getByRole('row').filter({ has: rowButton(page, name) })+ await expect(row.getByText('12.5%')).toBeVisible({ timeout: 15_000 })+ })++ test('deletes a rate after confirming', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, TAX_RATES_PATH(creds.store_id), CTA)++ const name = `E2E Delete Rate ${Date.now()}`+ await createTaxRate(page, { name, amount: '5' })+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })++ await openRowMenu(page, name)+ await page.getByRole('menuitem', { name: /^delete$/i }).click()+ await expect(page.getByRole('heading', { name: /delete tax rate\?/i })).toBeVisible()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^delete$/i })+ .click()++ await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })+ })+})diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/seller-requirements.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/seller-requirements.tsxindex 003d51be76..268aabda4c 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/seller-requirements.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/seller-requirements.tsx@@ -38,7 +38,7 @@ import {import { PlusIcon } from '@spree/dashboard-ui/icons'import { useQueryClient } from '@tanstack/react-query'import { createFileRoute, useNavigate } from '@tanstack/react-router'-import { useMemo, useState } from 'react'+import { useId, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { z } from 'zod'import { customFieldDefinitionAutocompleteProps } from '../../../../hooks/use-custom-field-definitions'@@ -238,9 +238,11 @@ function CreateRequirementSheet({)}<FieldGroup><Field>- <FieldLabel>{t('admin.seller_requirements.fields.kind.label')}</FieldLabel>+ <FieldLabel htmlFor="seller-requirement-kind">+ {t('admin.seller_requirements.fields.kind.label')}+ </FieldLabel><Select items={selectItems} value={type} onValueChange={handleTypeChange}>- <SelectTrigger disabled={isLoading}>+ <SelectTrigger id="seller-requirement-kind" disabled={isLoading}><SelectValueplaceholder={t('admin.seller_requirements.fields.kind.placeholder')}/>@@ -497,12 +499,13 @@ function RequirementFields({<Field>{/* A kind that can appear more than once has nothing else to tell itapart by, so its label is the operator's own wording. */}- <FieldLabel>+ <FieldLabel htmlFor="seller-requirement-name">{kindEntry.allow_multiple? t('admin.seller_requirements.fields.name.label_required'): t('admin.seller_requirements.fields.name.label')}</FieldLabel><Input+ id="seller-requirement-name"value={values.name}onChange={(event) => onChange.setName(event.target.value)}placeholder={typeLabel('seller_requirement', kindEntry.type, kindEntry.name)}@@ -513,8 +516,11 @@ function RequirementFields({</Field><Field>- <FieldLabel>{t('admin.seller_requirements.fields.description.label')}</FieldLabel>+ <FieldLabel htmlFor="seller-requirement-description">+ {t('admin.seller_requirements.fields.description.label')}+ </FieldLabel><Textarea+ id="seller-requirement-description"value={values.description}onChange={(event) => onChange.setDescription(event.target.value)}placeholder={t('admin.seller_requirements.fields.description.placeholder')}@@ -581,13 +587,17 @@ function SettingSwitch({value: booleanonChange: (value: boolean) => void}) {+ const id = useId()+return (<div className="flex items-center justify-between gap-3"><div className="flex flex-col">- <span className="font-medium text-sm">{label}</span>+ <label htmlFor={id} className="font-medium text-sm">+ {label}+ </label><span className="text-muted-foreground text-xs">{description}</span></div>- <Switch checked={value} onCheckedChange={onChange} />+ <Switch id={id} checked={value} onCheckedChange={onChange} /></div>)}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/tax-rates.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/tax-rates.tsxindex 3dac6c32fc..d166c74f83 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/tax-rates.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/tax-rates.tsx@@ -378,6 +378,7 @@ function TaxRateFormFields({ form }: { form: UseFormReturn<TaxRateFormValues> })control={form.control}render={({ field }) => (<CountryCombobox+ id="country_code"value={field.value}onValueChange={(iso) => {field.onChange(iso)@@ -400,6 +401,7 @@ function TaxRateFormFields({ form }: { form: UseFormReturn<TaxRateFormValues> })control={form.control}render={({ field }) => (<StateCombobox+ id="state_code"countryCode={countryCode}value={field.value}onValueChange={field.onChange}