mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +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)
|
if (categoryIds)
|
||||||
categories = await Promise.all(categoryIds.map(id => neodeInstance.find('Category', id)))
|
categories = await Promise.all(categoryIds.map(id => neodeInstance.find('Category', id)))
|
||||||
categories = categories || (await Promise.all([factoryInstance.create('Category')]))
|
categories = categories || (await Promise.all([factoryInstance.create('Category')]))
|
||||||
|
|
||||||
const { tagIds = [] } = args
|
const { tagIds = [] } = args
|
||||||
delete args.tags
|
delete args.tags
|
||||||
const tags = await Promise.all(
|
const tags = await Promise.all(
|
||||||
|
|||||||
@ -29,10 +29,20 @@ const narratorParams = {
|
|||||||
...termsAndConditionsAgreedVersion,
|
...termsAndConditionsAgreedVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const annoyingParams = {
|
||||||
|
email: "spammy-spammer@example.org",
|
||||||
|
password: "1234",
|
||||||
|
...termsAndConditionsAgreedVersion
|
||||||
|
};
|
||||||
|
|
||||||
Given("I am logged in", () => {
|
Given("I am logged in", () => {
|
||||||
cy.login(loginCredentials);
|
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", () => {
|
Given("we have a selection of categories", () => {
|
||||||
cy.createCategories("cat0", "just-for-fun");
|
cy.createCategories("cat0", "just-for-fun");
|
||||||
});
|
});
|
||||||
@ -227,7 +237,6 @@ Given("I previously created a post", () => {
|
|||||||
lastPost.authorId = narratorParams.id
|
lastPost.authorId = narratorParams.id
|
||||||
lastPost.title = "previously created post";
|
lastPost.title = "previously created post";
|
||||||
lastPost.content = "with some content";
|
lastPost.content = "with some content";
|
||||||
lastPost.categoryIds = ["cat0"];
|
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.create("Post", lastPost);
|
.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 => {
|
Given("there is an annoying user called {string}", name => {
|
||||||
const annoyingParams = {
|
|
||||||
email: "spammy-spammer@example.org",
|
|
||||||
password: "1234",
|
|
||||||
...termsAndConditionsAgreedVersion
|
|
||||||
};
|
|
||||||
cy.factory().create("User", {
|
cy.factory().create("User", {
|
||||||
...annoyingParams,
|
...annoyingParams,
|
||||||
id: "annoying-user",
|
id: "annoying-user",
|
||||||
@ -519,12 +523,12 @@ When("I blacklist the user {string}", name => {
|
|||||||
.first("User", {
|
.first("User", {
|
||||||
name
|
name
|
||||||
})
|
})
|
||||||
.then(blacklisted => {
|
.then(blacklistedUser => {
|
||||||
cy.neode()
|
cy.neode()
|
||||||
.first("User", {
|
.first("User", {
|
||||||
name: narratorParams.name
|
name: narratorParams.name
|
||||||
})
|
})
|
||||||
.relateTo(blacklisted, "blacklisted");
|
.relateTo(blacklistedUser, "blacklisted");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -41,3 +41,13 @@ Feature: Blacklist a User
|
|||||||
Then I should see the following posts in the select dropdown:
|
Then I should see the following posts in the select dropdown:
|
||||||
| title |
|
| title |
|
||||||
| Post that should be seen |
|
| 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
|
Scenario Outline: Blacklisted users cannot see each others posts
|
||||||
Given "Spammy Spammer" wrote a post "Spam Spam Spam"
|
Given "Spammy Spammer" wrote a post "Spam Spam Spam"
|
||||||
And I wrote a post "I hate spammers"
|
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:
|
When I log in with:
|
||||||
| Email | Password |
|
| Email | Password |
|
||||||
| <email> | <password> |
|
| <email> | <password> |
|
||||||
|
|||||||
@ -60,7 +60,7 @@ Cypress.Commands.add("login", ({ email, password }) => {
|
|||||||
.as("submitButton")
|
.as("submitButton")
|
||||||
.click();
|
.click();
|
||||||
cy.get(".iziToast-message").should("contain", "You are logged in!");
|
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) => {
|
Cypress.Commands.add("logout", (email, password) => {
|
||||||
|
|||||||
@ -22,8 +22,8 @@
|
|||||||
:resource="user"
|
:resource="user"
|
||||||
:is-owner="myProfile"
|
:is-owner="myProfile"
|
||||||
class="user-content-menu"
|
class="user-content-menu"
|
||||||
@blacklist="blacklist"
|
@blacklist="blacklistUserContent"
|
||||||
@whitelist="whitelist"
|
@whitelist="whitelistUserContent"
|
||||||
/>
|
/>
|
||||||
</client-only>
|
</client-only>
|
||||||
<ds-space margin="small">
|
<ds-space margin="small">
|
||||||
@ -399,16 +399,26 @@ export default {
|
|||||||
this.hasMore = true
|
this.hasMore = true
|
||||||
},
|
},
|
||||||
async blacklistUserContent(user) {
|
async blacklistUserContent(user) {
|
||||||
|
try {
|
||||||
await this.$apollo.mutate({ mutation: blacklistUserContent(), variables: { id: user.id } })
|
await this.$apollo.mutate({ mutation: blacklistUserContent(), variables: { id: user.id } })
|
||||||
|
} catch (error) {
|
||||||
|
this.$toast.error(error.message)
|
||||||
|
} finally {
|
||||||
this.$apollo.queries.User.refetch()
|
this.$apollo.queries.User.refetch()
|
||||||
this.resetPostList()
|
this.resetPostList()
|
||||||
this.$apollo.queries.profilePagePosts.refetch()
|
this.$apollo.queries.profilePagePosts.refetch()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async whitelistUserContent(user) {
|
async whitelistUserContent(user) {
|
||||||
await this.$apollo.mutate({ mutation: whitelistUserContent(), variables: { id: user.id } })
|
try {
|
||||||
|
this.$apollo.mutate({ mutation: whitelistUserContent(), variables: { id: user.id } })
|
||||||
|
} catch (error) {
|
||||||
|
this.$toast.error(error.message)
|
||||||
|
} finally {
|
||||||
this.$apollo.queries.User.refetch()
|
this.$apollo.queries.User.refetch()
|
||||||
this.resetPostList()
|
this.resetPostList()
|
||||||
this.$apollo.queries.profilePagePosts.refetch()
|
this.$apollo.queries.profilePagePosts.refetch()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
pinPost(post) {
|
pinPost(post) {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
|
|||||||
@ -98,7 +98,7 @@ export default {
|
|||||||
avatar: '',
|
avatar: '',
|
||||||
name: this.$t('settings.blacklisted-users.columns.name'),
|
name: this.$t('settings.blacklisted-users.columns.name'),
|
||||||
slug: this.$t('settings.blacklisted-users.columns.slug'),
|
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