mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
Fix/extend cypress tests
This commit is contained in:
parent
c297b83f87
commit
cd7f0e2783
@ -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(
|
||||
|
||||
@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -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 |
|
||||
|
||||
@ -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 |
|
||||
| <email> | <password> |
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
:resource="user"
|
||||
:is-owner="myProfile"
|
||||
class="user-content-menu"
|
||||
@blacklist="blacklist"
|
||||
@whitelist="whitelist"
|
||||
@blacklist="blacklistUserContent"
|
||||
@whitelist="whitelistUserContent"
|
||||
/>
|
||||
</client-only>
|
||||
<ds-space margin="small">
|
||||
@ -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
|
||||
|
||||
@ -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'),
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user