From d39ace5a6b04f3bef01e0e8c1cc2aecc7c656ea2 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Tue, 8 Nov 2022 21:05:13 -0800 Subject: [PATCH] feat: Improve image loading for thumbnails (#5823) --- .../components/widgets/Thumbnail.spec.js | 8 +++++--- .../components/widgets/Thumbnail.vue | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/javascript/dashboard/components/widgets/Thumbnail.spec.js b/app/javascript/dashboard/components/widgets/Thumbnail.spec.js index bcb881d09..1ea5e6cc6 100644 --- a/app/javascript/dashboard/components/widgets/Thumbnail.spec.js +++ b/app/javascript/dashboard/components/widgets/Thumbnail.spec.js @@ -10,13 +10,14 @@ describe('Thumbnail.vue', () => { }, data() { return { + hasImageLoaded: true, imgError: false, }; }, }); expect(wrapper.find('.user-thumbnail').exists()).toBe(true); const avatarComponent = wrapper.findComponent(Avatar); - expect(avatarComponent.exists()).toBe(false); + expect(avatarComponent.isVisible()).toBe(false); }); it('should render the avatar component if invalid image is passed', () => { @@ -26,13 +27,14 @@ describe('Thumbnail.vue', () => { }, data() { return { + hasImageLoaded: true, imgError: true, }; }, }); - expect(wrapper.find('.avatar-container').exists()).toBe(true); + expect(wrapper.find('#image').exists()).toBe(false); const avatarComponent = wrapper.findComponent(Avatar); - expect(avatarComponent.exists()).toBe(true); + expect(avatarComponent.isVisible()).toBe(true); }); it('should the initial of the name if no image is passed', () => { diff --git a/app/javascript/dashboard/components/widgets/Thumbnail.vue b/app/javascript/dashboard/components/widgets/Thumbnail.vue index 9cc4d7100..649cac990 100644 --- a/app/javascript/dashboard/components/widgets/Thumbnail.vue +++ b/app/javascript/dashboard/components/widgets/Thumbnail.vue @@ -1,13 +1,15 @@