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 coverage for typed preferences
Damian Legawiecbc73b5894107
diff --git a/packages/dashboard/e2e/channels-settings.spec.ts b/packages/dashboard/e2e/channels-settings.spec.tsindex 8ab2cbf6f2..bc27c48f5f 100644--- a/packages/dashboard/e2e/channels-settings.spec.ts+++ b/packages/dashboard/e2e/channels-settings.spec.ts@@ -95,6 +95,52 @@ test.describe('settings / channels', () => {await expect(page.locator('#order_routing_strategy')).toContainText(/^rules \(ordered\)$/i)})+ // A channel's storefront access and guest checkout override the store's+ // until cleared back to "inherit", which must store nothing rather than a+ // blank that reads as an override.+ test('overrides store settings per channel and clears them back to inherit', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)++ const name = `E2E Channel Overrides ${Date.now()}`+ await createChannel(page, { name })+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })++ const access = page.locator('#storefront_access')+ const guestCheckout = page.locator('#guest_checkout')+ const save = page.getByRole('button', { name: /^save$/i })++ async function reopen() {+ await expect(page.getByRole('heading', { name })).toHaveCount(0, { timeout: 15_000 })+ await rowButton(page, name).click()+ await expect(page.getByRole('heading', { name })).toBeVisible({ timeout: 15_000 })+ }++ await rowButton(page, name).click()+ await expect(access).toContainText(/^inherit from store$/i, { timeout: 15_000 })+ await expect(guestCheckout).toContainText(/^inherit from store$/i)++ await access.click()+ await page.getByRole('option', { name: /^login required/i }).click()+ await guestCheckout.click()+ await page.getByRole('option', { name: /^not allowed$/i }).click()+ await save.click()++ await reopen()+ await expect(access).toContainText(/^login required/i)+ await expect(guestCheckout).toContainText(/^not allowed$/i)++ await access.click()+ await page.getByRole('option', { name: /^inherit from store$/i }).click()+ await guestCheckout.click()+ await page.getByRole('option', { name: /^inherit from store$/i }).click()+ await save.click()++ await reopen()+ await expect(access).toContainText(/^inherit from store$/i)+ await expect(guestCheckout).toContainText(/^inherit from store$/i)+ })+test('names the default catalog picker for assistive technology', async ({ page }) => {const creds = await login(page)await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)diff --git a/packages/dashboard/e2e/commission-rates.spec.ts b/packages/dashboard/e2e/commission-rates.spec.tsindex 66550bd7ae..416fa03386 100644--- a/packages/dashboard/e2e/commission-rates.spec.ts+++ b/packages/dashboard/e2e/commission-rates.spec.ts@@ -1,5 +1,13 @@import { expect, type Page, test } from '@playwright/test'-import { gotoIndex, login, openRowMenu, rowButton, waitForToastsToClear } from './helpers'+import {+ FIXTURE_LEDGER_SELLER,+ FIXTURE_PROMO_TAXON,+ gotoIndex,+ login,+ openRowMenu,+ rowButton,+ waitForToastsToClear,+} from './helpers'const COMMISSION_RATES_PATH = (storeId: string) => `/${storeId}/sellers/commission-rates`const CTA = /add commission rate/i@@ -77,6 +85,41 @@ test.describe('commission rates', () => {await expect(page.locator('#commission_tax_rate')).toHaveValue('7.125')})+ // Seller and category conditions keep prefixed ids in their preferences,+ // so reopening must name the same records that were picked.+ test('saves seller and category conditions and reopens with them', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, COMMISSION_RATES_PATH(creds.store_id), CTA)++ const name = `E2E Commission Conditions ${Date.now()}`+ await page.getByRole('button', { name: CTA }).click()+ const sheet = page.getByRole('dialog')+ await page.locator('#name').fill(name)+ await page.locator('#value').fill('8')++ await sheet.getByRole('button', { name: /^add condition$/i }).click()+ await page.getByRole('menuitem', { name: /^seller$/i }).click()+ await sheet.getByPlaceholder(/search sellers/i).fill(FIXTURE_LEDGER_SELLER)+ await page.getByRole('option', { name: FIXTURE_LEDGER_SELLER }).click()++ await sheet.getByRole('button', { name: /^add condition$/i }).click()+ await page.getByRole('menuitem', { name: /^category$/i }).click()+ await sheet.getByPlaceholder(/search categories/i).fill(FIXTURE_PROMO_TAXON)+ await page+ .getByRole('option', { name: new RegExp(FIXTURE_PROMO_TAXON) })+ .first()+ .click()++ await page.getByRole('button', { name: /create commission rate/i }).click()+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })++ await page.reload()+ await rowButton(page, name).click()+ await expect(page.locator('#value')).toHaveValue(/^8(\.0+)?$/, { timeout: 15_000 })+ await expect(sheet.getByText(FIXTURE_LEDGER_SELLER)).toBeVisible()+ await expect(sheet.getByText(FIXTURE_PROMO_TAXON).first()).toBeVisible()+ })+test('deletes a rate after confirming', async ({ page }) => {const creds = await login(page)await gotoIndex(page, COMMISSION_RATES_PATH(creds.store_id), CTA)diff --git a/packages/dashboard/e2e/delivery-settings.spec.ts b/packages/dashboard/e2e/delivery-settings.spec.tsindex 4b16db8193..b1a01dc83f 100644--- a/packages/dashboard/e2e/delivery-settings.spec.ts+++ b/packages/dashboard/e2e/delivery-settings.spec.ts@@ -1,5 +1,5 @@import { expect, type Locator, type Page, test } from '@playwright/test'-import { gotoIndex, login } from './helpers'+import { FIXTURE_BULK_CHANNEL_NAME, gotoIndex, login } from './helpers'const DELIVERY_PROFILES_PATH = (storeId: string) => `/${storeId}/settings/delivery-profiles`const PROFILE_CTA = /add profile/i@@ -157,6 +157,79 @@ test.describe('delivery profiles', () => {await expect(reopened.locator('[id^="calculator-amount-"]').first()).toHaveValue(/7\.50|7\.5/)})+ // A method's settings are typed: each currency keeps its own amount, the+ // eligibility rules keep theirs, and switching the calculator starts over+ // from the new one's defaults instead of carrying the old one's keys.+ test('keeps per-currency amounts and conditions, and resets settings when the calculator changes', async ({+ page,+ }) => {+ const creds = await login(page)+ await gotoIndex(page, DELIVERY_PROFILES_PATH(creds.store_id), PROFILE_CTA)++ const stamp = Date.now()+ const methodName = `E2E Typed ${stamp}`+ await createProfile(page, `E2E Typed Profile ${stamp}`)++ await page+ .getByRole('button', { name: /add method/i })+ .first()+ .click()+ const sheet = page.getByRole('dialog')+ await sheet.locator('#name').fill(methodName)++ const calculator = sheet.locator('#calculator-type')+ await expect(calculator).toBeEnabled({ timeout: 15_000 })+ await calculator.click()+ await page.getByRole('option', { name: /^flat rate$/i }).click()+ await sheet.locator('#calculator-amount-USD').fill('5.00')+ await sheet.locator('#calculator-amount-EUR').fill('4.50')++ await sheet.getByRole('button', { name: /^add condition$/i }).click()+ await page.getByRole('menuitem', { name: /^channel$/i }).click()+ await sheet.getByPlaceholder(/search sales channels/i).fill(FIXTURE_BULK_CHANNEL_NAME)+ await page.getByRole('option', { name: FIXTURE_BULK_CHANNEL_NAME }).click()++ await sheet.getByRole('button', { name: /^add condition$/i }).click()+ await page.getByRole('menuitem', { name: /^item total$/i }).click()+ await sheet.locator('#preference-minimum_amount').fill('25')++ await page.getByRole('button', { name: /create delivery method/i }).click()+ await expect(page.getByRole('heading', { name: /new delivery method/i })).toHaveCount(0, {+ timeout: 15_000,+ })++ // Both conditions and both amounts come back as saved.+ await page.getByText(methodName).click()+ await expect(sheet.locator('#calculator-amount-USD')).toHaveValue(/^5(\.0+)?$/, {+ timeout: 15_000,+ })+ await expect(sheet.locator('#calculator-amount-EUR')).toHaveValue(/^4\.50?$/)+ await expect(sheet.getByText(FIXTURE_BULK_CHANNEL_NAME)).toBeVisible()+ await expect(sheet.locator('#preference-minimum_amount')).toHaveValue(/^25(\.0+)?$/)++ // Changing one currency leaves the other alone.+ await sheet.locator('#calculator-amount-USD').fill('6.25')+ await sheet.getByRole('button', { name: /^save$/i }).click()+ await expect(sheet).toHaveCount(0, { timeout: 15_000 })+ await page.getByText(methodName).click()+ await expect(sheet.locator('#calculator-amount-USD')).toHaveValue('6.25', { timeout: 15_000 })+ await expect(sheet.locator('#calculator-amount-EUR')).toHaveValue(/^4\.50?$/)++ // A different calculator starts from its own defaults.+ await calculator.click()+ await page.getByRole('option', { name: /^flexi rate$/i }).click()+ await expect(sheet.locator('#calculator-amount-USD')).toHaveCount(0)+ await expect(sheet.locator('#preference-first_item')).toHaveValue(/^0(\.0+)?$/)+ await sheet.locator('#preference-first_item').fill('3.00')+ await sheet.getByRole('button', { name: /^save$/i }).click()+ await expect(sheet).toHaveCount(0, { timeout: 15_000 })++ await page.getByText(methodName).click()+ await expect(calculator).toContainText(/flexi rate/i, { timeout: 15_000 })+ await expect(sheet.locator('#preference-first_item')).toHaveValue(/^3(\.0+)?$/)+ await expect(sheet.getByText(FIXTURE_BULK_CHANNEL_NAME)).toBeVisible()+ })+// Opening a method is a search-param change, so the sheet must survive a// reload and a direct link — that is what keeps bookmarked methods working.test('opens the method sheet straight from a URL', async ({ page }) => {diff --git a/packages/dashboard/e2e/global-setup.ts b/packages/dashboard/e2e/global-setup.tsindex 04c912d20b..51d575d334 100644--- a/packages/dashboard/e2e/global-setup.ts+++ b/packages/dashboard/e2e/global-setup.ts@@ -43,7 +43,12 @@ import {FIXTURE_TRANSFER_SKU,FIXTURE_TRANSFER_SOURCE,} from './helpers'-import { ASYNC_JOBS_INITIALIZER, CREDENTIALS_FILE, RAILS_PID_FILE } from './paths'+import {+ ASYNC_JOBS_INITIALIZER,+ CREDENTIALS_FILE,+ RAILS_PID_FILE,+ TEST_INTEGRATION_INITIALIZER,+} from './paths'import { API_GEM_DIR, rmIfExists, runRailsBootstrap, startRails } from './rails'const PORT = process.env.E2E_RAILS_PORT || '3010'@@ -196,6 +201,32 @@ export default async function globalSetup() {].join('\n'),)+ // One setting of each kind the connect form renders, so the integrations+ // spec can prove each saves and reads back. Registered after Spree's own+ // integrations list is set up, the way a provider gem registers its own.+ writeFileSync(+ TEST_INTEGRATION_INITIALIZER,+ [+ '# Written by packages/dashboard/e2e/global-setup.ts — safe to delete.',+ "if ENV['DASHBOARD_E2E'] == '1'",+ ' Rails.application.config.after_initialize do',+ ' unless defined?(::E2eRelay)',+ ' class ::E2eRelay < Spree::Integration',+ ' preference :account_id, :string',+ ' preference :api_secret, :password',+ ' preference :sync_interval, :integer, default: 15',+ ' preference :sandbox_mode, :boolean, default: true',+ '',+ " def self.integration_name = 'E2E Relay'",+ ' end',+ ' end',+ " Spree.integrations << 'E2eRelay' unless Spree.integrations.include?('E2eRelay')",+ ' end',+ 'end',+ '',+ ].join('\n'),+ )+const credentials = runRailsBootstrap(BOOTSTRAP_RUBY, RAILS_ENV)writeFileSync(CREDENTIALS_FILE, credentials)diff --git a/packages/dashboard/e2e/global-teardown.ts b/packages/dashboard/e2e/global-teardown.tsindex 9656186a23..83302035c3 100644--- a/packages/dashboard/e2e/global-teardown.ts+++ b/packages/dashboard/e2e/global-teardown.ts@@ -1,7 +1,8 @@-import { ASYNC_JOBS_INITIALIZER, RAILS_PID_FILE } from './paths'+import { ASYNC_JOBS_INITIALIZER, RAILS_PID_FILE, TEST_INTEGRATION_INITIALIZER } from './paths'import { rmIfExists, stopRails } from './rails'export default async function globalTeardown() {rmIfExists(ASYNC_JOBS_INITIALIZER)+ rmIfExists(TEST_INTEGRATION_INITIALIZER)await stopRails(RAILS_PID_FILE)}diff --git a/packages/dashboard/e2e/imports.spec.ts b/packages/dashboard/e2e/imports.spec.tsindex c60e6f4cde..1c677b7777 100644--- a/packages/dashboard/e2e/imports.spec.ts+++ b/packages/dashboard/e2e/imports.spec.ts@@ -83,6 +83,45 @@ test.describe('csv import', () => {await expect(page.getByText(goodName)).toBeVisible({ timeout: 15_000 })})+ // The column separator travels as the import's `delimiter` setting; a+ // semicolon file only maps and imports if the server read it back.+ test('imports a semicolon-separated file', async ({ page }) => {+ test.setTimeout(180_000)++ const creds = await login(page)+ const suffix = Date.now()+ const name = `E2E Semicolon Product ${suffix}`++ await openImportSheet(page, creds.store_id)+ const sheet = page.getByRole('dialog')+ await sheet+ .locator('[data-slot="field"]')+ .filter({ hasText: /^column separator/i })+ .getByRole('combobox')+ .click()+ await page.getByRole('option', { name: /^semicolon/i }).click()+ await sheet+ .locator('input[type="file"]')+ .setInputFiles(+ csvFile([+ 'slug;sku;name;price',+ `e2e-semicolon-${suffix};E2E-SEMI-${suffix};${name};12.00`,+ ]),+ )+ await page.getByRole('button', { name: /^continue$/i }).click()++ // Split on the semicolon, every column is its own field with its own+ // sample — read as commas, the whole line would be a single column.+ await expect(page.getByText('Map columns')).toBeVisible({ timeout: 15_000 })+ await expect(page.getByText(`E2E-SEMI-${suffix}`, { exact: true })).toBeVisible()++ await page.getByRole('button', { name: /start import/i }).click()+ await expect(page.getByText(/import completed/i)).toBeVisible({ timeout: 120_000 })++ await page.getByRole('button', { name: /view products/i }).click()+ await expect(page.getByText(name)).toBeVisible({ timeout: 15_000 })+ })+test('blocks starting until required fields are mapped', async ({ page }) => {const creds = await login(page)const suffix = Date.now()diff --git a/packages/dashboard/e2e/integrations.spec.ts b/packages/dashboard/e2e/integrations.spec.tsindex 272a441f24..3448101d50 100644--- a/packages/dashboard/e2e/integrations.spec.ts+++ b/packages/dashboard/e2e/integrations.spec.ts@@ -46,6 +46,68 @@ test.describe('integrations', () => {await expect(page.getByRole('switch', { name: /store credit/i })).toHaveCount(0)})+ // `E2E Relay` is registered by global-setup for this test: one setting of+ // each kind, each of which must save and come back as itself, with the+ // secret only ever returned as a mask.+ test('connects an integration and keeps its settings', async ({ page }) => {+ const creds = await login(page)+ await page.goto(INTEGRATIONS_PATH(creds.store_id))++ const card = page.locator('[data-slot="card"]').filter({ hasText: 'E2E Relay' })+ const sheet = page.getByRole('dialog')+ const accountId = sheet.locator('#preference-account_id')+ const secret = sheet.locator('#preference-api_secret')+ const interval = sheet.locator('#preference-sync_interval')+ const sandbox = sheet.getByRole('switch', { name: /^sandbox mode$/i })++ await card.getByRole('button', { name: /^connect$/i }).click()+ await expect(sheet.getByRole('heading', { name: 'E2E Relay' })).toBeVisible({+ timeout: 15_000,+ })+ // A new connection starts from the declared defaults.+ await expect(interval).toHaveValue('15')+ await expect(sandbox).toBeChecked()++ await accountId.fill('acct-e2e')+ await secret.fill('relay-secret-4321')+ await interval.fill('30')+ await sandbox.click()+ await sheet.getByRole('button', { name: /^connect$/i }).click()+ await expect(sheet).toHaveCount(0, { timeout: 15_000 })++ async function reopen() {+ await card.getByRole('button', { name: /^configure$/i }).click()+ await expect(sheet.getByRole('heading', { name: 'E2E Relay' })).toBeVisible({+ timeout: 15_000,+ })+ }++ await reopen()+ await expect(accountId).toHaveValue('acct-e2e')+ await expect(secret).toHaveText(/^•+4321$/)+ await expect(interval).toHaveValue('30')+ await expect(sandbox).not.toBeChecked()++ // Saving with the secret untouched keeps it.+ await accountId.fill('acct-e2e-2')+ await sheet.getByRole('button', { name: /^save$/i }).click()+ await expect(sheet).toHaveCount(0, { timeout: 15_000 })++ await page.reload()+ await reopen()+ await expect(accountId).toHaveValue('acct-e2e-2')+ await expect(secret).toHaveText(/^•+4321$/)+ await expect(interval).toHaveValue('30')++ await sheet.getByRole('button', { name: /^disconnect$/i }).click()+ await page+ .getByRole('alertdialog')+ .or(page.getByRole('dialog', { name: /disconnect integration/i }))+ .getByRole('button', { name: /^disconnect$/i })+ .click()+ await expect(card.getByRole('button', { name: /^connect$/i })).toBeVisible({ timeout: 15_000 })+ })+// Setting up a provider from its card already says which provider, so the// add sheet skips the provider picker.test('opens the add sheet for the chosen provider without a provider picker', async ({diff --git a/packages/dashboard/e2e/paths.ts b/packages/dashboard/e2e/paths.tsindex 5531d84839..4808b9b07b 100644--- a/packages/dashboard/e2e/paths.ts+++ b/packages/dashboard/e2e/paths.ts@@ -10,6 +10,13 @@ export const ASYNC_JOBS_INITIALIZER = resolve(E2E_DIR,'../../../spree/api/spec/dummy/config/initializers/zz_dashboard_e2e_async_jobs.rb',)+// A third-party integration for the integrations specs to configure. Core+// ships none, and only provider gems the test app does not install register+// one. Written and removed alongside the file above.+export const TEST_INTEGRATION_INITIALIZER = resolve(+ E2E_DIR,+ '../../../spree/api/spec/dummy/config/initializers/zz_dashboard_e2e_integration.rb',+)// The first-run setup suite runs its own Rails against its own database, so// its state files live apart from the main suite's.export const FIRST_RUN_CREDENTIALS_FILE = resolve(E2E_DIR, '.first-run.json')diff --git a/packages/dashboard/e2e/payment-methods.spec.ts b/packages/dashboard/e2e/payment-methods.spec.tsindex a95c7f0774..b1eb34fb2a 100644--- a/packages/dashboard/e2e/payment-methods.spec.ts+++ b/packages/dashboard/e2e/payment-methods.spec.ts@@ -68,7 +68,9 @@ test.describe('payment methods', () => {await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })})- test('creates a new payment method (Bogus provider)', async ({ page }) => {+ test('creates a payment method with provider settings, keeping its secret on edit', async ({+ page,+ }) => {const creds = await login(page)await gotoIndex(page, PAYMENT_METHODS_PATH(creds.store_id), CTA)@@ -79,9 +81,40 @@ test.describe('payment methods', () => {await selectProvider(page, 'Bogus')await page.locator('#name').fill(name)+ await page.locator('#preference-dummy_key').fill('E2EPUBLIC')+ await page.locator('#preference-dummy_secret_key').fill('e2e-secret-9876')await page.getByRole('button', { name: /create payment method/i }).click()await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })++ // The installed provider's settings come back on edit: the plain one as+ // typed, the secret only as a mask of its last characters.+ await rowButton(page, name).click()+ await expect(page.locator('#preference-dummy_key')).toHaveValue('E2EPUBLIC', {+ timeout: 15_000,+ })+ const secret = page.locator('#preference-dummy_secret_key')+ await expect(secret).toHaveText(/^•+9876$/)++ // Saving without touching the secret keeps it.+ const updated = `${name} (updated)`+ await page.locator('#name').fill(updated)+ await page.getByRole('button', { name: /^save$/i }).click()+ await expect(rowButton(page, updated)).toBeVisible({ timeout: 15_000 })++ await page.reload()+ await rowButton(page, updated).click()+ await expect(page.locator('#preference-dummy_key')).toHaveValue('E2EPUBLIC', {+ timeout: 15_000,+ })+ await expect(secret).toHaveText(/^•+9876$/)+ await page.keyboard.press('Escape')++ // A provider is installed once per store, so the picker stops offering it.+ await page.getByRole('button', { name: /add payment method/i }).click()+ await page.locator('#type').click()+ await expect(page.getByRole('option', { name: 'Check' })).toBeVisible()+ await expect(page.getByRole('option', { name: 'Bogus' })).toHaveCount(0)})test('edits a payment method', async ({ page }) => {diff --git a/packages/dashboard/e2e/promotions.spec.ts b/packages/dashboard/e2e/promotions.spec.tsindex d883a8fbcc..40646f15b9 100644--- a/packages/dashboard/e2e/promotions.spec.ts+++ b/packages/dashboard/e2e/promotions.spec.ts@@ -1,5 +1,6 @@import { expect, type Page, test } from '@playwright/test'import {+ FIXTURE_BULK_CHANNEL_NAME,FIXTURE_PROMO_COUNTRY,FIXTURE_PROMO_CUSTOMER_FIRST_NAME,FIXTURE_PROMO_CUSTOMER_FULL_NAME,@@ -241,6 +242,38 @@ test.describe('promotions', () => {await submitCreate(page, name)})+ // Both rules keep prefixed ids in their preferences; reloading proves they+ // were saved and read back as the records they name.+ test('creates a promotion with Channel and Market rules', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, PROMOTIONS_PATH(creds.store_id), CTA)++ const name = `E2E Channel Market Promo ${Date.now()}`+ await startNewPromotion(page, creds.store_id, name)++ await pickRule(page, /^channel\(s\)/i)+ await expect(page.getByRole('heading', { name: /^channel\(s\)$/i })).toBeVisible({+ timeout: 5_000,+ })+ await pickAutocompleteOption(page, /search sales channels/i, FIXTURE_BULK_CHANNEL_NAME)+ await saveEditor(page)++ await pickRule(page, /^market\(s\)/i)+ await expect(page.getByRole('heading', { name: /^market\(s\)$/i })).toBeVisible({+ timeout: 5_000,+ })+ await pickAutocompleteOption(page, /search markets/i, 'Europe')+ await saveEditor(page)++ await submitCreate(page, name)++ await page.reload()+ await expect(page.getByText(FIXTURE_BULK_CHANNEL_NAME).first()).toBeVisible({+ timeout: 15_000,+ })+ await expect(page.getByText('Europe', { exact: true }).first()).toBeVisible()+ })+test('creates a promotion with a Product rule', async ({ page }) => {const creds = await login(page)await gotoIndex(page, PROMOTIONS_PATH(creds.store_id), CTA)diff --git a/packages/dashboard/e2e/seller-requirements.spec.ts b/packages/dashboard/e2e/seller-requirements.spec.tsindex cdac4e79fc..322092dd8a 100644--- a/packages/dashboard/e2e/seller-requirements.spec.ts+++ b/packages/dashboard/e2e/seller-requirements.spec.ts@@ -56,4 +56,60 @@ test.describe('seller requirements', () => {.click()await expect(rowButton(page, name)).toHaveCount(0, { timeout: 15_000 })})++ // Settings of a kind are typed: a whole number, a URL and a date each save+ // and come back as themselves. Both requirements are part of every+ // marketplace's starting checklist, so each is put back afterwards.+ test('saves the settings of a kind and reads them back', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, REQUIREMENTS_PATH(creds.store_id), CTA)+ const sheet = page.getByRole('dialog')+ const save = sheet.getByRole('button', { name: /^save$/i })++ async function open(name: string) {+ await expect(sheet).toHaveCount(0, { timeout: 15_000 })+ await rowButton(page, name).click()+ await expect(sheet).toBeVisible({ timeout: 15_000 })+ }++ await open('Minimum products')+ const count = page.locator('#preference-minimum_count')+ await expect(count).not.toHaveValue('', { timeout: 15_000 })+ const originalCount = await count.inputValue()+ await count.fill('3')+ await save.click()+ await open('Minimum products')+ await expect(count).toHaveValue('3')+ await count.fill(originalCount)+ await save.click()++ await open('Accept terms')+ const url = page.locator('#preference-terms_url')+ const effectiveFrom = page.locator('#preference-terms_effective_from')+ await url.fill('https://example.com/e2e-terms')+ // A date in the past, so sellers who already accepted still count as met.+ await effectiveFrom.click()+ await sheet.getByRole('button', { name: /previous month/i }).click()+ await sheet.getByRole('gridcell', { name: '15' }).click()+ await save.click()++ await open('Accept terms')+ await expect(url).toHaveValue('https://example.com/e2e-terms')+ await expect(effectiveFrom).toContainText('15')++ await url.fill('')+ await effectiveFrom.getByRole('button', { name: /clear date/i }).click()+ await save.click()+ await open('Accept terms')+ await expect(url).toHaveValue('')+ await expect(effectiveFrom).toHaveAttribute('data-empty', 'true')+ await sheet.getByRole('button', { name: /^cancel$/i }).click()++ // And it was stored, not only shown.+ await page.reload()+ await open('Accept terms')+ await expect(url).toHaveValue('')+ await expect(effectiveFrom).toHaveAttribute('data-empty', 'true')+ await sheet.getByRole('button', { name: /^cancel$/i }).click()+ })})diff --git a/packages/dashboard/e2e/store-settings.spec.ts b/packages/dashboard/e2e/store-settings.spec.tsindex b4a4bbfab7..ad7afbcf87 100644--- a/packages/dashboard/e2e/store-settings.spec.ts+++ b/packages/dashboard/e2e/store-settings.spec.ts@@ -135,6 +135,84 @@ test.describe('store settings — general', () => {timeout: 15_000,})})+ // These settings are written under their plain names (`timezone`,+ // `guest_checkout`, …) since preferences became a typed contract; each must+ // still save and come back after a reload.+ test('saves standards, storefront access, order numbers and payments, and they survive a reload', async ({+ page,+ }) => {+ const creds = await login(page)+ await page.goto(STORE_PATH(creds.store_id))+ const timezone = page.locator('#store-timezone')+ const storefrontAccess = page.locator('#store-storefront-access')+ const guestCheckout = page.getByRole('switch', { name: /^guest checkout/i })+ const prefix = page.locator('#store-order-number-prefix')+ const captureRadios = page.getByRole('radio')+ const onDispatch = page.getByRole('radio', { name: /on dispatch/i })+ // The form fills from the store once it loads; wait for that before editing.+ await expect(prefix).not.toHaveValue('', { timeout: 15_000 })++ const original = {+ timezone: (await timezone.textContent())?.trim() ?? '',+ storefrontAccess: (await storefrontAccess.textContent())?.trim() ?? '',+ guestCheckout: (await guestCheckout.getAttribute('aria-checked')) === 'true',+ prefix: await prefix.inputValue(),+ capture: await captureRadios.evaluateAll((radios) =>+ radios.findIndex((radio) => radio.getAttribute('aria-checked') === 'true'),+ ),+ }++ await timezone.click()+ await page.getByRole('option', { name: 'Europe/Warsaw', exact: true }).click()+ await storefrontAccess.click()+ await page.getByRole('option', { name: /^prices hidden/i }).click()+ await guestCheckout.click()+ await prefix.fill('E2E')+ await onDispatch.click()++ const save = page.getByRole('button', { name: /^save$/i })+ await save.click()+ await expect(save).toBeDisabled({ timeout: 15_000 })++ await page.reload()+ await expect(prefix).toHaveValue('E2E', { timeout: 15_000 })+ await expect(timezone).toContainText('Europe/Warsaw')+ await expect(storefrontAccess).toContainText(/prices hidden/i)+ await expect(guestCheckout).toHaveAttribute('aria-checked', String(!original.guestCheckout))+ await expect(onDispatch).toBeChecked()++ // Put the shared store back the way it was for the rest of the suite.+ await timezone.click()+ await page.getByRole('option', { name: original.timezone, exact: true }).click()+ await storefrontAccess.click()+ await page.getByRole('option', { name: original.storefrontAccess, exact: true }).click()+ await guestCheckout.click()+ await prefix.fill(original.prefix)+ if (original.capture >= 0) await captureRadios.nth(original.capture).click()+ await save.click()+ await expect(save).toBeDisabled({ timeout: 15_000 })+ })++ // A store with no storefront of its own reads back no storefront URL: the+ // dashboard neither offers to "View store" nor prefills the connect form+ // with an address the merchant never entered.+ test('shows no storefront address until one is set', async ({ page }) => {+ const creds = await login(page)+ await page.goto(`/${creds.store_id}/getting-started`)+ await expect(page.getByRole('heading', { name: /^getting started$/i })).toBeVisible({+ timeout: 15_000,+ })++ await page.getByRole('button', { name: /^user menu$/i }).click()+ await expect(page.getByRole('menu')).toBeVisible()+ await expect(page.getByRole('menuitem', { name: /^view store$/i })).toHaveCount(0)+ await page.keyboard.press('Escape')++ const step = page.getByRole('button', { name: /set up storefront/i })+ if ((await step.getAttribute('aria-expanded')) !== 'true') await step.click()+ await page.getByRole('button', { name: /^connect storefront$/i }).click()+ await expect(page.getByLabel(/^storefront url$/i)).toHaveValue('')+ })})test.describe('store settings — emails', () => {@@ -218,4 +296,33 @@ test.describe('store settings — emails', () => {expect(valid).toBe(false)}).toPass({ timeout: 5_000 })})++ test('saves the email colors and font, and they survive a reload', async ({ page }) => {+ const creds = await login(page)+ await page.goto(EMAILS_PATH(creds.store_id))+ const accent = page.locator('#store-email-accent_color')+ const font = page.locator('#store-email-font')+ await expect(page.locator('#store-mail-from-address')).not.toHaveValue('', { timeout: 15_000 })++ await accent.fill('#123ABC')+ await accent.blur()+ await font.click()+ await page.getByRole('option', { name: /^georgia$/i }).click()++ const save = page.getByRole('button', { name: /^save$/i })+ await save.click()+ await expect(save).toBeDisabled({ timeout: 15_000 })++ await page.reload()+ await expect(accent).toHaveValue(/^#123abc$/i, { timeout: 15_000 })+ await expect(font).toContainText(/georgia/i)++ // Back to the shipped design for the rest of the suite.+ await accent.fill('')+ await accent.blur()+ await font.click()+ await page.getByRole('option', { name: /^inter/i }).click()+ await save.click()+ await expect(save).toBeDisabled({ 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 b3993a2aae..d51e0332b0 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/seller-requirements.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/seller-requirements.tsx@@ -316,8 +316,12 @@ function EditRequirementSheet({// blank and then save those blanks over the requirement.if (!requirement) return null+ // Keyed by version: a sheet opened straight after a save can mount on the+ // list from before it, and must re-seed once the refetch lands rather than+ // save those stale values back.return (<EditRequirementForm+ key={requirement.updated_at}requirement={requirement}kindEntry={kindEntry}open={open}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsxindex f7ac06caed..bf4831ae3d 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/store.tsx@@ -80,7 +80,10 @@ const INVENTORY_PROVIDER_DOCS_URL = 'https://spreecommerce.org/docs/developer/prconst TIMEZONES: string[] = (() => {try {- return Intl.supportedValuesOf('timeZone')+ // Browsers list only canonical zones, which leaves out `UTC` — the store's+ // default, and a choice a merchant must be able to return to.+ const zones = Intl.supportedValuesOf('timeZone')+ return zones.includes('UTC') ? zones : ['UTC', ...zones]} catch {// Fallback for older browsers — a small representative set.return [