mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Added report content tests
This commit is contained in:
parent
453ceae726
commit
a87c9e4f4a
17
cypress/fixtures/users.json
Normal file
17
cypress/fixtures/users.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"admin": {
|
||||
"email": "admin@example.org",
|
||||
"password": "1234",
|
||||
"name": "Peter Lustig"
|
||||
},
|
||||
"moderator": {
|
||||
"email": "moderator@example.org",
|
||||
"password": "1234",
|
||||
"name": "Bob der Bausmeister"
|
||||
},
|
||||
"user": {
|
||||
"email": "user@example.org",
|
||||
"password": "1234",
|
||||
"name": "Jenny Rostock"
|
||||
}
|
||||
}
|
||||
34
cypress/integration/05.ReportContent.feature
Normal file
34
cypress/integration/05.ReportContent.feature
Normal file
@ -0,0 +1,34 @@
|
||||
Feature: Report content
|
||||
As a user
|
||||
I would like to report content that viloates the community guidlines
|
||||
So the moderators can take action on it
|
||||
|
||||
As a moderator
|
||||
I would like to see all reported content
|
||||
So I can look into it and decide what to do
|
||||
|
||||
Scenario: Report a Post from landingpage
|
||||
Given I am logged in as "user"
|
||||
And I am on the "landing" page
|
||||
|
||||
When I click on a Post menu and select the report option
|
||||
And I click on send in the confirmation dialog
|
||||
Then I get a success message
|
||||
|
||||
Scenario: See reported content
|
||||
Given I am logged in as "moderator"
|
||||
And I previously reported a post
|
||||
|
||||
When I am on the "moderation" page
|
||||
Then I see my reported post
|
||||
|
||||
Scenario: Report while reading Post
|
||||
Given I am logged in as "admin"
|
||||
And I am viewing a post
|
||||
|
||||
When I report the current post
|
||||
And I visit the "moderation" page
|
||||
Then I see my reported post
|
||||
|
||||
#Scenario: Normal user can't see the moderation page
|
||||
#Given I am logged in as "user"
|
||||
73
cypress/integration/common/report.js
Normal file
73
cypress/integration/common/report.js
Normal file
@ -0,0 +1,73 @@
|
||||
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
|
||||
|
||||
/* global cy */
|
||||
|
||||
let lastPostTitle
|
||||
|
||||
const savePostTitle = $post => {
|
||||
return $post
|
||||
.first()
|
||||
.find('.ds-heading')
|
||||
.first()
|
||||
.invoke('text')
|
||||
.then(title => {
|
||||
lastPostTitle = title
|
||||
})
|
||||
}
|
||||
const invokeReportOnElement = selector => {
|
||||
cy.get(selector)
|
||||
.first()
|
||||
.find('.content-menu-trigger')
|
||||
.first()
|
||||
.click()
|
||||
|
||||
return savePostTitle(cy.get(selector)).then(() => {
|
||||
cy.get('.popover .ds-menu-item-link')
|
||||
.contains('Report')
|
||||
.click()
|
||||
})
|
||||
}
|
||||
|
||||
Given('I am logged in as {string}', userType => {
|
||||
cy.loginAs(userType)
|
||||
})
|
||||
|
||||
Given('I previously reported a post', () => {
|
||||
invokeReportOnElement('.post-card')
|
||||
})
|
||||
|
||||
Given('I am viewing a post', () => {
|
||||
cy.visit('/')
|
||||
cy.get('.post-card:nth(2)')
|
||||
.click()
|
||||
.wait(200)
|
||||
cy.location('pathname').should('contain', '/post')
|
||||
})
|
||||
|
||||
When('I report the current post', () => {
|
||||
invokeReportOnElement('.post-card').then(() => {
|
||||
cy.get('button')
|
||||
.contains('Send')
|
||||
.click()
|
||||
})
|
||||
})
|
||||
|
||||
When('I click on a Post menu and select the report option', () => {
|
||||
invokeReportOnElement('.post-card')
|
||||
})
|
||||
|
||||
When('I click on send in the confirmation dialog', () => {
|
||||
cy.get('button')
|
||||
.contains('Send')
|
||||
.click()
|
||||
})
|
||||
|
||||
Then('I get a success message', () => {
|
||||
cy.get('.iziToast-message').contains('Thanks')
|
||||
})
|
||||
|
||||
Then('I see my reported post', () => {
|
||||
cy.get('table').then(() => {
|
||||
cy.get('tbody tr:first-child()').contains(lastPostTitle.slice(0, 20))
|
||||
})
|
||||
})
|
||||
@ -1,11 +1,9 @@
|
||||
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
|
||||
import { getLangByName } from '../../support/helpers'
|
||||
import find from 'lodash/find'
|
||||
import users from '../../fixtures/users.json'
|
||||
|
||||
/* global cy */
|
||||
|
||||
const username = 'Peter Lustig'
|
||||
|
||||
const openPage = page => {
|
||||
if (page === 'landing') {
|
||||
page = ''
|
||||
@ -14,7 +12,10 @@ const openPage = page => {
|
||||
}
|
||||
|
||||
Given('I am logged in', () => {
|
||||
cy.login('admin@example.org', 1234)
|
||||
cy.loginAs('admin')
|
||||
})
|
||||
Given('I am logged in as {string}', userType => {
|
||||
cy.loginAs(userType)
|
||||
})
|
||||
|
||||
Given('we have a selection of tags and categories as well as posts', () => {
|
||||
@ -59,7 +60,7 @@ Then('I can click on my profile picture in the top right corner', () => {
|
||||
})
|
||||
|
||||
Then('I can see my name {string} in the dropdown menu', () => {
|
||||
cy.get('.avatar-menu-popover').should('contain', username)
|
||||
cy.get('.avatar-menu-popover').should('contain', users.admin.name)
|
||||
})
|
||||
|
||||
Then('I see the login screen again', () => {
|
||||
@ -68,7 +69,7 @@ Then('I see the login screen again', () => {
|
||||
|
||||
Then('I am still logged in', () => {
|
||||
cy.get('.avatar-menu').click()
|
||||
cy.get('.avatar-menu-popover').contains(username)
|
||||
cy.get('.avatar-menu-popover').contains(users.admin.name)
|
||||
})
|
||||
|
||||
When('I select {string} in the language menu', name => {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
/* globals Cypress cy */
|
||||
|
||||
import { getLangByName } from './helpers'
|
||||
import users from '../fixtures/users.json'
|
||||
|
||||
const switchLang = name => {
|
||||
cy.get('.locale-menu').click()
|
||||
@ -54,6 +55,12 @@ Cypress.Commands.add('login', (email, password) => {
|
||||
.click()
|
||||
cy.location('pathname').should('eq', '/') // we're in!
|
||||
})
|
||||
|
||||
Cypress.Commands.add('loginAs', userType => {
|
||||
userType = userType || 'admin'
|
||||
cy.login(users[userType].email, users[userType].password)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('logout', (email, password) => {
|
||||
cy.visit(`/logout`)
|
||||
cy.location('pathname').should('contain', '/login') // we're out
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
export default {
|
||||
users: {
|
||||
admin: {
|
||||
email: 'admin@example.org',
|
||||
password: 1234
|
||||
},
|
||||
moderator: {
|
||||
email: 'moderator@example.org',
|
||||
password: 1234
|
||||
},
|
||||
user: {
|
||||
email: 'user@example.org',
|
||||
password: 1234
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user