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
E2E: channels settings CRUD and product publishing card unlist
Damian Legawiecd319f85e6f2e
diff --git a/packages/dashboard/e2e/channels-settings.spec.ts b/packages/dashboard/e2e/channels-settings.spec.tsnew file mode 100644index 0000000000..6735274054--- /dev/null+++ b/packages/dashboard/e2e/channels-settings.spec.ts@@ -0,0 +1,108 @@+import { expect, type Page, test } from '@playwright/test'+import { gotoIndex, login, openRowMenu, rowButton } from './helpers'++const CHANNELS_PATH = (storeId: string) => `/${storeId}/settings/channels`+const ADD_CTA = /new sales channel/i++async function createChannel(page: Page, attrs: { name: string; code?: string }) {+ await page.getByRole('button', { name: ADD_CTA }).click()+ await expect(page.getByRole('heading', { name: /add sales channel/i })).toBeVisible()++ await page.getByLabel(/^name$/i).fill(attrs.name)+ if (attrs.code !== undefined) {+ await page.getByLabel(/^code$/i).fill(attrs.code)+ }++ await page.getByRole('button', { name: /create sales channel/i }).click()+}++test.describe('settings / channels', () => {+ test('lists channels', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)+ })++ test('auto-derives the code from the name and lists the new channel without a reload', async ({+ page,+ }) => {+ const creds = await login(page)+ await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)++ const suffix = Date.now()+ const name = `E2E Channel ${suffix}`+ // ActiveSupport's +String#parameterize+: lowercase, hyphen-separated. The+ // SPA's +slugifyChannelCode+ must produce the same string the user can+ // submit with the auto-fill alone.+ const expectedCode = `e2e-channel-${suffix}`++ await page.getByRole('button', { name: ADD_CTA }).click()+ await expect(page.getByRole('heading', { name: /add sales channel/i })).toBeVisible()++ await page.getByLabel(/^name$/i).fill(name)+ // Auto-derive should populate +code+ without us touching the field.+ await expect(page.getByLabel(/^code$/i)).toHaveValue(expectedCode)++ await page.getByRole('button', { name: /create sales channel/i }).click()++ // List refresh after create — the new row appears without reloading.+ await expect(rowButton(page, name)).toBeVisible({ timeout: 15_000 })+ await expect(page.getByRole('cell', { name: expectedCode, exact: true })).toBeVisible()+ })++ test('stops auto-deriving once the user edits the code field', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)++ const suffix = Date.now()+ const customCode = `e2e-custom-${suffix}`++ await page.getByRole('button', { name: ADD_CTA }).click()+ await page.getByLabel(/^name$/i).fill('Initial Name')+ await page.getByLabel(/^code$/i).fill(customCode)+ // Keep typing on the name — code must NOT follow once it's been touched.+ await page.getByLabel(/^name$/i).fill('Renamed Channel')+ await expect(page.getByLabel(/^code$/i)).toHaveValue(customCode)+ })++ test('edits an existing channel', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)++ const suffix = Date.now()+ const original = `E2E Channel Edit ${suffix}`+ const updated = `${original} (updated)`++ await createChannel(page, { name: original })+ await expect(rowButton(page, original)).toBeVisible({ timeout: 15_000 })++ await rowButton(page, original).click()+ await expect(page.getByRole('heading', { name: original })).toBeVisible({ timeout: 15_000 })++ await page.getByLabel(/^name$/i).fill(updated)+ await page.getByRole('button', { name: /^save$/i }).click()++ await expect(rowButton(page, updated)).toBeVisible({ timeout: 15_000 })+ })++ test('deletes a non-default channel', async ({ page }) => {+ const creds = await login(page)+ await gotoIndex(page, CHANNELS_PATH(creds.store_id), ADD_CTA)++ const suffix = Date.now()+ const name = `E2E Channel Delete ${suffix}`++ await createChannel(page, { name })+ 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('dialog')).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/products-edit.spec.ts b/packages/dashboard/e2e/products-edit.spec.tsindex 40c1d9e949..8bc7da7e97 100644--- a/packages/dashboard/e2e/products-edit.spec.ts+++ b/packages/dashboard/e2e/products-edit.spec.ts@@ -102,4 +102,54 @@ test.describe('product edit', () => {publishingCard(page).getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i')),).toBeVisible()})++ test('unlists a product from a channel via the publishing card', async ({ page }) => {+ const creds = await login(page)+ const name = `E2E Product Unpublish ${Date.now()}`++ await createProduct(page, creds.store_id, name)+ const card = publishingCard(page)++ // Attach the bulk channel first so we have something to detach.+ await card.getByRole('button', { name: /^manage$/i }).click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i') })+ .click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^done$/i })+ .click()+ await expect(card.getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i'))).toBeVisible()+ await page.getByRole('button', { name: /save product/i }).click()+ await expect(page.getByRole('button', { name: /save product/i })).toBeDisabled({+ timeout: 15_000,+ })++ // Re-open Manage and toggle the same channel off — exercises the+ // re-sync write path (POST product_publications without that channel)+ // and locks in the idempotent-channel + remove-missing behaviour+ // covered by the controller spec.+ await card.getByRole('button', { name: /^manage$/i }).click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i') })+ .click()+ await page+ .getByRole('dialog')+ .getByRole('button', { name: /^done$/i })+ .click()++ await expect(card.getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i'))).not.toBeVisible()++ await page.getByRole('button', { name: /save product/i }).click()+ await expect(page.getByRole('button', { name: /save product/i })).toBeDisabled({+ timeout: 15_000,+ })++ await page.reload()+ await expect(+ publishingCard(page).getByText(new RegExp(FIXTURE_BULK_CHANNEL_NAME, 'i')),+ ).not.toBeVisible()+ })})