mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-13 13:48:59 +02:00
refactor: test
This commit is contained in:
parent
c8cc9ad3a5
commit
b36297843e
@ -1,3 +1,4 @@
|
|||||||
|
import { subDays } from 'date-fns';
|
||||||
import dbInit, {
|
import dbInit, {
|
||||||
type ITestDb,
|
type ITestDb,
|
||||||
} from '../../../test/e2e/helpers/database-init.js';
|
} from '../../../test/e2e/helpers/database-init.js';
|
||||||
@ -1093,27 +1094,22 @@ test('should filter features by lastSeenAt', async () => {
|
|||||||
name: 'old_seen_feature',
|
name: 'old_seen_feature',
|
||||||
});
|
});
|
||||||
|
|
||||||
// Insert lastSeenAt data for both features
|
const currentDate = new Date();
|
||||||
const recentDate = new Date();
|
|
||||||
const oldDate = new Date();
|
|
||||||
oldDate.setDate(oldDate.getDate() - 10); // 10 days ago
|
|
||||||
|
|
||||||
await insertLastSeenAt(
|
await insertLastSeenAt(
|
||||||
'recently_seen_feature',
|
'recently_seen_feature',
|
||||||
db.rawDatabase,
|
db.rawDatabase,
|
||||||
DEFAULT_ENV,
|
DEFAULT_ENV,
|
||||||
recentDate.toISOString(),
|
currentDate.toISOString(),
|
||||||
);
|
);
|
||||||
await insertLastSeenAt(
|
await insertLastSeenAt(
|
||||||
'old_seen_feature',
|
'old_seen_feature',
|
||||||
db.rawDatabase,
|
db.rawDatabase,
|
||||||
DEFAULT_ENV,
|
DEFAULT_ENV,
|
||||||
oldDate.toISOString(),
|
subDays(currentDate, 10).toISOString(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Filter for features seen in the last 7 days
|
const sevenDaysAgo = subDays(currentDate, 7);
|
||||||
const sevenDaysAgo = new Date();
|
|
||||||
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
|
||||||
|
|
||||||
const { body: recentFeatures } = await app.request
|
const { body: recentFeatures } = await app.request
|
||||||
.get(
|
.get(
|
||||||
@ -1124,7 +1120,6 @@ test('should filter features by lastSeenAt', async () => {
|
|||||||
expect(recentFeatures.features).toHaveLength(1);
|
expect(recentFeatures.features).toHaveLength(1);
|
||||||
expect(recentFeatures.features[0].name).toBe('recently_seen_feature');
|
expect(recentFeatures.features[0].name).toBe('recently_seen_feature');
|
||||||
|
|
||||||
// Filter for features seen before 7 days ago
|
|
||||||
const { body: oldFeatures } = await app.request
|
const { body: oldFeatures } = await app.request
|
||||||
.get(
|
.get(
|
||||||
`/api/admin/search/features?lastSeenAt=IS_BEFORE:${sevenDaysAgo.toISOString()}`,
|
`/api/admin/search/features?lastSeenAt=IS_BEFORE:${sevenDaysAgo.toISOString()}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user