From 86966cebdb3660e9e072e9ea20d2ee04d5f450cd Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Mon, 4 Nov 2024 12:39:05 +0100 Subject: [PATCH] Fix tablelistview test due to timezone switch (#198759) ## Summary Fix https://github.com/elastic/kibana/issues/198744 Test was subtracting 7 days, but there is 1 hour less now, so the test setup is incorrect. Fixing it by using moment to handle time switch edge case (cherry picked from commit a88833c7830c2bb469430eb54c93cab19e64de6e) --- .../table_list_view_table/src/table_list_view.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/content-management/table_list_view_table/src/table_list_view.test.tsx b/packages/content-management/table_list_view_table/src/table_list_view.test.tsx index c874747799480..3f31b0de54323 100644 --- a/packages/content-management/table_list_view_table/src/table_list_view.test.tsx +++ b/packages/content-management/table_list_view_table/src/table_list_view.test.tsx @@ -241,8 +241,8 @@ describe('TableListView', () => { const updatedAtValues: Moment[] = []; const updatedHits = hits.map(({ id, attributes, references }, i) => { - const updatedAt = new Date(new Date().setDate(new Date().getDate() - (7 + i))); - updatedAtValues.push(moment(updatedAt)); + const updatedAt = moment().subtract(7 + i, 'days'); + updatedAtValues.push(updatedAt); return { id,