-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(cypress): Add version view and compare tests
Signed-off-by: Julius Härtl <[email protected]>
- Loading branch information
1 parent
9817233
commit 7b4be33
Showing
3 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import { initUserAndFiles, randUser } from '../utils/index.js' | ||
|
||
const currentUser = randUser() | ||
|
||
const versionFileName = 'versioned.md' | ||
|
||
describe('Versions', () => { | ||
before(() => { | ||
initUserAndFiles(currentUser, 'empty.md') | ||
}) | ||
|
||
beforeEach(() => { | ||
cy.login(currentUser) | ||
cy.visit('/apps/files') | ||
}) | ||
|
||
it('View versions with close timestamps', () => { | ||
cy.isolateTest().then(({ folderName, fileName }) => { | ||
const fullPath = folderName + '/' + versionFileName | ||
cy.createFile(fullPath, '# V1', 'text/markdown', { 'x-oc-mtime': 1691420501 }) | ||
cy.createFile(fullPath, '# V2', 'text/markdown', { 'x-oc-mtime': 1691420521 }) | ||
cy.createFile(fullPath, '# V3', 'text/markdown') | ||
|
||
cy.reloadFileList() | ||
|
||
cy.get('tr[data-file="' + versionFileName + '"] td.date').click() | ||
cy.get('.app-sidebar-header').should('be.visible').should('contain', versionFileName) | ||
cy.get('.app-sidebar-tabs__tab[data-id="version_vue"]').click() | ||
cy.get('[data-files-versions-versions-list] li > a').should('have.length', 3) | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').eq(1).click() | ||
cy.get('.viewer__content #read-only-editor') | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V2') | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').eq(2).click() | ||
cy.get('.viewer__content #read-only-editor') | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V1') | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').eq(0).click() | ||
cy.getContent() | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V3') | ||
}) | ||
}) | ||
|
||
it('View versions', () => { | ||
cy.isolateTest().then(({ folderName, fileName }) => { | ||
const fullPath = folderName + '/' + versionFileName | ||
cy.createFile(fullPath, '# V1', 'text/markdown', { 'x-oc-mtime': 1691420521 }) | ||
cy.createFile(fullPath, '# V2', 'text/markdown', { 'x-oc-mtime': 1691521521 }) | ||
cy.createFile(fullPath, '# V3') | ||
|
||
cy.reloadFileList() | ||
|
||
cy.get('tr[data-file="' + versionFileName + '"] td.date').click() | ||
|
||
cy.get('.app-sidebar-header').should('be.visible').should('contain', versionFileName) | ||
|
||
cy.get('.app-sidebar-tabs__tab[data-id="version_vue"]').click() | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').should('have.length', 3) | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').eq(1).click() | ||
cy.get('.viewer__content #read-only-editor') | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V2') | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').eq(2).click() | ||
cy.get('.viewer__content #read-only-editor') | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V1') | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').eq(0).click() | ||
cy.getContent() | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V3') | ||
|
||
cy.getContent() | ||
.type('Hello') | ||
}) | ||
}) | ||
|
||
it('Compare versions', () => { | ||
cy.isolateTest().then(({ folderName, fileName }) => { | ||
const fullPath = folderName + '/' + versionFileName | ||
cy.createFile(fullPath, '# V1', 'text/markdown', { 'x-oc-mtime': 1691420521 }) | ||
cy.createFile(fullPath, '# V2', 'text/markdown', { 'x-oc-mtime': 1691521521 }) | ||
cy.createFile(fullPath, '# V3') | ||
|
||
cy.reloadFileList() | ||
|
||
cy.get('tr[data-file="' + versionFileName + '"] td.date').click() | ||
|
||
cy.get('.app-sidebar-header').should('be.visible').should('contain', versionFileName) | ||
|
||
cy.get('.app-sidebar-tabs__tab[data-id="version_vue"]').click() | ||
|
||
cy.get('[data-files-versions-versions-list] li > a').should('have.length', 3) | ||
|
||
cy.get('[data-files-versions-versions-list] li').eq(2) | ||
.find('button.action-item__menutoggle').first().click({ force: true }) | ||
|
||
cy.get('.v-popper__inner') | ||
.find('button') | ||
.eq(1) | ||
.should('contain', 'Compare to current version') | ||
.click() | ||
|
||
cy.get('.viewer__content #read-only-editor') | ||
.find('h1 [data-node-view-content]') | ||
.should('have.text', 'V1') | ||
|
||
cy.get('.viewer__content .viewer__file--active .ProseMirror') | ||
.find('h1 [data-node-view-content]') | ||
.should('contain.text', 'V3') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters