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

Code before:
        const elt = getByText(defaultMessage);
        expect(elt.closest(".notistack-MuiContent-info")).toBeInTheDocument();
    });
    it("gets favicon URL from document link tags", () => {
        const link = document.createElement("link");
        link.rel = "icon";
        link.href = "/test-icon.png";
        document.head.appendChild(link);
        const alerts: AlertMessage[] = [
            { atype: "success", message: "This is a system alert", system: true, duration: 3000 },
        ];
        render(
            <SnackbarProvider>
                <Alert alerts={alerts} />
            </SnackbarProvider>,
        );
        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>

Review comment (suggestion):
```suggestion
    it("closes alert on close button click", async () => {
```

Code after:
        const elt = getByText(defaultMessage);
        expect(elt.closest(".notistack-MuiContent-info")).toBeInTheDocument();
    });
    it("gets favicon URL from document link tags", () => {
        const link = document.createElement("link");
        link.rel = "icon";
        link.href = "/test-icon.png";
        document.head.appendChild(link);
        const alerts: AlertMessage[] = [
            { atype: "success", message: "This is a system alert", system: true, duration: 3000 },
        ];
        render(
            <SnackbarProvider>
                <Alert alerts={alerts} />
            </SnackbarProvider>,
        );
        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>