test04-theme-settings.spec.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. describe('Typemill Theme Settings', function()
  2. {
  3. before(function ()
  4. {
  5. cy.visit('/tm/login')
  6. cy.url().should('include','/tm/login')
  7. cy.get('input[name="username"]').type('trendschau')
  8. cy.get('input[name="password"]').type('password')
  9. cy.get('form').submit()
  10. cy.url().should('include','/tm/content')
  11. cy.getCookie('typemill-session').should('exist')
  12. cy.visit('/tm/themes')
  13. cy.url().should('include','/tm/themes')
  14. })
  15. beforeEach(function ()
  16. {
  17. Cypress.Cookies.preserveOnce('typemill-session')
  18. })
  19. it('changes default values', function()
  20. {
  21. // open the form
  22. cy.get('#cyanine-toggle')
  23. .should('contain', 'Settings')
  24. .click()
  25. // fill out valid data
  26. cy.get('input[name="cyanine[introButtonLink]"]')
  27. .clear()
  28. .type('https://typemill.net')
  29. .should('have.value', 'https://typemill.net')
  30. // fill out valid data
  31. cy.get('input[name="cyanine[introButtonLabel]"]')
  32. .clear()
  33. .type('Typemill')
  34. .should('have.value', 'Typemill')
  35. // fill out valid data
  36. cy.get('input[name="cyanine[chapnum]"]')
  37. .should('not.be.checked')
  38. .and('not.be.visible')
  39. .check({ force: true })
  40. .should('be.checked')
  41. // fill out valid data
  42. cy.get('input[name="cyanine[authorPosition][top]"]')
  43. .should('not.be.checked')
  44. .and('not.be.visible')
  45. .check({ force: true })
  46. .should('be.checked')
  47. // fill out valid data
  48. cy.get('input[name="cyanine[authorIntro]"]')
  49. .clear()
  50. .type('Writer')
  51. .should('have.value', 'Writer')
  52. // fill out valid data
  53. cy.get('input[name="cyanine[datePosition][bottom]"]')
  54. .should('not.be.checked')
  55. .and('not.be.visible')
  56. .check({ force: true })
  57. .should('be.checked')
  58. // fill out valid data
  59. cy.get('input[name="cyanine[dateIntro]"]')
  60. .clear()
  61. .type('Final update')
  62. .should('have.value', 'Final update')
  63. cy.get('select[name="cyanine[dateFormat]"]')
  64. .should('have.value', 'm/d/Y')
  65. .select('m/d/Y')
  66. .should('have.value', 'm/d/Y')
  67. cy.get('input[name="cyanine[gitPosition][top]"]')
  68. .should('not.be.checked')
  69. .and('not.be.visible')
  70. .check({ force: true })
  71. .should('be.checked')
  72. cy.get('input[name="cyanine[gitLink]"]')
  73. .clear()
  74. .type('https://github.com/typemill/docs')
  75. .should('have.value', 'https://github.com/typemill/docs')
  76. cy.get('#theme-cyanine').submit()
  77. cy.get('#flash-message').should('contain', 'Settings are stored')
  78. // fill out valid data
  79. cy.get('input[name="cyanine[introButtonLink]"]')
  80. .should('have.value', 'https://typemill.net')
  81. // fill out valid data
  82. cy.get('input[name="cyanine[introButtonLabel]"]')
  83. .should('have.value', 'Typemill')
  84. // fill out valid data
  85. cy.get('input[name="cyanine[chapnum]"]')
  86. .should('be.checked')
  87. // fill out valid data
  88. cy.get('input[name="cyanine[authorPosition][top]"]')
  89. .should('be.checked')
  90. // fill out valid data
  91. cy.get('input[name="cyanine[authorIntro]"]')
  92. .should('have.value', 'Writer')
  93. // fill out valid data
  94. cy.get('input[name="cyanine[datePosition][bottom]"]')
  95. .should('be.checked')
  96. // fill out valid data
  97. cy.get('input[name="cyanine[dateIntro]"]')
  98. .should('have.value', 'Final update')
  99. cy.get('select[name="cyanine[dateFormat]"]')
  100. .should('have.value', 'm/d/Y')
  101. cy.get('input[name="cyanine[gitPosition][top]"]')
  102. .should('be.checked')
  103. cy.get('input[name="cyanine[gitLink]"]')
  104. .should('have.value', 'https://github.com/typemill/docs')
  105. })
  106. it('validates input', function()
  107. {
  108. // open the form
  109. cy.get('#cyanine-toggle')
  110. .should('contain', 'Settings')
  111. .click()
  112. // fill out invalid data
  113. cy.get('input[name="cyanine[introButtonLabel]"]')
  114. .should('have.value', 'Typemill')
  115. .clear()
  116. .type('Kapitel<?')
  117. .should('have.value', 'Kapitel<?')
  118. // submit form
  119. cy.get('#theme-cyanine').submit()
  120. cy.get('#flash-message').should('contain', 'Please correct the errors')
  121. })
  122. })