Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix date-dependent test in ConversationFilters date dropdown (#76803)

Sébastien3d8b6293b896
diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/metabot-analytics/components/ConversationFilters/ConversationFilters.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/audit_app/metabot-analytics/components/ConversationFilters/ConversationFilters.unit.spec.tsx
index 3e0d7f45f36..351f0210246 100644
--- a/enterprise/frontend/src/metabase-enterprise/audit_app/metabot-analytics/components/ConversationFilters/ConversationFilters.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/audit_app/metabot-analytics/components/ConversationFilters/ConversationFilters.unit.spec.tsx
@@ -50,6 +50,22 @@ async function getDropdownLabels() {
}
describe("ConversationFilters date dropdown", () => {
+ // Retention shortcuts are computed relative to the current date, so freeze the
+ // clock to a fixed mid-month date to keep the assertions deterministic. (Without
+ // this, e.g. on the 1st of a month following a 30-day month, the "Previous month"
+ // shortcut's start lands exactly on the retention cutoff and stays visible.)
+ beforeEach(() => {
+ jest.useFakeTimers({
+ advanceTimers: true,
+ now: new Date(2026, 5, 15),
+ doNotFake: ["setTimeout"],
+ });
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ });
+
it("hides shortcuts that go past the configured retention window", async () => {
setup({ retentionDays: 180 });
const labels = await getDropdownLabels();