Skip to content

Commit 1cf99f3

Browse files
Merge pull request #9182 from jeffibm/fix-copy-dashboard-form-test
Fix CopyDashboardForm test
2 parents 4a387ee + d99984e commit 1cf99f3

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

app/javascript/spec/copy-dashboard-form/copy-dashboard-form.spec.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe('Copy Dashboard form', () => {
113113
done();
114114
});
115115

116-
it('should handle submit', async(done) => {
116+
it('should handle submit', async() => {
117117
fetchMock
118118
.getOnce(baseUrl, dashboardData)
119119
.getOnce(apiUrl, apiData)
@@ -133,16 +133,19 @@ describe('Copy Dashboard form', () => {
133133
await act(async() => {
134134
wrapper.find('input[name="name"]').simulate('change', { target: { value: 'new_name' } });
135135
wrapper.find('input[name="group_id"]').simulate('change', { target: { value: '80s' } });
136-
wrapper.find('form').simulate('submit');
137136
});
138137

139-
setTimeout(() => {
140-
expect(spyMiqAjaxButton).toHaveBeenCalledWith(
141-
'/report/dashboard_render',
142-
{ group: 'current group', name: 'new_name', original_name: 'original_name' },
143-
);
144-
expect(fetchMock.calls()).toHaveLength(4);
145-
done();
146-
}, 500);
138+
await new Promise((resolve) => setTimeout(resolve, 0));
139+
wrapper.update();
140+
141+
await act(async() => {
142+
setTimeout(() => {
143+
expect(spyMiqAjaxButton).toHaveBeenCalledWith(
144+
'/report/dashboard_render',
145+
{ group: 'current group', name: 'new_name', original_name: 'original_name' },
146+
);
147+
expect(fetchMock.calls()).toHaveLength(4);
148+
}, 500);
149+
});
147150
});
148151
});

0 commit comments

Comments
 (0)