You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Navigation.cy.ts 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* eslint-disable import/first */
  2. import FolderSvg from '@mdi/svg/svg/folder.svg'
  3. import ShareSvg from '@mdi/svg/svg/share-variant.svg'
  4. import NavigationService from '../services/Navigation'
  5. import NavigationView from './Navigation.vue'
  6. import router from '../router/router.js'
  7. const Navigation = new NavigationService()
  8. console.log(FolderSvg)
  9. describe('Navigation renders', () => {
  10. it('renders', () => {
  11. cy.mount(NavigationView, {
  12. propsData: {
  13. Navigation,
  14. },
  15. })
  16. cy.get('[data-cy-files-navigation]').should('be.visible')
  17. cy.get('[data-cy-files-navigation-settings-button]').should('be.visible')
  18. })
  19. })
  20. describe('Navigation API', () => {
  21. it('Check API entries rendering', () => {
  22. Navigation.register({
  23. id: 'files',
  24. name: 'Files',
  25. getFiles: () => [],
  26. icon: FolderSvg,
  27. order: 1,
  28. })
  29. cy.mount(NavigationView, {
  30. propsData: {
  31. Navigation,
  32. },
  33. router,
  34. })
  35. cy.get('[data-cy-files-navigation]').should('be.visible')
  36. cy.get('[data-cy-files-navigation-item]').should('have.length', 1)
  37. cy.get('[data-cy-files-navigation-item="files"]').should('be.visible')
  38. cy.get('[data-cy-files-navigation-item="files"]').should('contain.text', 'Files')
  39. })
  40. it('Adds a new entry and render', () => {
  41. Navigation.register({
  42. id: 'sharing',
  43. name: 'Sharing',
  44. getFiles: () => [],
  45. icon: ShareSvg,
  46. order: 2,
  47. })
  48. cy.mount(NavigationView, {
  49. propsData: {
  50. Navigation,
  51. },
  52. router,
  53. })
  54. cy.get('[data-cy-files-navigation]').should('be.visible')
  55. cy.get('[data-cy-files-navigation-item]').should('have.length', 2)
  56. cy.get('[data-cy-files-navigation-item="sharing"]').should('be.visible')
  57. cy.get('[data-cy-files-navigation-item="sharing"]').should('contain.text', 'Sharing')
  58. })
  59. it('Adds a new children, render and open menu', () => {
  60. Navigation.register({
  61. id: 'sharingin',
  62. name: 'Shared with me',
  63. getFiles: () => [],
  64. parent: 'sharing',
  65. icon: ShareSvg,
  66. order: 1,
  67. })
  68. cy.mount(NavigationView, {
  69. propsData: {
  70. Navigation,
  71. },
  72. router,
  73. })
  74. cy.get('[data-cy-files-navigation]').should('be.visible')
  75. cy.get('[data-cy-files-navigation-item]').should('have.length', 3)
  76. // Intercept collapse preference request
  77. cy.intercept('POST', '*/apps/files/api/v1/toggleShowFolder/*', {
  78. statusCode: 200,
  79. }).as('toggleShowFolder')
  80. // Toggle the sharing entry children
  81. cy.get('[data-cy-files-navigation-item="sharing"] button.icon-collapse').should('exist')
  82. cy.get('[data-cy-files-navigation-item="sharing"] button.icon-collapse').click({ force: true })
  83. cy.wait('@toggleShowFolder')
  84. // Validate children
  85. cy.get('[data-cy-files-navigation-item="sharingin"]').should('be.visible')
  86. cy.get('[data-cy-files-navigation-item="sharingin"]').should('contain.text', 'Shared with me')
  87. })
  88. it('Throws when adding a duplicate entry', () => {
  89. expect(() => {
  90. Navigation.register({
  91. id: 'files',
  92. name: 'Files',
  93. getFiles: () => [],
  94. icon: FolderSvg,
  95. order: 1,
  96. })
  97. }).to.throw('Navigation id files is already registered')
  98. })
  99. })