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 { ...@@ -247,7 +247,7 @@ export default {
}); });
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
this.poll.makeRequest(); this.poll.makeDelayedRequest(2000);
} }
Visibility.change(() => { Visibility.change(() => {
......
...@@ -88,7 +88,11 @@ export default class Poll { ...@@ -88,7 +88,11 @@ export default class Poll {
} }
makeDelayedRequest(delay = 0) { 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() { makeRequest() {
......
...@@ -475,7 +475,7 @@ export const poll = ({ commit, state, getters, dispatch }) => { ...@@ -475,7 +475,7 @@ export const poll = ({ commit, state, getters, dispatch }) => {
}); });
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
eTagPoll.makeRequest(); eTagPoll.makeDelayedRequest(2500);
} else { } else {
dispatch('fetchData'); dispatch('fetchData');
} }
......
...@@ -29,6 +29,8 @@ describe('EpicAppComponent', () => { ...@@ -29,6 +29,8 @@ describe('EpicAppComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
jest.advanceTimersByTime(2);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -29,6 +29,8 @@ describe('EpicBodyComponent', () => { ...@@ -29,6 +29,8 @@ describe('EpicBodyComponent', () => {
vm = mountComponentWithStore(Component, { vm = mountComponentWithStore(Component, {
store, store,
}); });
jest.advanceTimersByTime(5);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -78,6 +78,8 @@ describe('Issuable output', () => { ...@@ -78,6 +78,8 @@ describe('Issuable output', () => {
}); });
mountComponent(); mountComponent();
jest.advanceTimersByTime(2);
}); });
afterEach(() => { afterEach(() => {
......
...@@ -330,6 +330,8 @@ describe('note_app', () => { ...@@ -330,6 +330,8 @@ describe('note_app', () => {
wrapper.vm.$parent.$el.dispatchEvent(toggleAwardEvent); wrapper.vm.$parent.$el.dispatchEvent(toggleAwardEvent);
jest.advanceTimersByTime(2);
expect(toggleAwardAction).toHaveBeenCalledTimes(1); expect(toggleAwardAction).toHaveBeenCalledTimes(1);
const [, payload] = toggleAwardAction.mock.calls[0]; const [, payload] = toggleAwardAction.mock.calls[0];
......
...@@ -335,6 +335,9 @@ describe('Actions Notes Store', () => { ...@@ -335,6 +335,9 @@ describe('Actions Notes Store', () => {
it('calls service with last fetched state', done => { it('calls service with last fetched state', done => {
store store
.dispatch('poll') .dispatch('poll')
.then(() => {
jest.advanceTimersByTime(2);
})
.then(() => new Promise(resolve => requestAnimationFrame(resolve))) .then(() => new Promise(resolve => requestAnimationFrame(resolve)))
.then(() => { .then(() => {
expect(store.state.lastFetchedAt).toBe('123456'); 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