Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
import { Command, CommandInput, CommandList, CommandItem } from "./command";
|
|
|
|
const HAM = "Hamilton Backpack For Cabrio Car Seat HAM-001";
|
|
const ISA = "Isa Uchi Hands Free Breast Pump Bra YELLOW-001";
|
|
const MOM = "Momcozy Official Washing Block MOM-001";
|
|
|
|
function setup(props: React.ComponentProps<typeof Command> = {}) {
|
|
render(
|
|
<Command {...props}>
|
|
<CommandInput placeholder="search" />
|
|
<CommandList>
|
|
<CommandItem value={HAM}>{HAM}</CommandItem>
|
|
<CommandItem value={ISA}>{ISA}</CommandItem>
|
|
<CommandItem value={MOM}>{MOM}</CommandItem>
|
|
</CommandList>
|
|
</Command>,
|
|
);
|
|
}
|
|
const type = (v: string) => fireEvent.change(screen.getByPlaceholderText("search"), { target: { value: v } });
|
|
|
|
describe("Command default filter", () => {
|
|
it("typing a SKU renders only the item containing it", () => {
|
|
setup();
|
|
type("HAM-001");
|
|
expect(screen.getByText(HAM)).toBeInTheDocument();
|
|
expect(screen.queryByText(ISA)).not.toBeInTheDocument();
|
|
expect(screen.queryByText(MOM)).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("ignores surrounding spaces in the search", () => {
|
|
setup();
|
|
type(" HAM-001 ");
|
|
expect(screen.getByText(HAM)).toBeInTheDocument();
|
|
expect(screen.queryByText(ISA)).not.toBeInTheDocument();
|
|
expect(screen.queryByText(MOM)).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("matches case-insensitively", () => {
|
|
setup();
|
|
type("ham");
|
|
expect(screen.getByText(HAM)).toBeInTheDocument();
|
|
expect(screen.queryByText(ISA)).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("an explicit filter prop still wins", () => {
|
|
setup({ filter: (value: string) => (value.includes("MOM-001") ? 1 : 0) });
|
|
type("anything");
|
|
expect(screen.getByText(MOM)).toBeInTheDocument();
|
|
expect(screen.queryByText(HAM)).not.toBeInTheDocument();
|
|
});
|
|
});
|