|
| 1 | +import { initUserAndFiles, randUser } from '../utils/index.js' |
| 2 | + |
| 3 | +const currentUser = randUser() |
| 4 | + |
| 5 | +const versionFileName = 'versioned.md' |
| 6 | + |
| 7 | +describe('Versions', () => { |
| 8 | + before(() => { |
| 9 | + initUserAndFiles(currentUser, 'empty.md') |
| 10 | + }) |
| 11 | + |
| 12 | + beforeEach(() => { |
| 13 | + cy.login(currentUser) |
| 14 | + cy.visit('/apps/files') |
| 15 | + }) |
| 16 | + |
| 17 | + it('View versions with close timestamps', () => { |
| 18 | + cy.isolateTest().then(({ folderName, fileName }) => { |
| 19 | + const fullPath = folderName + '/' + versionFileName |
| 20 | + cy.createFile(fullPath, '# V1', 'text/markdown', { 'x-oc-mtime': 1691420501 }) |
| 21 | + cy.createFile(fullPath, '# V2', 'text/markdown', { 'x-oc-mtime': 1691420521 }) |
| 22 | + cy.createFile(fullPath, '# V3', 'text/markdown') |
| 23 | + |
| 24 | + cy.reloadFileList() |
| 25 | + |
| 26 | + cy.get('[data-cy-files-list-row-name="' + versionFileName + '"] [data-cy-files-list-row-mtime]').click() |
| 27 | + cy.get('.app-sidebar-header').should('be.visible').should('contain', versionFileName) |
| 28 | + cy.get('.app-sidebar-tabs__tab[data-id="version_vue"]').click() |
| 29 | + cy.get('[data-files-versions-versions-list] li > a').should('have.length', 3) |
| 30 | + |
| 31 | + cy.get('[data-files-versions-versions-list] li > a').eq(1).click() |
| 32 | + cy.get('.viewer__content #read-only-editor') |
| 33 | + .find('h1 [data-node-view-content]') |
| 34 | + .should('have.text', 'V2') |
| 35 | + |
| 36 | + cy.get('[data-files-versions-versions-list] li > a').eq(2).click() |
| 37 | + cy.get('.viewer__content #read-only-editor') |
| 38 | + .find('h1 [data-node-view-content]') |
| 39 | + .should('have.text', 'V1') |
| 40 | + |
| 41 | + cy.get('[data-files-versions-versions-list] li > a').eq(0).click() |
| 42 | + cy.getContent() |
| 43 | + .find('h1 [data-node-view-content]') |
| 44 | + .should('have.text', 'V3') |
| 45 | + }) |
| 46 | + }) |
| 47 | + |
| 48 | + it('View versions', () => { |
| 49 | + cy.isolateTest().then(({ folderName, fileName }) => { |
| 50 | + const fullPath = folderName + '/' + versionFileName |
| 51 | + cy.createFile(fullPath, '# V1', 'text/markdown', { 'x-oc-mtime': 1691420521 }) |
| 52 | + cy.createFile(fullPath, '# V2', 'text/markdown', { 'x-oc-mtime': 1691521521 }) |
| 53 | + cy.createFile(fullPath, '# V3') |
| 54 | + |
| 55 | + cy.reloadFileList() |
| 56 | + |
| 57 | + cy.get('[data-cy-files-list-row-name="' + versionFileName + '"] [data-cy-files-list-row-mtime]').click() |
| 58 | + |
| 59 | + cy.get('.app-sidebar-header').should('be.visible').should('contain', versionFileName) |
| 60 | + |
| 61 | + cy.get('.app-sidebar-tabs__tab[data-id="version_vue"]').click() |
| 62 | + |
| 63 | + cy.get('[data-files-versions-versions-list] li > a').should('have.length', 3) |
| 64 | + |
| 65 | + cy.get('[data-files-versions-versions-list] li > a').eq(1).click() |
| 66 | + cy.get('.viewer__content #read-only-editor') |
| 67 | + .find('h1 [data-node-view-content]') |
| 68 | + .should('have.text', 'V2') |
| 69 | + |
| 70 | + cy.get('[data-files-versions-versions-list] li > a').eq(2).click() |
| 71 | + cy.get('.viewer__content #read-only-editor') |
| 72 | + .find('h1 [data-node-view-content]') |
| 73 | + .should('have.text', 'V1') |
| 74 | + |
| 75 | + cy.get('[data-files-versions-versions-list] li > a').eq(0).click() |
| 76 | + cy.getContent() |
| 77 | + .find('h1 [data-node-view-content]') |
| 78 | + .should('have.text', 'V3') |
| 79 | + |
| 80 | + cy.getContent() |
| 81 | + .type('Hello') |
| 82 | + }) |
| 83 | + }) |
| 84 | + |
| 85 | + it('Compare versions', () => { |
| 86 | + cy.isolateTest().then(({ folderName, fileName }) => { |
| 87 | + const fullPath = folderName + '/' + versionFileName |
| 88 | + cy.createFile(fullPath, '# V1', 'text/markdown', { 'x-oc-mtime': 1691420521 }) |
| 89 | + cy.createFile(fullPath, '# V2', 'text/markdown', { 'x-oc-mtime': 1691521521 }) |
| 90 | + cy.createFile(fullPath, '# V3') |
| 91 | + |
| 92 | + cy.reloadFileList() |
| 93 | + |
| 94 | + cy.get('[data-cy-files-list-row-name="' + versionFileName + '"] [data-cy-files-list-row-mtime]').click() |
| 95 | + |
| 96 | + cy.get('.app-sidebar-header').should('be.visible').should('contain', versionFileName) |
| 97 | + |
| 98 | + cy.get('.app-sidebar-tabs__tab[data-id="version_vue"]').click() |
| 99 | + |
| 100 | + cy.get('[data-files-versions-versions-list] li > a').should('have.length', 3) |
| 101 | + |
| 102 | + cy.get('[data-files-versions-versions-list] li').eq(2) |
| 103 | + .find('button.action-item__menutoggle').first().click({ force: true }) |
| 104 | + |
| 105 | + cy.get('.v-popper__inner') |
| 106 | + .find('button') |
| 107 | + .eq(1) |
| 108 | + .should('contain', 'Compare to current version') |
| 109 | + .click() |
| 110 | + |
| 111 | + cy.get('.viewer__content #read-only-editor') |
| 112 | + .find('h1 [data-node-view-content]') |
| 113 | + .should('have.text', 'V1') |
| 114 | + |
| 115 | + cy.get('.viewer__content .viewer__file--active .ProseMirror') |
| 116 | + .find('h1 [data-node-view-content]') |
| 117 | + .should('contain.text', 'V3') |
| 118 | + }) |
| 119 | + }) |
| 120 | +}) |
0 commit comments