diff --git a/src/desktop/apps/artist/client/views/overview.coffee b/src/desktop/apps/artist/client/views/overview.coffee index d28fabbacce..c83901b8a6d 100644 --- a/src/desktop/apps/artist/client/views/overview.coffee +++ b/src/desktop/apps/artist/client/views/overview.coffee @@ -35,6 +35,7 @@ module.exports = class OverviewView extends Backbone.View artists: @statuses.artists articles: @statuses.articles shows: @statuses.shows || @statuses.cv + loggedOut: !@user .then ({ artist }) => @trigger 'artist:overview:sync', artist setupBlurb: -> diff --git a/src/desktop/apps/artist/queries/overview.coffee b/src/desktop/apps/artist/queries/overview.coffee index a3e9caa8e5c..e2e82ca44f6 100644 --- a/src/desktop/apps/artist/queries/overview.coffee +++ b/src/desktop/apps/artist/queries/overview.coffee @@ -1,6 +1,6 @@ module.exports = """ - query artist($artist_id: String!, $shows: Boolean!, $artists: Boolean!, $articles: Boolean!) { + query artist($artist_id: String!, $shows: Boolean!, $artists: Boolean!, $articles: Boolean!, $loggedOut: Boolean!) { artist(id: $artist_id) { counts { shows: partner_shows @@ -15,7 +15,7 @@ module.exports = artists (size: 15) @include(if: $artists){ ... artistCell } - cta_artists: artists(size: 1) { + cta_artists: artists(size: 1) @include(if: $loggedOut){ image { thumb: resized(width: 150, version: "square") { url diff --git a/src/desktop/components/artist_page_cta/templates/overlay.jade b/src/desktop/components/artist_page_cta/templates/overlay.jade index 07d99ff1e88..dbb1ac933cd 100644 --- a/src/desktop/components/artist_page_cta/templates/overlay.jade +++ b/src/desktop/components/artist_page_cta/templates/overlay.jade @@ -16,7 +16,7 @@ - var count = 7 - var name = artist.get('name') include ./row.jade - if artist.get('cta_artists')[0] + if artist.get('cta_artists') && artist.get('cta_artists')[0] li - var image = artist.get('cta_artists')[0].image.thumb.url - var count = 3 diff --git a/src/desktop/components/artist_page_cta/test/template.coffee b/src/desktop/components/artist_page_cta/test/template.coffee new file mode 100644 index 00000000000..a17a5c014f2 --- /dev/null +++ b/src/desktop/components/artist_page_cta/test/template.coffee @@ -0,0 +1,53 @@ +_ = require 'underscore' +$ = require 'cheerio' +benv = require 'benv' +jade = require 'jade' +{ fabricate } = require 'antigravity' +Artist = require '../../../models/artist' + +templates = + overlay: jade.compileFile(require.resolve '../templates/overlay.jade') + +describe 'templates', -> + before (done) -> + benv.setup => + @artist = new Artist fabricate 'artist', name: 'Seth Clark', cta_image: thumb: url: 'http://thumb.jpg' + benv.expose + sd: AP: 'http://test.test' + done() + + after -> + benv.teardown() + + describe 'when there are null cta artists', -> + beforeEach -> + @artist.set cta_artists: null + @data = _.extend {}, { artist: @artist } + + it 'renders correctly', -> + $template = $(templates.overlay @data) + $template.find('.artist-page-cta-overlay__feed__items__row').length.should.equal 1 + text = $template.find('.artist-page-cta-overlay__headline').text() + text.should.equal 'Join Artsy to discover new works by Seth Clark and more artists you love' + + describe 'when there are null cta artists', -> + beforeEach -> + @artist.set cta_artists: [] + @data = _.extend {}, { artist: @artist } + + it 'renders correctly', -> + $template = $(templates.overlay @data) + $template.find('.artist-page-cta-overlay__feed__items__row').length.should.equal 1 + text = $template.find('.artist-page-cta-overlay__headline').text() + text.should.equal 'Join Artsy to discover new works by Seth Clark and more artists you love' + + describe 'when there are some cta artists', -> + beforeEach -> + @artist.set cta_artists: [{ name: 'Drew Conrad', image: { thumb: { url: 'http://thumb1.jpg' } } }] + @data = _.extend {}, { artist: @artist } + + it 'renders correctly', -> + $template = $(templates.overlay @data) + $template.find('.artist-page-cta-overlay__feed__items__row').length.should.equal 2 + text = $($template.find('.artist-page-cta-overlay__feed__items__row__artist-info')[1]).text() + text.should.equal '3 New WorksTodayDrew Conrad'