Skip to content

Commit

Permalink
tests fixed for clickedCount
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogge committed Feb 22, 2021
1 parent f2d34cc commit 96066ea
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 129 deletions.
1 change: 1 addition & 0 deletions webapp/components/PostTeaser/PostTeaser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('PostTeaser', () => {
disabled: false,
shoutedCount: 0,
commentsCount: 0,
clickedCount: 0,
name: 'It is a post',
author: {
id: 'u1',
Expand Down
1 change: 1 addition & 0 deletions webapp/components/PostTeaser/PostTeaser.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const post = {
shoutedCount: 5,
commentedCount: 39,
followedByCount: 2,
clickedCount: 42,
followedByCurrentUser: true,
location: null,
badges: [
Expand Down
258 changes: 129 additions & 129 deletions webapp/components/PostTeaser/PostTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<base-card
:lang="post.language"
:class="{
'disabled-content': post.disabled,
'--blur-image': post.image && post.image.sensitive,
}"
'disabled-content': post.disabled,
'--blur-image': post.image && post.image.sensitive,
}"
:highlight="isPinned"
>
<template v-if="post.image" #heroImage>
Expand Down Expand Up @@ -59,143 +59,143 @@
</template>

<script>
import UserTeaser from '~/components/UserTeaser/UserTeaser'
import ContentMenu from '~/components/ContentMenu/ContentMenu'
import HcRibbon from '~/components/Ribbon'
import CounterIcon from '~/components/_new/generic/CounterIcon/CounterIcon'
import { mapGetters } from 'vuex'
import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers'
import UserTeaser from '~/components/UserTeaser/UserTeaser'
import ContentMenu from '~/components/ContentMenu/ContentMenu'
import HcRibbon from '~/components/Ribbon'
import CounterIcon from '~/components/_new/generic/CounterIcon/CounterIcon'
import { mapGetters } from 'vuex'
import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers'
export default {
name: 'PostTeaser',
components: {
UserTeaser,
HcRibbon,
ContentMenu,
CounterIcon,
},
props: {
post: {
type: Object,
required: true,
},
width: {
type: Object,
default: () => {},
},
},
mounted() {
const { image } = this.post
if (!image) return
const width = this.$el.offsetWidth
const height = Math.min(width / image.aspectRatio, 2000)
const imageElement = this.$el.querySelector('.hero-image')
if (imageElement) {
imageElement.style.height = `${height}px`
}
},
computed: {
...mapGetters({
user: 'auth/user',
}),
excerpt() {
return this.$filters.removeLinks(this.post.contentExcerpt)
},
isAuthor() {
const { author } = this.post
if (!author) return false
return this.user.id === this.post.author.id
},
menuModalsData() {
return postMenuModalsData(
// "this.post" may not always be defined at the beginning …
this.post ? this.$filters.truncate(this.post.title, 30) : '',
this.deletePostCallback,
)
},
isPinned() {
return this.post && this.post.pinned
},
},
methods: {
async deletePostCallback() {
try {
const {
data: { DeletePost },
} = await this.$apollo.mutate(deletePostMutation(this.post.id))
this.$toast.success(this.$t('delete.contribution.success'))
this.$emit('removePostFromList', DeletePost)
} catch (err) {
this.$toast.error(err.message)
}
},
pinPost(post) {
this.$emit('pinPost', post)
},
unpinPost(post) {
this.$emit('unpinPost', post)
},
},
}
export default {
name: 'PostTeaser',
components: {
UserTeaser,
HcRibbon,
ContentMenu,
CounterIcon,
},
props: {
post: {
type: Object,
required: true,
},
width: {
type: Object,
default: () => {},
},
},
mounted() {
const { image } = this.post
if (!image) return
const width = this.$el.offsetWidth
const height = Math.min(width / image.aspectRatio, 2000)
const imageElement = this.$el.querySelector('.hero-image')
if (imageElement) {
imageElement.style.height = `${height}px`
}
},
computed: {
...mapGetters({
user: 'auth/user',
}),
excerpt() {
return this.$filters.removeLinks(this.post.contentExcerpt)
},
isAuthor() {
const { author } = this.post
if (!author) return false
return this.user.id === this.post.author.id
},
menuModalsData() {
return postMenuModalsData(
// "this.post" may not always be defined at the beginning …
this.post ? this.$filters.truncate(this.post.title, 30) : '',
this.deletePostCallback,
)
},
isPinned() {
return this.post && this.post.pinned
},
},
methods: {
async deletePostCallback() {
try {
const {
data: { DeletePost },
} = await this.$apollo.mutate(deletePostMutation(this.post.id))
this.$toast.success(this.$t('delete.contribution.success'))
this.$emit('removePostFromList', DeletePost)
} catch (err) {
this.$toast.error(err.message)
}
},
pinPost(post) {
this.$emit('pinPost', post)
},
unpinPost(post) {
this.$emit('unpinPost', post)
},
},
}
</script>
<style lang="scss">
.post-teaser,
.post-teaser:hover,
.post-teaser:active {
position: relative;
display: block;
height: 100%;
color: $text-color-base;
.post-teaser,
.post-teaser:hover,
.post-teaser:active {
position: relative;
display: block;
height: 100%;
color: $text-color-base;
> .ribbon {
position: absolute;
top: 50%;
right: -7px;
}
}
> .ribbon {
position: absolute;
top: 50%;
right: -7px;
}
}
.post-teaser > .base-card {
display: flex;
flex-direction: column;
height: 100%;
.post-teaser > .base-card {
display: flex;
flex-direction: column;
height: 100%;
&.--blur-image > .hero-image > .image {
filter: blur($blur-radius);
}
&.--blur-image > .hero-image > .image {
filter: blur($blur-radius);
}
> .content {
flex-grow: 1;
margin-bottom: $space-small;
}
> .content {
flex-grow: 1;
margin-bottom: $space-small;
}
> .footer {
display: flex;
justify-content: space-between;
align-items: center;
> .footer {
display: flex;
justify-content: space-between;
align-items: center;
> .categories-placeholder {
flex-grow: 1;
}
> .categories-placeholder {
flex-grow: 1;
}
> .counter-icon {
display: block;
margin-right: $space-small;
opacity: $opacity-disabled;
}
> .counter-icon {
display: block;
margin-right: $space-small;
opacity: $opacity-disabled;
}
> .content-menu {
position: relative;
z-index: $z-index-post-teaser-link;
}
> .content-menu {
position: relative;
z-index: $z-index-post-teaser-link;
}
.ds-tag {
margin: 0;
margin-right: $space-xx-small;
}
}
.ds-tag {
margin: 0;
margin-right: $space-xx-small;
}
}
.user-teaser {
margin-bottom: $space-small;
}
}
.user-teaser {
margin-bottom: $space-small;
}
}
</style>
1 change: 1 addition & 0 deletions webapp/components/generic/SearchPost/SearchPost.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('SearchPost.vue', () => {
title: 'Post Title',
commentsCount: 3,
shoutedCount: 6,
clickedCount: 5,
createdAt: '23.08.2019',
author: {
name: 'Post Author',
Expand Down
1 change: 1 addition & 0 deletions webapp/components/generic/SearchPost/SearchPost.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<span class="counts">
<counter-icon icon="comments" :count="option.commentsCount" soft />
<counter-icon icon="bullhorn" :count="option.shoutedCount" soft />
<counter-icon icon="eye" :count="option.clickedCount" soft />
</span>
{{ option.author.name | truncate(32) }} - {{ option.createdAt | dateTime('dd.MM.yyyy') }}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const searchResults = [
value: 'User Post by Jenny',
shoutedCount: 0,
commentsCount: 4,
clickedCount: 8,
createdAt: '2019-11-13T03:03:16.155Z',
author: {
id: 'u3',
Expand All @@ -29,6 +30,7 @@ export const searchResults = [
value: 'Eum quos est molestiae enim magni consequuntur sed commodi eos.',
shoutedCount: 0,
commentsCount: 0,
clickedCount: 9,
createdAt: '2019-11-13T03:00:45.478Z',
author: {
id: 'u6',
Expand All @@ -44,6 +46,7 @@ export const searchResults = [
value: 'This is post #7',
shoutedCount: 1,
commentsCount: 1,
clickedCount: 1,
createdAt: '2019-11-13T03:00:23.098Z',
author: {
id: 'u6',
Expand All @@ -59,6 +62,7 @@ export const searchResults = [
value: 'This is post #12',
shoutedCount: 0,
commentsCount: 12,
clickedCount: 14,
createdAt: '2019-11-13T03:00:23.098Z',
author: {
id: 'u6',
Expand Down
2 changes: 2 additions & 0 deletions webapp/graphql/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const searchQuery = gql`
...post
commentsCount
shoutedCount
clickedCount
author {
...user
}
Expand Down Expand Up @@ -40,6 +41,7 @@ export const searchPosts = gql`
...tagsCategoriesAndPinned
commentsCount
shoutedCount
clickedCount
author {
...user
}
Expand Down
1 change: 1 addition & 0 deletions webapp/storybook/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const helpers = {
slug: faker.lorem.slug(title),
shoutedCount: faker.random.number(),
commentsCount: faker.random.number(),
clickedCount: faker.random.number(),
}
})
},
Expand Down

0 comments on commit 96066ea

Please sign in to comment.