-
-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: event search e2e tests (#7755)
This covers the e2e cases for event search.
- Loading branch information
Showing
3 changed files
with
305 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,279 @@ test('should search events by query', async () => { | |
total: 1, | ||
}); | ||
}); | ||
|
||
test('should filter events by feature', async () => { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
featureName: 'my_feature_a', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
featureName: 'my_feature_b', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const { body } = await searchEvents({ feature: 'IS:my_feature_b' }); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
type: 'feature-created', | ||
featureName: 'my_feature_b', | ||
}, | ||
], | ||
total: 1, | ||
}); | ||
}); | ||
|
||
test('should filter events by project', async () => { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'another_project', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const { body } = await searchEvents({ project: 'IS:another_project' }); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
type: 'feature-created', | ||
project: 'another_project', | ||
}, | ||
], | ||
total: 1, | ||
}); | ||
}); | ||
|
||
test('should filter events by type', async () => { | ||
await eventService.storeEvent({ | ||
type: 'change-added', | ||
project: 'default', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: 'feature-created', | ||
project: 'default', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const { body } = await searchEvents({ type: 'IS:change-added' }); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
type: 'change-added', | ||
}, | ||
], | ||
total: 1, | ||
}); | ||
}); | ||
|
||
test('should filter events by created by', async () => { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
createdBy: '[email protected]', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
createdBy: '[email protected]', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const { body } = await searchEvents({ createdBy: 'IS:[email protected]' }); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
createdBy: '[email protected]', | ||
}, | ||
], | ||
total: 1, | ||
}); | ||
}); | ||
|
||
test('should filter events by created date range', async () => { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
data: { featureName: 'my_feature_a' }, | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
data: { featureName: 'my_feature_b' }, | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const today = new Date(); | ||
|
||
const { body } = await searchEvents({ | ||
createdAtFrom: `IS:${today.toISOString().split('T')[0]}`, | ||
}); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
type: FEATURE_CREATED, | ||
data: { featureName: 'my_feature_b' }, | ||
}, | ||
{ | ||
type: FEATURE_CREATED, | ||
data: { featureName: 'my_feature_a' }, | ||
}, | ||
], | ||
total: 2, | ||
}); | ||
}); | ||
|
||
test('should paginate with offset and limit', async () => { | ||
for (let i = 0; i < 5; i++) { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
data: { featureName: `my_feature_${i}` }, | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
} | ||
|
||
const { body: secondPage } = await searchEvents({ | ||
offset: '2', | ||
limit: '2', | ||
}); | ||
|
||
expect(secondPage.events).toMatchObject([ | ||
{ | ||
data: { featureName: `my_feature_2` }, | ||
}, | ||
{ | ||
data: { featureName: `my_feature_1` }, | ||
}, | ||
]); | ||
}); | ||
|
||
test('should filter events by feature using IS_ANY_OF', async () => { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
featureName: 'my_feature_a', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
featureName: 'my_feature_b', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'default', | ||
featureName: 'my_feature_c', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const { body } = await searchEvents({ | ||
feature: 'IS_ANY_OF:my_feature_a,my_feature_b', | ||
}); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
type: 'feature-created', | ||
featureName: 'my_feature_b', | ||
}, | ||
{ | ||
type: 'feature-created', | ||
featureName: 'my_feature_a', | ||
}, | ||
], | ||
total: 2, | ||
}); | ||
}); | ||
|
||
test('should filter events by project using IS_ANY_OF', async () => { | ||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'project_a', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'project_b', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
await eventService.storeEvent({ | ||
type: FEATURE_CREATED, | ||
project: 'project_c', | ||
createdBy: 'test-user', | ||
createdByUserId: TEST_USER_ID, | ||
ip: '127.0.0.1', | ||
}); | ||
|
||
const { body } = await searchEvents({ | ||
project: 'IS_ANY_OF:project_a,project_b', | ||
}); | ||
|
||
expect(body).toMatchObject({ | ||
events: [ | ||
{ | ||
type: 'feature-created', | ||
project: 'project_b', | ||
}, | ||
{ | ||
type: 'feature-created', | ||
project: 'project_a', | ||
}, | ||
], | ||
total: 2, | ||
}); | ||
}); |