mirror of
https://github.com/typemill/typemill.git
synced 2025-07-31 11:20:15 +02:00
Version 1.3.5 Consolidation
This commit is contained in:
126
cypress/test01-system-setup.spec.js
Normal file
126
cypress/test01-system-setup.spec.js
Normal file
@@ -0,0 +1,126 @@
|
||||
describe('Typemill Setup', function()
|
||||
{
|
||||
it('validates form input', function ()
|
||||
{
|
||||
// visit setup form
|
||||
cy.visit('/setup')
|
||||
cy.url().should('include','/setup')
|
||||
|
||||
// add data and check attributes
|
||||
cy.get('input[name="username"]')
|
||||
.type('?1')
|
||||
.should('have.value', '?1')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
cy.get('input[name="email"]')
|
||||
.type('trendschau.net')
|
||||
.should('have.value', 'trendschau.net')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
cy.get('input[name="password"]')
|
||||
.type('pass')
|
||||
.should('have.value', 'pass')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
// submit and get validation errors
|
||||
cy.get('form').submit()
|
||||
cy.get('#flash-message').should('contain', 'Please check your input and try again')
|
||||
cy.get('.error').should('contain', 'invalid characters')
|
||||
cy.get('.error').should('contain', 'e-mail is invalid')
|
||||
cy.get('.error').should('contain', 'Length between 5 - 20')
|
||||
})
|
||||
|
||||
it('fails without CSRF-token', function ()
|
||||
{
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: '/setup', // baseUrl is prepended to url
|
||||
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
|
||||
failOnStatusCode: false,
|
||||
body: {
|
||||
username: 'trendschau',
|
||||
email: 'trendschau@gmail.com',
|
||||
password: 'password'
|
||||
}
|
||||
})
|
||||
.its('body')
|
||||
.should('include', 'Failed CSRF check')
|
||||
})
|
||||
|
||||
it('submits valid form data and visit welcome and settings page', function ()
|
||||
{
|
||||
cy.visit('/setup')
|
||||
|
||||
// enter correct data
|
||||
cy.get('input[name="username"]').clear().type('trendschau')
|
||||
cy.get('input[name="email"]').clear().type('trendschau@gmail.com')
|
||||
cy.get('input[name="password"]').clear().type('password')
|
||||
|
||||
// submits valid form
|
||||
cy.get('form').submit()
|
||||
cy.url().should('include','/welcome')
|
||||
cy.getCookie('typemill-session').should('exist')
|
||||
Cypress.Cookies.preserveOnce('typemill-session')
|
||||
|
||||
// clicks link on welcome page to settings page
|
||||
cy.get('.button').should('contain', 'Configure your website')
|
||||
cy.get('.button').click()
|
||||
cy.url().should('include', '/tm/settings')
|
||||
})
|
||||
|
||||
it('creates default settings data', function()
|
||||
{
|
||||
cy.get('input[name="settings[title]"]')
|
||||
.should('have.value', 'TYPEMILL')
|
||||
.and('have.attr','required')
|
||||
cy.get('input[name="settings[author]"]')
|
||||
.should('have.value', 'Unknown')
|
||||
cy.get('select[name="settings[copyright]"]')
|
||||
cy.get('input[name="settings[year]"]')
|
||||
.should('have.attr', 'required')
|
||||
cy.get('select[name="settings[language]"]')
|
||||
cy.get('input[name="settings[sitemap]"]')
|
||||
.should('have.value', 'http://localhost/typemillTest/cache/sitemap.xml')
|
||||
.and('have.attr','readonly')
|
||||
Cypress.Cookies.preserveOnce('typemill-session')
|
||||
})
|
||||
|
||||
it('creates default user data', function()
|
||||
{
|
||||
cy.visit('/tm/user/trendschau')
|
||||
cy.url().should('include', '/tm/user/trendschau')
|
||||
|
||||
cy.get('input[name="showusername"]')
|
||||
.should('have.value', 'trendschau')
|
||||
.and('have.attr','disabled')
|
||||
cy.get('input[name="username"]')
|
||||
.should('have.value', 'trendschau')
|
||||
cy.get('input[name="email"]')
|
||||
.should('have.value', 'trendschau@gmail.com')
|
||||
.and('have.attr','required')
|
||||
cy.get('select[name="userrole"]')
|
||||
.should('have.attr','required')
|
||||
cy.get('input[name="password"]')
|
||||
.should('have.value', '')
|
||||
cy.get('input[name="newpassword"]')
|
||||
.should('have.value', '')
|
||||
})
|
||||
|
||||
it('logouts out', function()
|
||||
{
|
||||
// visits logout link
|
||||
cy.visit('/tm/logout')
|
||||
cy.url().should('include', '/tm/login')
|
||||
|
||||
// tries to open setup form again and gets redirected to login
|
||||
cy.visit('/setup')
|
||||
cy.url().should('include','/login')
|
||||
})
|
||||
|
||||
it('redirects when tries to setup again', function()
|
||||
{
|
||||
// tries to open setup form again and gets redirected to login
|
||||
cy.visit('/setup')
|
||||
cy.url().should('include','/login')
|
||||
})
|
||||
})
|
148
cypress/test02-initial-frontend.spec.js
Normal file
148
cypress/test02-initial-frontend.spec.js
Normal file
@@ -0,0 +1,148 @@
|
||||
describe('Typemill Initial Frontend', function()
|
||||
{
|
||||
it('has startpage with buttons and links', function ()
|
||||
{
|
||||
/* visit homepage */
|
||||
cy.visit('/')
|
||||
|
||||
/* has start and setup button */
|
||||
cy.get('.actionLink').find('a').should(($a) => {
|
||||
expect($a).to.have.length(1)
|
||||
expect($a[0].href).to.match(/welcome/)
|
||||
})
|
||||
|
||||
/* has start and setup button */
|
||||
cy.get('.toc-nav').find('a').should(($a) => {
|
||||
expect($a).to.have.length(5)
|
||||
expect($a[0].href).to.match(/welcome/)
|
||||
expect($a[1].href).to.match(/welcome\/setup/)
|
||||
expect($a[2].href).to.match(/welcome\/write-content/)
|
||||
expect($a[3].href).to.match(/welcome\/get-help/)
|
||||
expect($a[4].href).to.match(/welcome\/markdown-test/)
|
||||
})
|
||||
})
|
||||
|
||||
it('has error page', function ()
|
||||
{
|
||||
cy.request({
|
||||
url: '/error',
|
||||
failOnStatusCode: false,
|
||||
})
|
||||
.then((resp) => {
|
||||
/* should return 404 not found */
|
||||
expect(resp.status).to.eq(404)
|
||||
})
|
||||
|
||||
cy.visit('/error', { failOnStatusCode: false })
|
||||
cy.url().should('include','/error')
|
||||
|
||||
cy.get('h1').contains('Not Found')
|
||||
})
|
||||
|
||||
it('has no access to cache files', function ()
|
||||
{
|
||||
cy.request({
|
||||
url: '/cache/structure.txt',
|
||||
failOnStatusCode: false,
|
||||
})
|
||||
.then((resp) => {
|
||||
// redirect status code is 302
|
||||
expect(resp.status).to.eq(403)
|
||||
})
|
||||
})
|
||||
|
||||
it('has sitemap xml', function ()
|
||||
{
|
||||
cy.request({
|
||||
url: '/cache/sitemap.xml',
|
||||
})
|
||||
.then((resp) => {
|
||||
/* should return xml-format */
|
||||
expect(resp.headers).to.have.property('content-type','application/xml')
|
||||
})
|
||||
})
|
||||
|
||||
it('has no access to dashboard', function ()
|
||||
{
|
||||
cy.visit('/tm/settings')
|
||||
cy.url().should('include','/tm/login')
|
||||
})
|
||||
|
||||
it('has proper markdown test page', function ()
|
||||
{
|
||||
cy.visit('/welcome/markdown-test')
|
||||
cy.url().should('include','/welcome/markdown-test')
|
||||
|
||||
/* has navigation element */
|
||||
cy.get('nav').should('exist')
|
||||
|
||||
/* check if toc exists */
|
||||
cy.get('.TOC').within(($toc) =>{
|
||||
/* check if a certain link in toc exists */
|
||||
cy.get('a').eq(2).should('have.attr', 'href', '/typemillTest/welcome/markdown-test#headlines')
|
||||
})
|
||||
|
||||
/* check if corresponding anchor exists */
|
||||
cy.get('#headlines').should('exist')
|
||||
|
||||
/* soft linebreaks */
|
||||
cy.get('br').should('exist')
|
||||
|
||||
/* emphasis */
|
||||
cy.get('em').should('exist')
|
||||
|
||||
/* strong */
|
||||
cy.get('strong').should('exist')
|
||||
|
||||
/* ordered list */
|
||||
cy.get('ol').should('exist')
|
||||
|
||||
/* linebreak */
|
||||
cy.get('hr').should('exist')
|
||||
|
||||
/* links exists? hard to test, any idea? We need to wrap it in a div... */
|
||||
|
||||
/* images */
|
||||
cy.get('img').eq(0).should('have.attr', 'alt', 'alt-text')
|
||||
cy.get('img').eq(0).should('have.attr', 'src', 'media/markdown.png')
|
||||
cy.get('img').eq(2).should('have.id', 'myid')
|
||||
.and('have.class', 'otherclass')
|
||||
.and('have.attr', 'alt', 'alt-text')
|
||||
.and('have.attr', 'title', 'my title')
|
||||
.and('have.attr', 'width', '150px')
|
||||
|
||||
/* blockquote */
|
||||
cy.get('blockquote').should('exist')
|
||||
|
||||
/* footnote */
|
||||
cy.get('sup').eq(0).should('have.id', 'fnref1:1')
|
||||
cy.get('sup').eq(0).within(($sup) =>{
|
||||
cy.get('a').eq(0).should('have.attr', 'href', '/typemillTest/welcome/markdown-test#fn%3A1')
|
||||
.and('have.class', 'footnote-ref')
|
||||
})
|
||||
|
||||
/* abbreviation */
|
||||
cy.get('abbr').should('exist')
|
||||
|
||||
/* definition list */
|
||||
cy.get('dl').should('exist')
|
||||
|
||||
/* table */
|
||||
cy.get('table').should('exist')
|
||||
|
||||
/* code */
|
||||
cy.get('pre').should('exist')
|
||||
cy.get('code').should('exist')
|
||||
|
||||
/* math */
|
||||
cy.get('.math').should('exist')
|
||||
|
||||
/* footnote end */
|
||||
cy.get('.footnotes').within(($footnotes) => {
|
||||
cy.get('li').eq(0).should('have.id', 'fn:1')
|
||||
cy.get('a').eq(0).should('have.class', 'footnote-backref')
|
||||
.and('have.attr', 'href', '/typemillTest/welcome/markdown-test#fnref1%3A1')
|
||||
.and('have.attr', 'rev', 'footnote')
|
||||
})
|
||||
})
|
||||
})
|
109
cypress/test03-system-settings.spec.js
Normal file
109
cypress/test03-system-settings.spec.js
Normal file
@@ -0,0 +1,109 @@
|
||||
describe('Typemill System Settings', function()
|
||||
{
|
||||
before(function ()
|
||||
{
|
||||
cy.visit('/tm/login')
|
||||
cy.url().should('include','/tm/login')
|
||||
|
||||
cy.get('input[name="username"]').type('trendschau')
|
||||
cy.get('input[name="password"]').type('password')
|
||||
|
||||
cy.get('form').submit()
|
||||
cy.url().should('include','/tm/content')
|
||||
cy.getCookie('typemill-session').should('exist')
|
||||
|
||||
cy.visit('/tm/settings')
|
||||
cy.url().should('include','/tm/settings')
|
||||
})
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
Cypress.Cookies.preserveOnce('typemill-session')
|
||||
})
|
||||
|
||||
it('validates the form', function()
|
||||
{
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[title]"]')
|
||||
.clear()
|
||||
.type('Cypress<?')
|
||||
.should('have.value', 'Cypress<?')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[author]"]')
|
||||
.clear()
|
||||
.type('trendschau')
|
||||
.should('have.value', 'trendschau')
|
||||
|
||||
// fill out copyright data
|
||||
cy.get('select[name="settings[copyright]"]')
|
||||
.select('CC-BY')
|
||||
.should('have.value', 'CC-BY')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[year]"]')
|
||||
.clear()
|
||||
.type('2017')
|
||||
.should('have.value', '2017')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
// fill out copyright data
|
||||
cy.get('select[name="settings[language]"]')
|
||||
.select('German')
|
||||
.should('have.value', 'de')
|
||||
|
||||
// submit form
|
||||
cy.get('form').submit()
|
||||
cy.get('#flash-message').should('contain', 'Please correct the errors')
|
||||
cy.get('.error').should('contain', 'Title contains invalid characters')
|
||||
})
|
||||
|
||||
it('changes default values', function()
|
||||
{
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[title]"]')
|
||||
.clear()
|
||||
.type('Cypress')
|
||||
.should('have.value', 'Cypress')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[author]"]')
|
||||
.clear()
|
||||
.type('robot')
|
||||
.should('have.value', 'robot')
|
||||
|
||||
cy.get('select[name="settings[copyright]"]')
|
||||
.select('CC-BY-ND')
|
||||
.should('have.value', 'CC-BY-ND')
|
||||
|
||||
// fill out copyright data
|
||||
cy.get('select[name="settings[language]"]')
|
||||
.select('English')
|
||||
.should('have.value', 'en')
|
||||
|
||||
cy.get('form').submit()
|
||||
cy.get('#flash-message').should('contain', 'Settings are stored')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[title]"]')
|
||||
.should('have.value', 'Cypress')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[author]"]')
|
||||
.should('have.value', 'robot')
|
||||
|
||||
// fill out copyright data
|
||||
cy.get('select[name="settings[copyright]"]')
|
||||
.should('have.value', 'CC-BY-ND')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="settings[year]"]')
|
||||
.should('have.value', '2017')
|
||||
|
||||
// fill out copyright data
|
||||
cy.get('select[name="settings[language]"]')
|
||||
.should('have.value', 'en')
|
||||
})
|
||||
})
|
197
cypress/test04-theme-settings.spec.js
Normal file
197
cypress/test04-theme-settings.spec.js
Normal file
@@ -0,0 +1,197 @@
|
||||
describe('Typemill Theme Settings', function()
|
||||
{
|
||||
before(function ()
|
||||
{
|
||||
cy.visit('/tm/login')
|
||||
cy.url().should('include','/tm/login')
|
||||
|
||||
cy.get('input[name="username"]').type('trendschau')
|
||||
cy.get('input[name="password"]').type('password')
|
||||
|
||||
cy.get('form').submit()
|
||||
cy.url().should('include','/tm/content')
|
||||
cy.getCookie('typemill-session').should('exist')
|
||||
|
||||
cy.visit('/tm/themes')
|
||||
cy.url().should('include','/tm/themes')
|
||||
})
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
Cypress.Cookies.preserveOnce('typemill-session')
|
||||
})
|
||||
|
||||
it('changes default values', function()
|
||||
{
|
||||
|
||||
// open the form
|
||||
cy.get('#typemill-toggle')
|
||||
.should('contain', 'Settings')
|
||||
.click()
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[chapter]"]')
|
||||
.should('have.value', 'Chapter')
|
||||
.clear()
|
||||
.type('Kapitel')
|
||||
.should('have.value', 'Kapitel')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[start]"]')
|
||||
.should('have.value', 'Start')
|
||||
.clear()
|
||||
.type('Run')
|
||||
.should('have.value', 'Run')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[chapnum]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[authorPosition][top]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[authorIntro]"]')
|
||||
.should('have.value', 'Author')
|
||||
.clear()
|
||||
.type('Writer')
|
||||
.should('have.value', 'Writer')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[modifiedPosition][bottom]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[modifiedText]"]')
|
||||
.should('have.value', 'Last updated')
|
||||
.clear()
|
||||
.type('Final update')
|
||||
.should('have.value', 'Final update')
|
||||
|
||||
cy.get('select[name="typemill[modifiedFormat]"]')
|
||||
.should('have.value', 'd.m.Y')
|
||||
.select('m/d/Y')
|
||||
.should('have.value', 'm/d/Y')
|
||||
|
||||
cy.get('input[name="typemill[socialPosition][bottom]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[socialButtons][facebook]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[socialButtons][twitter]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[socialButtons][xing]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[gitPosition][top]"]')
|
||||
.should('not.be.checked')
|
||||
.and('not.be.visible')
|
||||
.check({ force: true })
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[gitlink]"]')
|
||||
.clear()
|
||||
.type('https://github.com/typemill/docs')
|
||||
.should('have.value', 'https://github.com/typemill/docs')
|
||||
|
||||
|
||||
cy.get('#theme-typemill').submit()
|
||||
cy.get('#flash-message').should('contain', 'Settings are stored')
|
||||
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[chapter]"]')
|
||||
.should('have.value', 'Kapitel')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[start]"]')
|
||||
.should('have.value', 'Run')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[chapnum]"]')
|
||||
.should('be.checked')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[authorPosition][top]"]')
|
||||
.should('be.checked')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[authorIntro]"]')
|
||||
.should('have.value', 'Writer')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[modifiedPosition][bottom]"]')
|
||||
.should('be.checked')
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[modifiedText]"]')
|
||||
.should('have.value', 'Final update')
|
||||
|
||||
cy.get('select[name="typemill[modifiedFormat]"]')
|
||||
.should('have.value', 'm/d/Y')
|
||||
|
||||
cy.get('input[name="typemill[socialPosition][bottom]"]')
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[socialButtons][facebook]"]')
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[socialButtons][twitter]"]')
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[socialButtons][xing]"]')
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[gitPosition][top]"]')
|
||||
.should('be.checked')
|
||||
|
||||
cy.get('input[name="typemill[gitlink]"]')
|
||||
.should('have.value', 'https://github.com/typemill/docs')
|
||||
})
|
||||
|
||||
it('validates input', function()
|
||||
{
|
||||
|
||||
// open the form
|
||||
cy.get('#typemill-toggle')
|
||||
.should('contain', 'Settings')
|
||||
.click()
|
||||
|
||||
// fill out valid data
|
||||
cy.get('input[name="typemill[chapter]"]')
|
||||
.should('have.value', 'Kapitel')
|
||||
.clear()
|
||||
.type('Kapitel<?')
|
||||
.should('have.value', 'Kapitel<?')
|
||||
|
||||
// submit form
|
||||
cy.get('#theme-typemill').submit()
|
||||
|
||||
cy.get('#flash-message').should('contain', 'Please correct the errors')
|
||||
|
||||
})
|
||||
})
|
87
cypress/test99-login.spec.js
Normal file
87
cypress/test99-login.spec.js
Normal file
@@ -0,0 +1,87 @@
|
||||
describe('Typemill Login', function()
|
||||
{
|
||||
it('redirects if visits dashboard without login', function ()
|
||||
{
|
||||
cy.visit('/tm/content')
|
||||
cy.url().should('include', '/tm/login')
|
||||
})
|
||||
|
||||
it('submits a valid form and logout', function ()
|
||||
{
|
||||
// visits login page and adds valid input
|
||||
cy.visit('/tm/login')
|
||||
cy.url().should('include','/tm/login')
|
||||
|
||||
cy.get('input[name="username"]')
|
||||
.type('trendschau')
|
||||
.should('have.value', 'trendschau')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
cy.get('input[name="password"]')
|
||||
.type('password')
|
||||
.should('have.value', 'password')
|
||||
.and('have.attr', 'required')
|
||||
|
||||
// can login
|
||||
cy.get('form').submit()
|
||||
cy.url().should('include','/tm/content')
|
||||
cy.getCookie('typemill-session').should('exist')
|
||||
|
||||
Cypress.Cookies.preserveOnce('typemill-session')
|
||||
})
|
||||
|
||||
it('redirects if visits login form when logged in', function ()
|
||||
{
|
||||
cy.visit('/tm/login')
|
||||
cy.url().should('include', '/tm/content')
|
||||
|
||||
Cypress.Cookies.preserveOnce('typemill-session')
|
||||
})
|
||||
|
||||
it('logs out', function ()
|
||||
{
|
||||
cy.contains('Logout').click()
|
||||
cy.url().should('include', '/tm/login')
|
||||
})
|
||||
|
||||
it('fails without CSRF-token', function ()
|
||||
{
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: '/tm/login', // baseUrl is prepended to url
|
||||
form: true, // indicates the body should be form urlencoded and sets Content-Type: application/x-www-form-urlencoded headers
|
||||
failOnStatusCode: false,
|
||||
body: {
|
||||
username: 'trendschau',
|
||||
password: 'password'
|
||||
}
|
||||
})
|
||||
.its('body')
|
||||
.should('include', 'Failed CSRF check')
|
||||
})
|
||||
|
||||
it('blocks after 3 fails', function ()
|
||||
{
|
||||
cy.visit('/tm/login')
|
||||
|
||||
// validation fails first
|
||||
cy.get('input[name="username"]').clear().type('wrong')
|
||||
cy.get('input[name="password"]').clear().type('pass')
|
||||
cy.get('form').submit()
|
||||
cy.get('#flash-message').should('contain', 'wrong password or username')
|
||||
cy.get('input[name="username"]').should('have.value', 'wrong')
|
||||
cy.get('input[name="password"]').should('have.value', '')
|
||||
|
||||
// validation fails second
|
||||
cy.get('input[name="password"]').clear().type('pass')
|
||||
cy.get('form').submit()
|
||||
cy.get('#flash-message').should('contain', 'wrong password or username')
|
||||
|
||||
// validation fails third and login is blocked
|
||||
cy.get('input[name="password"]').clear().type('pass')
|
||||
cy.get('form').submit()
|
||||
cy.get('#flash-message').should('contain', 'Too many bad logins')
|
||||
cy.contains('wait')
|
||||
cy.contains('Forgot password')
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user