From 6b8fac9de471646b36a822e2b18e1b3a97965288 Mon Sep 17 00:00:00 2001 From: Simon Knox Date: Wed, 17 May 2017 19:50:40 +1000 Subject: [PATCH] add loading spinner to sidebar assignees store isFetching state to indicate if assignees has initial data --- .../components/assignees/sidebar_assignees.js | 3 ++- .../javascripts/sidebar/stores/sidebar_store.js | 4 ++++ .../shared/issuable/_sidebar_assignees.html.haml | 3 +++ spec/javascripts/sidebar/sidebar_assignees_spec.js | 12 ++++++++++++ spec/javascripts/sidebar/sidebar_store_spec.js | 5 +++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js index 1488a66c695..da4abf0b68f 100644 --- a/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js +++ b/app/assets/javascripts/sidebar/components/assignees/sidebar_assignees.js @@ -69,10 +69,11 @@ export default {
{ expect(SidebarMediator.prototype.assignYourself).toHaveBeenCalled(); expect(this.mediator.store.assignees.length).toEqual(1); }); + + it('hides assignees until fetched', (done) => { + component = new SidebarAssigneeComponent().$mount(this.sidebarAssigneesEl); + const currentAssignee = this.sidebarAssigneesEl.querySelector('.value'); + expect(currentAssignee).toBe(null); + + component.store.isFetching.assignees = false; + Vue.nextTick(() => { + expect(component.$el.querySelector('.value')).toBeVisible(); + done(); + }); + }); }); diff --git a/spec/javascripts/sidebar/sidebar_store_spec.js b/spec/javascripts/sidebar/sidebar_store_spec.js index 29facf483b5..b3fa156eb64 100644 --- a/spec/javascripts/sidebar/sidebar_store_spec.js +++ b/spec/javascripts/sidebar/sidebar_store_spec.js @@ -35,6 +35,10 @@ describe('Sidebar store', () => { SidebarStore.singleton = null; }); + it('has default isFetching values', () => { + expect(this.store.isFetching.assignees).toBe(true); + }); + it('adds a new assignee', () => { this.store.addAssignee(assignee); expect(this.store.assignees.length).toEqual(1); @@ -67,6 +71,7 @@ describe('Sidebar store', () => { }; this.store.setAssigneeData(users); + expect(this.store.isFetching.assignees).toBe(false); expect(this.store.assignees.length).toEqual(3); });