Skip to content

Commit 09b464c

Browse files
fix(web): urgent and warning notices no longer hide behind activity banners (pingdotgg#18919)
Co-authored-by: Julius Marminge <[email protected]>
1 parent 8f72a73 commit 09b464c

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

‎apps/web/src/components/chat/ComposerBannerStack.browser.test.tsx‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "../../index.css";
33
import { act } from "react";
44
import { createRoot, type Root } from "react-dom/client";
55
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
6+
import { page, userEvent } from "vite-plus/test/browser";
67

78
import { ComposerBannerStack } from "./ComposerBannerStack";
89

@@ -58,3 +59,53 @@ it("only offers notice details when the description cannot fit", async () => {
5859
await nextFrame();
5960
expect(hasDetails()).toBe(true);
6061
});
62+
63+
it("keeps only the usage limit attached while an active goal waits in the collapsible stack", async () => {
64+
await act(async () =>
65+
root.render(
66+
<ComposerBannerStack
67+
items={[
68+
{
69+
id: "goal",
70+
variant: "default",
71+
priority: "activity",
72+
icon: null,
73+
title: "Goal active",
74+
description: "Finish the banner fix",
75+
},
76+
{
77+
id: "limit",
78+
variant: "default",
79+
priority: "urgent",
80+
icon: null,
81+
title: "Usage limit reached",
82+
},
83+
]}
84+
/>,
85+
),
86+
);
87+
88+
const visibleBanners = () =>
89+
Array.from(container.querySelectorAll('[data-slot="composer-banner"]')).filter((banner) =>
90+
banner.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }),
91+
);
92+
const limit = page.getByText("Usage limit reached", { exact: true });
93+
const goal = page.getByText("Goal active", { exact: true });
94+
95+
expect(visibleBanners()).toHaveLength(1);
96+
await expect.element(limit).toBeVisible();
97+
await expect.element(goal).not.toBeVisible();
98+
expect(container.querySelector('[data-slot="composer-banner-attachment"]')?.textContent).toBe(
99+
"Usage limit reached",
100+
);
101+
102+
await act(async () => page.getByRole("button", { name: "Show other notices" }).click());
103+
await expect.element(goal).toBeVisible();
104+
await expect.element(limit).toBeVisible();
105+
await expect.poll(visibleBanners).toHaveLength(2);
106+
107+
await act(async () => userEvent.keyboard("{Escape}"));
108+
await expect.element(goal).not.toBeVisible();
109+
await expect.element(limit).toBeVisible();
110+
expect(visibleBanners()).toHaveLength(1);
111+
});

‎apps/web/src/components/chat/ComposerBannerStack.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export type ComposerBannerStackContent = Pick<
3131
type ComposerBannerStackEntry = ComposerBannerStackItem | ComposerBannerStackContent;
3232

3333
function bannerPriority(item: ComposerBannerStackEntry) {
34-
if (item.priority === "activity") {
34+
if (item.priority === "urgent" || item.variant === "error" || item.variant === "warning") {
3535
return 0;
3636
}
37-
if (item.priority === "urgent" || item.variant === "error" || item.variant === "warning") {
37+
if (item.priority === "activity") {
3838
return 1;
3939
}
4040
return 2;

0 commit comments

Comments
 (0)