Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: apply formatting fixes from pre-commit hooks
  • Loading branch information
Olfa Maslah authored and Olfa Maslah committed Nov 27, 2025
commit c2bfeaf250c6514853fd08ed18c8301abfedb7ad
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ jest.mock("../../stores/sliding-container-store", () => ({
// Mock the icon component
jest.mock("@/components/common/genericIconComponent", () => ({
__esModule: true,
default: ({ name, className }: { name: string; className?: string }) => (
<div data-testid={`icon-${name}`} className={className}>
{name}
</div>
default: ({ name }: { name: string }) => (
<div data-testid={`icon-${name}`}>{name}</div>
),
}));

Expand Down Expand Up @@ -53,21 +51,13 @@ const mockUseSlidingContainerStore =

describe("PlaygroundButtonSliding", () => {
const mockToggle = jest.fn();
const mockIsOpen = false;

beforeEach(() => {
jest.clearAllMocks();
mockUseSlidingContainerStore.mockImplementation((selector) => {
const state: Partial<SlidingContainerStoreType> = {
isOpen: mockIsOpen,
toggle: mockToggle,
};
return selector(state as SlidingContainerStoreType);
});
});

describe("when hasIO is true", () => {
it("should render the button with Play icon when closed", () => {
it("should render with Play icon when closed", () => {
mockUseSlidingContainerStore.mockImplementation((selector) => {
const state: Partial<SlidingContainerStoreType> = {
isOpen: false,
Expand All @@ -82,10 +72,9 @@ describe("PlaygroundButtonSliding", () => {
screen.getByTestId("playground-btn-flow-io-sliding"),
).toBeInTheDocument();
expect(screen.getByTestId("icon-Play")).toBeInTheDocument();
expect(screen.getByText("Playground")).toBeInTheDocument();
});

it("should render the button with PanelRightClose icon when open", () => {
it("should render with PanelRightClose icon when open", () => {
mockUseSlidingContainerStore.mockImplementation((selector) => {
const state: Partial<SlidingContainerStoreType> = {
isOpen: true,
Expand All @@ -100,7 +89,6 @@ describe("PlaygroundButtonSliding", () => {
screen.getByTestId("playground-btn-flow-io-sliding"),
).toBeInTheDocument();
expect(screen.getByTestId("icon-PanelRightClose")).toBeInTheDocument();
expect(screen.getByText("Playground")).toBeInTheDocument();
});

it("should call toggle when clicked", () => {
Expand All @@ -119,13 +107,6 @@ describe("PlaygroundButtonSliding", () => {

expect(mockToggle).toHaveBeenCalledTimes(1);
});

it("should have hover styles when hasIO is true", () => {
render(<PlaygroundButtonSliding hasIO={true} />);

const button = screen.getByTestId("playground-btn-flow-io-sliding");
expect(button).toHaveClass("hover:bg-accent", "cursor-pointer");
});
});

describe("when hasIO is false", () => {
Expand All @@ -142,19 +123,6 @@ describe("PlaygroundButtonSliding", () => {
);
});

it("should show Play icon when disabled", () => {
render(<PlaygroundButtonSliding hasIO={false} />);

expect(screen.getByTestId("icon-Play")).toBeInTheDocument();
});

it("should have disabled styles", () => {
render(<PlaygroundButtonSliding hasIO={false} />);

const button = screen.getByTestId("playground-btn-flow-sliding");
expect(button).toHaveClass("cursor-not-allowed", "text-muted-foreground");
});

it("should not call toggle when clicked (disabled)", () => {
render(<PlaygroundButtonSliding hasIO={false} />);

Expand All @@ -164,22 +132,4 @@ describe("PlaygroundButtonSliding", () => {
expect(mockToggle).not.toHaveBeenCalled();
});
});

describe("icon rendering", () => {
it("should apply correct icon classes", () => {
render(<PlaygroundButtonSliding hasIO={true} />);

const icon = screen.getByTestId("icon-Play");
expect(icon).toHaveClass("h-4", "w-4", "transition-all", "flex-shrink-0");
});
});

describe("label visibility", () => {
it("should render label with hidden md:block classes", () => {
render(<PlaygroundButtonSliding hasIO={true} />);

const label = screen.getByText("Playground");
expect(label).toHaveClass("hidden", "md:block");
});
});
});
Loading
Loading