test02-initial-frontend.spec.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. describe('Typemill Initial Frontend', function()
  2. {
  3. it('has startpage with navigation', function ()
  4. {
  5. /* visit homepage */
  6. cy.visit('/')
  7. /* has startpage with headline */
  8. cy.get('h1').contains("Typemill")
  9. /* has start and setup button */
  10. cy.get('.cy-nav').find('a').should(($a) => {
  11. expect($a).to.have.length(10)
  12. expect($a[0].href).to.match(/welcome/)
  13. expect($a[1].href).to.match(/welcome\/setup/)
  14. expect($a[2].href).to.match(/welcome\/write-content/)
  15. expect($a[3].href).to.match(/welcome\/get-help/)
  16. expect($a[4].href).to.match(/welcome\/markdown-test/)
  17. expect($a[5].href).to.match(/cyanine-theme/)
  18. expect($a[6].href).to.match(/cyanine-theme\/landingpage/)
  19. expect($a[7].href).to.match(/cyanine-theme\/colors-and-fonts/)
  20. expect($a[8].href).to.match(/cyanine-theme\/footer/)
  21. expect($a[9].href).to.match(/cyanine-theme\/content-elements/)
  22. })
  23. })
  24. it('has error page', function ()
  25. {
  26. cy.request({
  27. url: '/error',
  28. failOnStatusCode: false,
  29. })
  30. .then((resp) => {
  31. /* should return 404 not found */
  32. expect(resp.status).to.eq(404)
  33. })
  34. cy.visit('/error', { failOnStatusCode: false })
  35. cy.url().should('include','/error')
  36. cy.get('h1').contains('Not Found')
  37. })
  38. it('has no access to cache files', function ()
  39. {
  40. cy.request({
  41. url: '/cache/structure.txt',
  42. failOnStatusCode: false,
  43. })
  44. .then((resp) => {
  45. // redirect status code is 302
  46. expect(resp.status).to.eq(403)
  47. })
  48. })
  49. it('has sitemap xml', function ()
  50. {
  51. cy.request({
  52. url: '/cache/sitemap.xml',
  53. })
  54. .then((resp) => {
  55. /* should return xml-format */
  56. expect(resp.headers).to.have.property('content-type','application/xml')
  57. })
  58. })
  59. it('has no access to dashboard', function ()
  60. {
  61. cy.visit('/tm/settings')
  62. cy.url().should('include','/tm/login')
  63. })
  64. it('has proper markdown test page', function ()
  65. {
  66. cy.visit('/welcome/markdown-test')
  67. cy.url().should('include','/welcome/markdown-test')
  68. /* has navigation element */
  69. cy.get('nav').should('exist')
  70. /* check if toc exists */
  71. cy.get('.TOC').within(($toc) =>{
  72. /* check if a certain link in toc exists */
  73. cy.get('a').eq(2).should('have.attr', 'href', '/typemillTest/welcome/markdown-test#headlines')
  74. })
  75. /* check if corresponding anchor exists */
  76. cy.get('#headlines').should('exist')
  77. /* soft linebreaks */
  78. cy.get('br').should('exist')
  79. /* emphasis */
  80. cy.get('em').should('exist')
  81. /* strong */
  82. cy.get('strong').should('exist')
  83. /* ordered list */
  84. cy.get('ol').should('exist')
  85. /* linebreak */
  86. cy.get('hr').should('exist')
  87. /* links exists? hard to test, any idea? We need to wrap it in a div... */
  88. /* images */
  89. cy.get('img').eq(0).should('have.attr', 'alt', 'alt')
  90. cy.get('img').eq(0).should('have.attr', 'src', 'media/files/markdown.png')
  91. cy.get('figure').eq(2).should('have.id', 'myid')
  92. .and('have.class', 'otherclass')
  93. cy.get('img').eq(2).should('have.attr', 'alt', 'alt-text')
  94. .and('have.attr', 'title', 'my title')
  95. .and('have.attr', 'width', '150px')
  96. /* blockquote */
  97. cy.get('blockquote').should('exist')
  98. /* has navigation element */
  99. cy.get('.notice1').should('exist')
  100. cy.get('.notice2').should('exist')
  101. cy.get('.notice3').should('exist')
  102. /* footnote */
  103. cy.get('sup').eq(0).should('have.id', 'fnref1:1')
  104. cy.get('sup').eq(0).within(($sup) =>{
  105. cy.get('a').eq(0).should('have.attr', 'href', '/typemillTest/welcome/markdown-test#fn%3A1')
  106. .and('have.class', 'footnote-ref')
  107. })
  108. /* abbreviation */
  109. cy.get('abbr').should('exist')
  110. /* definition list */
  111. cy.get('dl').should('exist')
  112. /* table */
  113. cy.get('table').should('exist')
  114. /* code */
  115. cy.get('pre').should('exist')
  116. cy.get('code').should('exist')
  117. /* math */
  118. cy.get('.math').should('exist')
  119. /* footnote end */
  120. cy.get('.footnotes').within(($footnotes) => {
  121. cy.get('li').eq(0).should('have.id', 'fn:1')
  122. cy.get('a').eq(0).should('have.class', 'footnote-backref')
  123. .and('have.attr', 'href', '/typemillTest/welcome/markdown-test#fnref1%3A1')
  124. .and('have.attr', 'rev', 'footnote')
  125. })
  126. })
  127. })