diff --git a/app/javascript/dashboard/components/widgets/Avatar.vue b/app/javascript/dashboard/components/widgets/Avatar.vue new file mode 100644 index 000000000..25875e13c --- /dev/null +++ b/app/javascript/dashboard/components/widgets/Avatar.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/app/javascript/dashboard/components/widgets/Thumbnail.spec.js b/app/javascript/dashboard/components/widgets/Thumbnail.spec.js new file mode 100644 index 000000000..5de534dbe --- /dev/null +++ b/app/javascript/dashboard/components/widgets/Thumbnail.spec.js @@ -0,0 +1,48 @@ +import { mount } from '@vue/test-utils'; +import Avatar from './Avatar.vue'; +import Thumbnail from './Thumbnail.vue'; + +describe(`when there are NO errors loading the thumbnail`, () => { + it(`should render the agent thumbnail`, () => { + const wrapper = mount(Thumbnail, { + propsData: { + src: 'https://some_valid_url.com', + }, + data() { + return { + imgError: false, + }; + }, + }); + expect(wrapper.find('#image').exists()).toBe(true); + expect(wrapper.contains(Avatar)).toBe(false); + }); +}); + +describe(`when there ARE errors loading the thumbnail`, () => { + it(`should render the agent avatar`, () => { + const wrapper = mount(Thumbnail, { + propsData: { + src: 'https://some_invalid_url.com', + }, + data() { + return { + imgError: true, + }; + }, + }); + expect(wrapper.contains('#image')).toBe(false); + expect(wrapper.contains(Avatar)).toBe(true); + }); +}); + +describe(`when Avatar shows`, () => { + it(`initials shold correspond to username`, () => { + const wrapper = mount(Avatar, { + propsData: { + username: 'Angie Rojas', + }, + }); + expect(wrapper.find('span').text()).toBe('AR'); + }); +}); diff --git a/app/javascript/dashboard/components/widgets/Thumbnail.vue b/app/javascript/dashboard/components/widgets/Thumbnail.vue index 2b5a54d68..e833a1ae2 100644 --- a/app/javascript/dashboard/components/widgets/Thumbnail.vue +++ b/app/javascript/dashboard/components/widgets/Thumbnail.vue @@ -1,7 +1,26 @@ diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue index f332a6b7f..324776793 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationCard.vue @@ -8,6 +8,8 @@ :src="chat.meta.sender.thumbnail" :badge="chat.meta.sender.channel" class="columns" + :username="chat.meta.sender.name" + size="40px" />

diff --git a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue index cdeb5b6be..ce0979d68 100644 --- a/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue +++ b/app/javascript/dashboard/components/widgets/conversation/ConversationHeader.vue @@ -5,6 +5,7 @@ :src="chat.meta.sender.thumbnail" size="40px" :badge="chat.meta.sender.channel" + :username="chat.meta.sender.name" />

{{ chat.meta.sender.name }} diff --git a/package.json b/package.json index e87eac70b..ee3c489e1 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ }, "devDependencies": { "@vue/babel-preset-app": "^3.11.0", + "@vue/test-utils": "^1.0.0-beta.29", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^24.9.0", diff --git a/yarn.lock b/yarn.lock index 1a5033428..55c6ab1b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1234,6 +1234,14 @@ source-map "~0.6.1" vue-template-es2015-compiler "^1.9.0" +"@vue/test-utils@^1.0.0-beta.29": + version "1.0.0-beta.29" + resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.29.tgz#c942cf25e891cf081b6a03332b4ae1ef430726f0" + integrity sha512-yX4sxEIHh4M9yAbLA/ikpEnGKMNBCnoX98xE1RwxfhQVcn0MaXNSj1Qmac+ZydTj6VBSEVukchBogXBTwc+9iA== + dependencies: + dom-event-types "^1.0.0" + lodash "^4.17.4" + "@webassemblyjs/ast@1.8.5": version "1.8.5" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359" @@ -3352,6 +3360,11 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" +dom-event-types@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/dom-event-types/-/dom-event-types-1.0.0.tgz#5830a0a29e1bf837fe50a70cd80a597232813cae" + integrity sha512-2G2Vwi2zXTHBGqXHsJ4+ak/iP0N8Ar+G8a7LiD2oup5o4sQWytwqqrZu/O6hIMV0KMID2PL69OhpshLO0n7UJQ== + dom-serializer@0: version "0.2.1" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.2.1.tgz#13650c850daffea35d8b626a4cfc4d3a17643fdb"