Skip to content

Commit edd59bc

Browse files
committed
update test coverage for revision numbers when useFulltextsearch is being used
1 parent 40a66a9 commit edd59bc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/__tests__/Search/fetchRevisionsBySearch.test.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,30 @@ describe('SearchView/fetchRevisions', () => {
208208
new Error(),
209209
);
210210
});
211+
212+
it('should fetch revisions by ID if searchValue is a 12 or 40 character hash', async () => {
213+
const { testData } = getTestData();
214+
(global.fetch as FetchMockSandbox).get(
215+
'glob:https://treeherder.mozilla.org/api/project/*/push/*',
216+
{
217+
results: testData,
218+
},
219+
);
220+
221+
// set delay to null to prevent test time-out due to useFakeTimers
222+
const user = userEvent.setup({ delay: null });
223+
224+
await renderSearchViewComponent();
225+
226+
const searchInput = screen.getAllByRole('textbox')[0];
227+
await user.type(searchInput, 'abcdef123456');
228+
act(() => void jest.runAllTimers());
229+
expect(global.fetch).toHaveBeenCalledWith(
230+
'https://treeherder.mozilla.org/api/project/try/push/?revision=abcdef123456',
231+
undefined,
232+
);
233+
expect(
234+
await screen.findByText("you've got no arms left!"),
235+
).toBeInTheDocument();
236+
});
211237
});

0 commit comments

Comments
 (0)