Merge pull request #3034 from Human-Connection/3033-fix-block-users-bug

fix: Display unblock feature only for blocking user
This commit is contained in:
mattwr18 2020-02-10 17:11:35 +01:00 committed by GitHub
commit de793e336c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 6 deletions

View File

@ -252,9 +252,11 @@ export default {
followedByCurrentUser:
'MATCH (this)<-[:FOLLOWS]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
blocked:
'MATCH (this)<-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
'MATCH (this)-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
isMuted:
'MATCH (this)<-[:MUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
isBlocked:
'MATCH (this)<-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
},
count: {
contributionsCount:

View File

@ -68,7 +68,12 @@ type User {
RETURN COUNT(u) >= 1
"""
)
isBlocked: Boolean! @cypher(
statement: """
MATCH (this)<-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})
RETURN COUNT(user) >= 1
"""
)
blocked: Boolean! @cypher(
statement: """
MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})

View File

@ -545,6 +545,20 @@ When("I block the user {string}", name => {
});
});
When("a user has blocked me", () => {
cy.neode()
.first("User", {
name: narratorParams.name
})
.then(blockedUser => {
cy.neode()
.first("User", {
name: 'Harassing User'
})
.relateTo(blockedUser, "blocked");
});
});
When("I log in with:", table => {
const [firstRow] = table.hashes();
const {
@ -571,3 +585,24 @@ Then("they should not see the comment form", () => {
Then("they should see a text explaining why commenting is not possible", () => {
cy.get('.ds-placeholder').should('contain', "Commenting is not possible at this time on this post.")
})
Then("I should see no users in my blocked users list", () => {
cy.get('.ds-placeholder')
.should('contain', "So far, you have not blocked anybody.")
})
Then("I {string} see {string} from the content menu in the user info box", (condition, link) => {
cy.get(".user-content-menu .base-button").click()
cy.get(".popover .ds-menu-item-link")
.should(condition === 'should' ? 'contain' : 'not.contain', link)
})
Then('I should not see {string} button', button => {
cy.get('.ds-card-content .action-buttons')
.should('have.length', 1)
})
Then('I should see the {string} button', button => {
cy.get('.ds-card-content .action-buttons .base-button')
.should('contain', button)
})

View File

@ -11,6 +11,7 @@ Feature: Block a User
Scenario: Block a user
Given I am on the profile page of the annoying user
When I click on "Block user" from the content menu in the user info box
And I "should" see "Unblock user" from the content menu in the user info box
And I navigate to my "Blocked users" settings page
Then I can see the following table:
| Avatar | Name |
@ -28,6 +29,7 @@ Feature: Block a User
When I visit the profile page of the annoying user
And I click on "Block user" from the content menu in the user info box
And I get removed from his follower collection
And I "should" see "Unblock user" from the content menu in the user info box
Scenario: Posts of blocked users are not filtered from search results
Given "Harassing User" wrote a post "You can still see my posts"
@ -44,3 +46,15 @@ Feature: Block a User
Then I should see the following posts in the select dropdown:
| title |
| previously created post |
Scenario: Blocked users cannot see they are blocked in their list
Given a user has blocked me
And I navigate to my "Blocked users" settings page
Then I should see no users in my blocked users list
Scenario: Blocked users should not see link or button to unblock, only blocking users
Given a user has blocked me
When I visit the profile page of the annoying user
And I "should not" see "Unblock user" from the content menu in the user info box
And I should see the "Follow" button
And I should not see "Unblock user" button

View File

@ -172,7 +172,7 @@ export default {
icon: 'microphone-slash',
})
}
if (this.resource.blocked) {
if (this.resource.isBlocked) {
routes.push({
label: this.$t(`settings.blocked-users.unblock`),
callback: () => {

View File

@ -24,6 +24,7 @@ export default i18n => {
createdAt
followedByCurrentUser
isMuted
isBlocked
blocked
following(first: 7) {
...user

View File

@ -97,7 +97,7 @@
:post="post"
@createComment="createComment"
/>
<ds-placeholder v-else>
<ds-placeholder v-if="post.author.blocked">
{{ $t('settings.blocked-users.explanation.commenting-disabled') }}
<br />
{{ $t('settings.blocked-users.explanation.commenting-explanation') }}

View File

@ -67,14 +67,14 @@
</ds-flex-item>
</ds-flex>
<div v-if="!myProfile" class="action-buttons">
<base-button v-if="user.blocked" @click="unblockUser(user)">
<base-button v-if="user.isBlocked" @click="unblockUser(user)">
{{ $t('settings.blocked-users.unblock') }}
</base-button>
<base-button v-if="user.isMuted" @click="unmuteUser(user)">
{{ $t('settings.muted-users.unmute') }}
</base-button>
<hc-follow-button
v-if="!(user.blocked || user.isMuted)"
v-if="!user.isMuted && !user.isBlocked"
:follow-id="user.id"
:is-followed="user.followedByCurrentUser"
@optimistic="optimisticFollow"