diff --git a/backend/src/seed/factories/posts.js b/backend/src/seed/factories/posts.js index d1a46d71b..55f4f95fb 100644 --- a/backend/src/seed/factories/posts.js +++ b/backend/src/seed/factories/posts.js @@ -36,7 +36,6 @@ export default function create() { if (categoryIds) categories = await Promise.all(categoryIds.map(id => neodeInstance.find('Category', id))) categories = categories || (await Promise.all([factoryInstance.create('Category')])) - const { tagIds = [] } = args delete args.tags const tags = await Promise.all( diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 23c655097..dbbb96645 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -29,10 +29,20 @@ const narratorParams = { ...termsAndConditionsAgreedVersion, }; +const annoyingParams = { + email: "spammy-spammer@example.org", + password: "1234", + ...termsAndConditionsAgreedVersion +}; + Given("I am logged in", () => { cy.login(loginCredentials); }); +Given("I am logged in as the blacklisted user", () => { + cy.login({ email: annoyingParams.email, password: '1234' }); +}); + Given("we have a selection of categories", () => { cy.createCategories("cat0", "just-for-fun"); }); @@ -227,7 +237,6 @@ Given("I previously created a post", () => { lastPost.authorId = narratorParams.id lastPost.title = "previously created post"; lastPost.content = "with some content"; - lastPost.categoryIds = ["cat0"]; cy.factory() .create("Post", lastPost); }); @@ -407,11 +416,6 @@ Then("there are no notifications in the top menu", () => { }); Given("there is an annoying user called {string}", name => { - const annoyingParams = { - email: "spammy-spammer@example.org", - password: "1234", - ...termsAndConditionsAgreedVersion - }; cy.factory().create("User", { ...annoyingParams, id: "annoying-user", @@ -519,12 +523,12 @@ When("I blacklist the user {string}", name => { .first("User", { name }) - .then(blacklisted => { + .then(blacklistedUser => { cy.neode() .first("User", { name: narratorParams.name }) - .relateTo(blacklisted, "blacklisted"); + .relateTo(blacklistedUser, "blacklisted"); }); }); diff --git a/cypress/integration/user_profile/blacklist-users/Blacklist.feature b/cypress/integration/user_profile/blacklist-users/Blacklist.feature index b62ad0e76..5548f68d5 100644 --- a/cypress/integration/user_profile/blacklist-users/Blacklist.feature +++ b/cypress/integration/user_profile/blacklist-users/Blacklist.feature @@ -26,7 +26,7 @@ Feature: Blacklist a User Scenario: Posts of blacklisted users are filtered from search results Given we have the following posts in our database: - | id | title | content | + | id | title | content | | im-not-blacklisted | Post that should be seen | cause I'm not blacklisted | Given "Spammy Spammer" wrote a post "Spam Spam Spam" When I search for "Spam" @@ -41,3 +41,13 @@ Feature: Blacklist a User Then I should see the following posts in the select dropdown: | title | | Post that should be seen | + + Scenario: Blacklisted users can still see my posts + Given I previously created a post + And I blacklist the user "Spammy Spammer" + Given I log out + And I am logged in as the blacklisted user + When I search for "previously created" + Then I should see the following posts in the select dropdown: + | title | + | previously created post | diff --git a/cypress/integration/user_profile/blacklist-users/Content.feature b/cypress/integration/user_profile/blacklist-users/Content.feature index 4cf5281fb..7714026ce 100644 --- a/cypress/integration/user_profile/blacklist-users/Content.feature +++ b/cypress/integration/user_profile/blacklist-users/Content.feature @@ -10,7 +10,7 @@ Feature: Blacklist a User Scenario Outline: Blacklisted users cannot see each others posts Given "Spammy Spammer" wrote a post "Spam Spam Spam" And I wrote a post "I hate spammers" - And I block the user "Spammy Spammer" + And I I blacklist the user "Spammy Spammer" When I log in with: | Email | Password | | | | diff --git a/cypress/support/commands.js b/cypress/support/commands.js index f52b38faf..c9a2e213a 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -60,7 +60,7 @@ Cypress.Commands.add("login", ({ email, password }) => { .as("submitButton") .click(); cy.get(".iziToast-message").should("contain", "You are logged in!"); - cy.get(".iziToast-close").click(); + cy.location("pathname").should("eq", "/"); }); Cypress.Commands.add("logout", (email, password) => { diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 8169e2dc7..4b67acba7 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -22,8 +22,8 @@ :resource="user" :is-owner="myProfile" class="user-content-menu" - @blacklist="blacklist" - @whitelist="whitelist" + @blacklist="blacklistUserContent" + @whitelist="whitelistUserContent" /> @@ -399,16 +399,26 @@ export default { this.hasMore = true }, async blacklistUserContent(user) { - await this.$apollo.mutate({ mutation: blacklistUserContent(), variables: { id: user.id } }) - this.$apollo.queries.User.refetch() - this.resetPostList() - this.$apollo.queries.profilePagePosts.refetch() + try { + await this.$apollo.mutate({ mutation: blacklistUserContent(), variables: { id: user.id } }) + } catch (error) { + this.$toast.error(error.message) + } finally { + this.$apollo.queries.User.refetch() + this.resetPostList() + this.$apollo.queries.profilePagePosts.refetch() + } }, async whitelistUserContent(user) { - await this.$apollo.mutate({ mutation: whitelistUserContent(), variables: { id: user.id } }) - this.$apollo.queries.User.refetch() - this.resetPostList() - this.$apollo.queries.profilePagePosts.refetch() + try { + this.$apollo.mutate({ mutation: whitelistUserContent(), variables: { id: user.id } }) + } catch (error) { + this.$toast.error(error.message) + } finally { + this.$apollo.queries.User.refetch() + this.resetPostList() + this.$apollo.queries.profilePagePosts.refetch() + } }, pinPost(post) { this.$apollo diff --git a/webapp/pages/settings/blacklisted-users.vue b/webapp/pages/settings/blacklisted-users.vue index b862f7dcd..50aa27f21 100644 --- a/webapp/pages/settings/blacklisted-users.vue +++ b/webapp/pages/settings/blacklisted-users.vue @@ -98,7 +98,7 @@ export default { avatar: '', name: this.$t('settings.blacklisted-users.columns.name'), slug: this.$t('settings.blacklisted-users.columns.slug'), - whitelistUserContent: this.$t('settings.blacklisted-users.columns.unblock'), + whitelistUserContent: this.$t('settings.blacklisted-users.columns.whitelist'), } }, },