1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00

fix: make test for last seen by env not rely on array order (#5303)

This test was flaky because it relied on the order of the array
returned. To make it less flaky, we now turn the array into an object
instead and compare that.
This commit is contained in:
Thomas Heartman 2023-11-08 15:23:24 +01:00 committed by GitHub
parent ebf3102244
commit 2695e38ed5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,7 +188,7 @@ test('response should include last seen at per environment correctly for a singl
.get(`/api/admin/projects/default/features/${featureName}`)
.expect(200);
expect(body.environments).toMatchObject([
const expected = [
{
name: 'default',
lastSeenAt: '2023-08-01T12:30:56.000Z',
@ -201,5 +201,15 @@ test('response should include last seen at per environment correctly for a singl
name: 'production',
lastSeenAt: '2023-08-01T12:30:56.000Z',
},
]);
];
const toObject = (lastSeenAtEnvData) =>
Object.fromEntries(
lastSeenAtEnvData.map((env) => [
env.name,
{ lastSeenAt: env.lastSeenAt },
]),
);
expect(toObject(body.environments)).toMatchObject(toObject(expected));
});