Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ const TypesRequiringDuration: GoabTemporaryNotificationType[] = ["basic", "succe
function show(message: string, opts?: Partial<GoabNotificationOptions>): string {
const uuid = crypto.randomUUID();
opts = { uuid, type: "basic", ...(opts || {}) };

// set default duration for certain notification types
if (!opts.duration && opts.type && TypesRequiringDuration.includes(opts.type)) {
if (opts.duration === undefined && opts.type && TypesRequiringDuration.includes(opts.type)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as well, but what is the reason for the change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we pass 0 as a number, the !opts.duration is true, and it doesn't work.

opts.duration = "short";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,24 @@ describe("Temporary Notification Controller", () => {
};

const result = render(<Component />);
const notification = result.getByTestId("cancel-notification");
const actionButton = result.getByRole("button");


await vi.waitFor(async () => {
sendCancellableNotificationWithoutNotificationResponse("Notification with cancel action", "cancel-notification");

// Verify the notification is displayed
const notification = result.getByTestId("cancel-notification");
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failed in headless mode (passed in browser mode) because of a race condition. We query the notification outside the waitFor block, so we query it even before we trigger the temporary notification, that is why it failed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always run in headless mode and it never failed. I am also not clear on what you mean by us querying it before triggering it.

expect(notification.elements().length).toBe(1);
}, { timeout: 5000 });

// Click the cancel button
expect(actionButton.elements().length).toBe(1);
await actionButton.click();
// Get the action button and click it
const actionButton = result.getByRole("button");
expect(actionButton.elements().length).toBe(1);
await actionButton.click();

// Verify the notification is removed
await vi.waitFor(() => {
expect(notification.elements().length).toBe(0);
});
});
// Verify the notification is removed
await vi.waitFor(() => {
const notification = result.getByTestId("cancel-notification");
expect(notification.elements().length).toBe(0);
}, { timeout: 5000 });
})

it.skip("should handle progress updates", async function () {
Expand Down