[Security Solution] [Notes] Make notes tests deterministic (#214876)

## Summary

Unskips some recently skipped tests in the notes reducer, I believe
because the time for each mock was just Date.now(), resulting in
slightly different times for each mock on ci, whereas locally the time
is the same.

### Checklist

- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
This commit is contained in:
Kevin Qualters 2025-03-17 20:25:23 -04:00 committed by GitHub
parent e78a2d19e1
commit 4334508e62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,7 +72,11 @@ const generateNoteMock = (documentId: string): Note => ({
});
const mockNote1 = generateNoteMock('1');
const mockNote2 = generateNoteMock('2');
const mockNote2 = {
...generateNoteMock('2'),
created: new Date().getTime() + 1000,
updated: new Date().getTime() + 1000,
};
const initialNonEmptyState: NotesState = {
entities: {
@ -117,8 +121,7 @@ describe('notesSlice', () => {
expect(notesReducer(initalEmptyState, { type: 'unknown' })).toEqual(initalEmptyState);
});
// FLAKY: https://github.com/elastic/kibana/issues/213905
describe.skip('fetchNotesByDocumentIds', () => {
describe('fetchNotesByDocumentIds', () => {
it('should set correct status state when fetching notes by document ids', () => {
const action = { type: fetchNotesByDocumentIds.pending.type };
@ -175,7 +178,7 @@ describe('notesSlice', () => {
[newMockNote.noteId]: newMockNote,
[mockNote2.noteId]: mockNote2,
},
ids: [mockNote2.noteId, newMockNote.noteId],
ids: [newMockNote.noteId, mockNote2.noteId],
status: {
...initalEmptyState.status,
fetchNotesByDocumentIds: ReqStatus.Succeeded,
@ -200,8 +203,7 @@ describe('notesSlice', () => {
});
});
// FLAKY: https://github.com/elastic/kibana/issues/213906
describe.skip('fetchNotesBySavedObjectIds', () => {
describe('fetchNotesBySavedObjectIds', () => {
it('should set correct status state when fetching notes by saved object ids', () => {
const action = { type: fetchNotesBySavedObjectIds.pending.type };
@ -258,7 +260,7 @@ describe('notesSlice', () => {
[newMockNote.noteId]: newMockNote,
[mockNote2.noteId]: mockNote2,
},
ids: [mockNote2.noteId, newMockNote.noteId],
ids: [newMockNote.noteId, mockNote2.noteId],
status: {
...initalEmptyState.status,
fetchNotesBySavedObjectIds: ReqStatus.Succeeded,