Commit c2a9e3f5 authored by Tim Zallmann's avatar Tim Zallmann

Improvements for Issue Detail loading

Using delayed request for polling

Removing Sidebar startup call again
Restructured makeDelayedRequest

Delayed Polling Spec fixes
parent 8c871ce3
......@@ -247,7 +247,7 @@ export default {
});
if (!Visibility.hidden()) {
this.poll.makeRequest();
this.poll.makeDelayedRequest(2000);
}
Visibility.change(() => {
......
......@@ -88,7 +88,11 @@ export default class Poll {
}
makeDelayedRequest(delay = 0) {
this.timeoutID = setTimeout(() => this.makeRequest(), delay);
// So we don't make our specs artificially slower
this.timeoutID = setTimeout(
() => this.makeRequest(),
process.env.NODE_ENV !== 'test' ? delay : 1,
);
}
makeRequest() {
......
......@@ -475,7 +475,7 @@ export const poll = ({ commit, state, getters, dispatch }) => {
});
if (!Visibility.hidden()) {
eTagPoll.makeRequest();
eTagPoll.makeDelayedRequest(2500);
} else {
dispatch('fetchData');
}
......
......@@ -29,6 +29,8 @@ describe('EpicAppComponent', () => {
vm = mountComponentWithStore(Component, {
store,
});
jest.advanceTimersByTime(2);
});
afterEach(() => {
......
......@@ -29,6 +29,8 @@ describe('EpicBodyComponent', () => {
vm = mountComponentWithStore(Component, {
store,
});
jest.advanceTimersByTime(5);
});
afterEach(() => {
......
......@@ -78,6 +78,8 @@ describe('Issuable output', () => {
});
mountComponent();
jest.advanceTimersByTime(2);
});
afterEach(() => {
......
......@@ -330,6 +330,8 @@ describe('note_app', () => {
wrapper.vm.$parent.$el.dispatchEvent(toggleAwardEvent);
jest.advanceTimersByTime(2);
expect(toggleAwardAction).toHaveBeenCalledTimes(1);
const [, payload] = toggleAwardAction.mock.calls[0];
......
......@@ -335,6 +335,9 @@ describe('Actions Notes Store', () => {
it('calls service with last fetched state', done => {
store
.dispatch('poll')
.then(() => {
jest.advanceTimersByTime(2);
})
.then(() => new Promise(resolve => requestAnimationFrame(resolve)))
.then(() => {
expect(store.state.lastFetchedAt).toBe('123456');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment