1
0
mirror of https://github.com/typemill/typemill.git synced 2025-01-17 21:38:25 +01:00
php-typemill/cypress/test02-initial-frontend.spec.js

156 lines
4.7 KiB
JavaScript
Raw Normal View History

2020-04-21 08:01:28 +02:00
describe('Typemill Initial Frontend', function()
{
2020-06-14 19:53:02 +02:00
it('has startpage with navigation', function ()
2020-04-21 08:01:28 +02:00
{
/* visit homepage */
cy.visit('/')
2020-06-14 19:53:02 +02:00
/* has startpage with headline */
cy.get('h1').contains("Typemill")
2020-04-21 08:01:28 +02:00
/* has start and setup button */
2021-01-08 10:10:47 +01:00
cy.get('nav').find('a').should(($a) => {
expect($a).to.have.length(11)
2020-04-21 08:01:28 +02:00
expect($a[0].href).to.match(/welcome/)
expect($a[1].href).to.match(/welcome\/setup-your-website/)
expect($a[2].href).to.match(/welcome\/manage-access/)
expect($a[3].href).to.match(/welcome\/write-content/)
expect($a[4].href).to.match(/welcome\/get-help/)
expect($a[5].href).to.match(/welcome\/markdown-test/)
expect($a[6].href).to.match(/cyanine-theme/)
expect($a[7].href).to.match(/cyanine-theme\/landingpage/)
expect($a[8].href).to.match(/cyanine-theme\/colors-and-fonts/)
expect($a[9].href).to.match(/cyanine-theme\/footer/)
expect($a[10].href).to.match(/cyanine-theme\/content-elements/)
2020-04-21 08:01:28 +02:00
})
})
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 */
2021-01-08 10:10:47 +01:00
cy.get('a').eq(2).should('have.attr', 'href', '#h-headlines')
2020-04-21 08:01:28 +02:00
})
/* check if corresponding anchor exists */
2021-01-08 10:10:47 +01:00
cy.get('#h-headlines').should('exist')
2020-04-21 08:01:28 +02:00
/* 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 */
2020-06-14 19:53:02 +02:00
cy.get('img').eq(0).should('have.attr', 'alt', 'alt')
2021-01-08 10:10:47 +01:00
cy.get('img').eq(0).should('have.attr', 'src').should('include','media/files/markdown.png')
2020-05-17 10:23:36 +02:00
cy.get('figure').eq(2).should('have.id', 'myid')
2020-04-21 08:01:28 +02:00
.and('have.class', 'otherclass')
2020-05-17 10:23:36 +02:00
cy.get('img').eq(2).should('have.attr', 'alt', 'alt-text')
2020-04-21 08:01:28 +02:00
.and('have.attr', 'title', 'my title')
.and('have.attr', 'width', '150px')
/* blockquote */
cy.get('blockquote').should('exist')
2020-05-17 10:23:36 +02:00
/* has navigation element */
cy.get('.notice1').should('exist')
cy.get('.notice2').should('exist')
cy.get('.notice3').should('exist')
2020-04-21 08:01:28 +02:00
/* footnote */
cy.get('sup').eq(0).should('have.id', 'fnref1:1')
cy.get('sup').eq(0).within(($sup) =>{
2021-01-08 10:10:47 +01:00
cy.get('a').eq(0).should('have.attr', 'href', '#fn%3A1')
2020-04-21 08:01:28 +02:00
.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')
2021-01-08 10:10:47 +01:00
.and('have.attr', 'href', '#fnref1%3A1')
2020-04-21 08:01:28 +02:00
.and('have.attr', 'rev', 'footnote')
})
})
})