Repository: Avaiga/taipy
File: frontend/taipy-gui/src/components/Taipy/Alert.spec.tsx (TypeScript)

Code before:
        );
        const linkElement = document.querySelector("link[rel='icon']");
        if (linkElement) {
            expect(linkElement.getAttribute("href")).toBe("/test-icon.png");
        } else {
            expect(true).toBe(false);
        }
        document.head.removeChild(link);
    });

    it("closes Snackbar on close button click", async () => {
        const alerts = [{ atype: "success", message: "Test Alert", duration: 3000, system: false }];
        render(
            <SnackbarProvider>
                <Alert alerts={alerts} />
            </SnackbarProvider>,
        );
        const closeButton = await screen.findByRole("button", { name: /close/i });
        await userEvent.click(closeButton);
        await waitFor(() => {
            const alertMessage = screen.queryByText("Test Alert");
            expect(alertMessage).not.toBeInTheDocument();
        });
    });

    it("Snackbar disappears when alert type is empty", async () => {
        const alerts = [{ atype: "success", message: "Test Alert", duration: 3000, system: false }];
        const { rerender } = render(
            <SnackbarProvider>
                <Alert alerts={alerts} />
            </SnackbarProvider>,
        );
        await screen.findByRole("button", { name: /close/i });
        const newAlerts = [{ atype: "", message: "Test Alert", duration: 3000, system: false }];
        rerender(
            <SnackbarProvider>
                <Alert alerts={newAlerts} />
            </SnackbarProvider>,
        );
        await waitFor(() => {
            const alertMessage = screen.queryByText("Test Alert");
            expect(alertMessage).not.toBeInTheDocument();
        });
    });

    it("does nothing when alert is undefined", async () => {
        render(
            <SnackbarProvider>
                <Alert alerts={[]} />
            </SnackbarProvider>,
        );

Review comment (suggestion):
```suggestion
    it("Alert disappears when alert type is empty", async () => {
```

Code after:
        );
        const linkElement = document.querySelector("link[rel='icon']");
        if (linkElement) {
            expect(linkElement.getAttribute("href")).toBe("/test-icon.png");
        } else {
            expect(true).toBe(false);
        }
        document.head.removeChild(link);
    });

    it("closes alert on close button click", async () => {
        const alerts = [{ atype: "success", message: "Test Alert", duration: 3000, system: false }];
        render(
            <SnackbarProvider>
                <Alert alerts={alerts} />
            </SnackbarProvider>,
        );
        const closeButton = await screen.findByRole("button", { name: /close/i });
        await userEvent.click(closeButton);
        await waitFor(() => {
            const alertMessage = screen.queryByText("Test Alert");
            expect(alertMessage).not.toBeInTheDocument();
        });
    });

    it("Alert disappears when alert type is empty", async () => {
        const alerts = [{ atype: "success", message: "Test Alert", duration: 3000, system: false }];
        const { rerender } = render(
            <SnackbarProvider>
                <Alert alerts={alerts} />
            </SnackbarProvider>,
        );
        await screen.findByRole("button", { name: /close/i });
        const newAlerts = [{ atype: "", message: "Test Alert", duration: 3000, system: false }];
        rerender(
            <SnackbarProvider>
                <Alert alerts={newAlerts} />
            </SnackbarProvider>,
        );
        await waitFor(() => {
            const alertMessage = screen.queryByText("Test Alert");
            expect(alertMessage).not.toBeInTheDocument();
        });
    });

    it("does nothing when alert is undefined", async () => {
        render(
            <SnackbarProvider>
                <Alert alerts={[]} />
            </SnackbarProvider>,
        );