Follow-up from "Prevent form submission on Enter in dropdown search fields"
The following discussion from !40011 (merged) should be addressed:
-
@dmishunov started a discussion: (+4 comments) issue: @nfriend I'm not sure we're testing the correct thing here. The issue this MR is trying to solve is the prevention of the form's submission on Enter. But here we're only testing for the search to be made. It's a bit misleading because if you try with a small modification of this
describe
:beforeEach(() => { mock .onGet(TEST_SEARCH_ENDPOINT, { params: { search: 'TEST_SEARCH', scope: 'milestones' } }) .reply(200, []); }); it('should trigger a search', async () => { expect(mock.history.get.length).toBe(0); findSearchBox().vm.$emit('keydown', new KeyboardEvent({ key: ENTER_KEY })); await axios.waitForAll(); expect(mock.history.get.length).toBe(1); });
you'll notice that the very first expectation that is supposed to be passing just fine is failing the test. Apparently we do not reset the mock properly here, hence catch some call to
/api/v4/projects/8/milestones
instead ofTEST_SEARCH_ENDPOINT
.Moreover,
mock.history.get.length
doesn't get updated after the Enter is clicked. And this is odd. Could you please take a look at this situation and update the test to make sure we test the correct thing here?