Commit 02c30391 authored by Tamlyn Rhodes's avatar Tamlyn Rhodes

Reorganise specs

parent 34378140
Pipeline #2892 passed with stage
in 5 minutes and 2 seconds
export {default as login} from './login'
export {default as signup} from './signup'
export {default as managePosts} from './managePosts'
export {default as managePosts} from './manage/posts'
......@@ -6,6 +6,7 @@ const login = {
submit: 'form button',
signUp: 'form a:first',
resetPassword: 'form a:last',
alert: '.alert',
doLogin: (username, password) => {
cy.visit(login.url)
......
const signup = {
url: `http://localhost:${process.env.PORT || 3000}/signup`,
title: 'h1'
title: 'h1',
username: 'form input[type=text]:first',
email: 'form input[type=text]:last',
password: 'form input[type=password]',
submit: 'form button',
login: 'form a'
}
export default signup
......@@ -2,8 +2,8 @@ import faker from 'faker'
import { login, managePosts } from '../pageObjects/index'
import * as fixtures from '../helpers/fixtures'
describe('Manage posts', () => {
it('admin can create a post', () => {
describe('Admin user', () => {
it('Posts manager journey', () => {
login.doLogin(fixtures.admin.username, fixtures.admin.password)
// create a post
......
import { login, signup, managePosts } from '../pageObjects'
import * as fixtures from '../helpers/fixtures'
import faker from 'faker'
describe('Login page', () => {
it('admin can log in', () => {
login.doLogin(fixtures.admin.username, fixtures.admin.password)
cy.get(managePosts.title).should('contain', fixtures.collection)
})
describe('Guest user', () => {
it('Signup jorney', () => {
const user = {
username: faker.internet.domainWord(),
email: faker.internet.email(),
password: faker.internet.password()
}
it('guest can navigate to sign up page', () => {
cy.visit(login.url)
// cannot log in
login.doLogin(user.username, user.password)
cy.get(login.alert).should('contain', 'Unauthorized')
// signup
cy.get(login.signUp).click()
cy.get(signup.title).should('contain', 'Sign up')
cy.get(signup.username).type(user.username)
cy.get(signup.email).type(user.email)
cy.get(signup.password).type(user.password)
cy.get(signup.submit).click()
// can log in
login.doLogin(user.username, user.password)
cy.url().should('eq', managePosts.url)
})
it.skip('guest can navigate to reset password page', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment