Display unblock feature only for blocking user

- add hasBlocked query to check if userA initiated the blocking and, if
  true, only them to unblock userB.
- add cypress tests to make sure we don't break this in the future.
This commit is contained in:
mattwr18 2020-02-10 12:34:40 +01:00
parent 403376418f
commit 3b29d480e3
5 changed files with 50 additions and 4 deletions

View File

@ -68,7 +68,12 @@ type User {
RETURN COUNT(u) >= 1
"""
)
hasBlocked: 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

@ -558,6 +558,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 {
@ -583,4 +597,20 @@ Then("they should not see the comment from", () => {
Then("they should see a text explaining 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 should not see {string} from the content menu in the user info box", link => {
cy.get(".user-content-menu .base-button").click()
cy.get(".popover .ds-menu-item-link")
.should('not.contain', link)
})
Then('I should not see {string} button', button => {
cy.get('.ds-card-content')
.should('not.contain', '.action-buttons')
})

View File

@ -44,3 +44,14 @@ 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 not see "Unblock user" button

View File

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

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.hasBlocked" @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.hasBlocked || user.isMuted)"
:follow-id="user.id"
:is-followed="user.followedByCurrentUser"
@optimistic="optimisticFollow"