diff --git a/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.test.tsx b/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.test.tsx new file mode 100644 index 00000000..d73bf1b8 --- /dev/null +++ b/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.test.tsx @@ -0,0 +1,50 @@ +import { render, screen } from "@testing-library/react"; +import { BarcodePrintHeader } from "./BarcodePrintHeader"; +import { EMPTY_FILTERS } from "./barcodePrintFiltering"; + +function renderHeader(canManageImports: boolean) { + return render( + , + ); +} + +describe("BarcodePrintHeader", () => { + it("hides all import controls for users without import permission", () => { + renderHeader(false); + + expect(screen.queryByRole("button", { name: "条码导入" })).not.toBeInTheDocument(); + expect( + screen.queryByRole("button", { name: "条码导入模板下载" }), + ).not.toBeInTheDocument(); + expect(screen.queryByRole("button", { name: "品牌货号导入" })).not.toBeInTheDocument(); + expect( + screen.queryByRole("button", { name: "品牌货号导入模板下载" }), + ).not.toBeInTheDocument(); + expect(screen.getByRole("button", { name: "查询" })).toBeInTheDocument(); + }); + + it("shows all import controls for designers and administrators", () => { + renderHeader(true); + + expect(screen.getByRole("button", { name: "条码导入" })).toBeInTheDocument(); + expect( + screen.getByRole("button", { name: "条码导入模板下载" }), + ).toBeInTheDocument(); + expect(screen.getByRole("button", { name: "品牌货号导入" })).toBeInTheDocument(); + expect( + screen.getByRole("button", { name: "品牌货号导入模板下载" }), + ).toBeInTheDocument(); + }); +}); diff --git a/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.tsx b/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.tsx index 7395b5ce..9c10ce0a 100644 --- a/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.tsx +++ b/furniture-3d-system/src/app/intake/barcode-print/BarcodePrintHeader.tsx @@ -21,6 +21,7 @@ export function BarcodePrintHeader({ productCategoryOptions, salesCategoryOptions, statusMessage, + canManageImports, onBarcodeImport, actionDisabled = false, onBrandSkuImport, @@ -33,6 +34,7 @@ export function BarcodePrintHeader({ productCategoryOptions: string[]; salesCategoryOptions: string[]; statusMessage: string; + canManageImports: boolean; actionDisabled?: boolean; onBarcodeImport: () => void; onBrandSkuImport: () => void; @@ -46,26 +48,32 @@ export function BarcodePrintHeader({ }) { return (
-
- - - onDownloadTemplate("barcode")}> - - - - onDownloadTemplate("brandSku")}> - -
+ {canManageImports ? ( +
+ + + onDownloadTemplate("barcode")}> + + + + onDownloadTemplate("brandSku")}> + +
+ ) : null} -
+
void; onBarcodePrint: (row: BarcodePrintRow) => void; onCertificatePrint: (row: BarcodePrintRow) => void; + canManageImports: boolean; onDeleteImportedData: (importRecordIds: string[] | undefined) => void; }) { return ( @@ -213,7 +215,7 @@ export function BarcodePrintTable({ >