From 8708c529e75d9518fcb3a778b22daa8b1a77cecd Mon Sep 17 00:00:00 2001
From: Hweinstock <42325418+Hweinstock@users.noreply.github.com>
Date: Wed, 18 Dec 2024 11:51:42 -0500
Subject: [PATCH] test(codecatalyst): only fail test if message is >1 minute
 off #6265

## Problem
fix https://github.com/aws/aws-toolkit-vscode/issues/6213

## Solution
- The important part of this test is that the message comes after being inactive. If the message comes slightly early/late, that is okay. If it doesn't come at all, then we have problems and should fail.
- Pass test if message comes within a minute of expected.
---
 packages/core/src/testInteg/codecatalyst/devEnv.test.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/packages/core/src/testInteg/codecatalyst/devEnv.test.ts b/packages/core/src/testInteg/codecatalyst/devEnv.test.ts
index 1faed565ccb..2da7c4c0adc 100644
--- a/packages/core/src/testInteg/codecatalyst/devEnv.test.ts
+++ b/packages/core/src/testInteg/codecatalyst/devEnv.test.ts
@@ -141,7 +141,12 @@ describe('InactivityMessage', function () {
                 message: expectedMessages[i][0],
                 minute: expectedMessages[i][1],
             }
-            assert.deepStrictEqual(actualMessages[i], expected)
+            assert.deepStrictEqual(actualMessages[i].message, expected.message)
+            // Avoid flakiness in the timing by looking within a minute rather than exact.
+            assert.ok(
+                Math.abs(actualMessages[i].minute - expected.minute) <= 1,
+                `Expected to be within 60 seconds of minute ${expected.minute}, but instead was at minute ${actualMessages[i].minute}`
+            )
         }
     }