Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Other bulk operation code review fixes

Damian Legawiec2152ac47fc1c
diff --git a/packages/admin/e2e/global-setup.ts b/packages/admin/e2e/global-setup.ts
index aff9ebbea9..e17046a998 100644
--- a/packages/admin/e2e/global-setup.ts
+++ b/packages/admin/e2e/global-setup.ts
@@ -12,6 +12,7 @@ import {
FIXTURE_BULK_PRODUCT_G,
FIXTURE_BULK_PRODUCT_H,
FIXTURE_BULK_PRODUCT_I,
+ FIXTURE_BULK_PRODUCT_J,
FIXTURE_PROMO_CUSTOMER_EMAIL,
FIXTURE_PROMO_CUSTOMER_FIRST_NAME,
FIXTURE_PROMO_CUSTOMER_FULL_NAME,
@@ -64,6 +65,7 @@ const BOOTSTRAP_RUBY = [
`Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_G}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,
`Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_H}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,
`Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_I}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,
+ `Spree::Product.where(name: '${FIXTURE_BULK_PRODUCT_J}').first_or_create!(price: 9.99, shipping_category: shipping_category, stores: [s], status: 'active').update!(status: 'active')`,
// Category used by the bulk-add-to-categories test. Sits in the same
// `Categories` taxonomy as the promo taxon above.
`taxonomy.taxons.where(name: '${FIXTURE_BULK_CATEGORY}').first_or_create!(parent: taxonomy.root)`,
diff --git a/packages/admin/e2e/helpers.ts b/packages/admin/e2e/helpers.ts
index 5d10ac50ac..837c999ddc 100644
--- a/packages/admin/e2e/helpers.ts
+++ b/packages/admin/e2e/helpers.ts
@@ -22,6 +22,7 @@ export const FIXTURE_BULK_PRODUCT_F = 'E2E Bulk Product F'
export const FIXTURE_BULK_PRODUCT_G = 'E2E Bulk Product G'
export const FIXTURE_BULK_PRODUCT_H = 'E2E Bulk Product H'
export const FIXTURE_BULK_PRODUCT_I = 'E2E Bulk Product I'
+export const FIXTURE_BULK_PRODUCT_J = 'E2E Bulk Product J'
// Dedicated category seeded for the bulk-add-to-categories test; lives under
// the `Categories` taxonomy alongside `FIXTURE_PROMO_TAXON`.
export const FIXTURE_BULK_CATEGORY = 'E2E Bulk Category'
diff --git a/packages/admin/e2e/products-bulk.spec.ts b/packages/admin/e2e/products-bulk.spec.ts
index 08f324d678..78df612474 100644
--- a/packages/admin/e2e/products-bulk.spec.ts
+++ b/packages/admin/e2e/products-bulk.spec.ts
@@ -10,6 +10,7 @@ import {
FIXTURE_BULK_PRODUCT_G,
FIXTURE_BULK_PRODUCT_H,
FIXTURE_BULK_PRODUCT_I,
+ FIXTURE_BULK_PRODUCT_J,
gotoIndex,
login,
} from './helpers'
@@ -192,10 +193,19 @@ test.describe('products bulk operations', () => {
const creds = await login(page)
await gotoIndex(page, PRODUCTS_PATH(creds.store_id), CTA)
- // The previous test duplicated product I, so a "COPY OF E2E Bulk Product I"
- // row exists. Delete it via the row-action menu to exercise the row-level
- // confirm + delete path without depleting other fixtures.
- const cloneName = `COPY OF ${FIXTURE_BULK_PRODUCT_I}`
+ // Self-contained: duplicate product J inside this test (so it survives
+ // re-runs and doesn't depend on the prior clone test), then delete the
+ // resulting clone via the row-action menu.
+ await openRowMenu(page, FIXTURE_BULK_PRODUCT_J)
+ await page.getByRole('menuitem', { name: /duplicate/i }).click()
+
+ const cloneName = `COPY OF ${FIXTURE_BULK_PRODUCT_J}`
+ await expect(page.getByRole('heading', { name: new RegExp(cloneName, 'i') })).toBeVisible({
+ timeout: 15_000,
+ })
+
+ // Back to the index, find the clone row and open its menu.
+ await gotoIndex(page, PRODUCTS_PATH(creds.store_id), CTA)
await expect(page.getByRole('link', { name: cloneName })).toBeVisible({ timeout: 15_000 })
await openRowMenu(page, cloneName)
await page.getByRole('menuitem', { name: /^delete$/i }).click()
diff --git a/packages/admin/src/components/spree/bulk-dialog.tsx b/packages/admin/src/components/spree/bulk-dialog.tsx
index 06d5d9d853..52fb49f6af 100644
--- a/packages/admin/src/components/spree/bulk-dialog.tsx
+++ b/packages/admin/src/components/spree/bulk-dialog.tsx
@@ -46,17 +46,25 @@ export function BulkDialog({
<DialogTitle>{title}</DialogTitle>
{description && <DialogDescription>{description}</DialogDescription>}
</DialogHeader>
- <DialogBody>
- <FieldGroup>{children}</FieldGroup>
- </DialogBody>
- <DialogFooter>
- <Button type="button" variant="outline" size="sm" onClick={onCancel}>
- {t('admin.actions.cancel')}
- </Button>
- <Button type="button" size="sm" disabled={submitDisabled} onClick={onSubmit}>
- {submitLabel}
- </Button>
- </DialogFooter>
+ <form
+ onSubmit={(event) => {
+ event.preventDefault()
+ if (!submitDisabled) onSubmit()
+ }}
+ className="flex min-h-0 flex-1 flex-col"
+ >
+ <DialogBody>
+ <FieldGroup>{children}</FieldGroup>
+ </DialogBody>
+ <DialogFooter>
+ <Button type="button" variant="outline" size="sm" onClick={onCancel}>
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="submit" size="sm" disabled={submitDisabled}>
+ {submitLabel}
+ </Button>
+ </DialogFooter>
+ </form>
</DialogContent>
</Dialog>
)
diff --git a/packages/admin/src/components/spree/resource-table.tsx b/packages/admin/src/components/spree/resource-table.tsx
index 7166ed3f48..73d76582f2 100644
--- a/packages/admin/src/components/spree/resource-table.tsx
+++ b/packages/admin/src/components/spree/resource-table.tsx
@@ -471,7 +471,11 @@ export function ResourceTable<T extends Record<string, any>>({
{col.label}
</TableHead>
))}
- {rowActionsEnabled && <TableHead className="w-12" />}
+ {rowActionsEnabled && (
+ <TableHead className="w-12">
+ <span className="sr-only">{t('admin.row_actions.menu_label')}</span>
+ </TableHead>
+ )}
</tr>
</TableHeader>
<TableBody>
diff --git a/packages/admin/src/locales/en.json b/packages/admin/src/locales/en.json
index a5b3348972..4a560d00d2 100644
--- a/packages/admin/src/locales/en.json
+++ b/packages/admin/src/locales/en.json
@@ -421,6 +421,7 @@
},
"customer": {
"tags": { "label": "Tags" },
+ "customer_groups": { "label": "Customer groups" },
"accepts_email_marketing": { "label": "Subscribed to marketing" },
"internal_note": {
"label": "Internal note",
diff --git a/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx b/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx
index a040ca5922..be9d999983 100644
--- a/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx
+++ b/packages/admin/src/routes/_authenticated/$storeId/customers/index.tsx
@@ -225,7 +225,7 @@ function GroupPickerDialog({
onSubmit={() => onSubmit({ customer_group_ids: groupIds })}
>
<Field>
- <FieldLabel>{t('admin.pages.customers.groups_cta')}</FieldLabel>
+ <FieldLabel>{t('admin.fields.customer.customer_groups.label')}</FieldLabel>
<ResourceMultiAutocomplete
{...customerGroupAutocompleteProps('customer-groups-picker')}
value={groupIds}