test02-initial-frontend.spec.js 4.5 KB

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