Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add cypress test for direct editing of plain text files
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Nov 23, 2022
commit ca985233653a6f6359bd7118190f855d09b5d814
27 changes: 26 additions & 1 deletion cypress/e2e/directediting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const createDirectEditingLinkForNewFile = (user, file) => {

describe('direct editing', function() {
before(function() {
initUserAndFiles(randUser, 'test.md', 'empty.md')
initUserAndFiles(randUser, 'test.md', 'empty.md', 'empty.txt')
})

it('Open an existing file, edit and close it', () => {
Expand Down Expand Up @@ -101,4 +101,29 @@ describe('direct editing', function() {
})
})
})

it('Open an existing plain text file, edit and close it', () => {
createDirectEditingLink(randUser, 'empty.txt')
.then((token) => {
cy.logout()
cy.visit(token)
})
const closeRequestAlias = 'closeRequest'
cy.intercept({ method: 'POST', url: '**/session/close' }).as(closeRequestAlias)

cy.getContent()
.type('# This is a headline')
.type('{enter}')
.type('Some text')
.type('{enter}')

cy.get('button.icon-close').click()
cy.wait(`@${closeRequestAlias}`).then(() => {
cy.getFileContent(randUser, 'empty.txt').then((content) => {
// FIXME: This currently fails due to the save not happening fast enough
// The best would be if we always send the markdown at least on close and perform a save if the content changed
// expect(content).to.equal('# This is a headline\n\nSome text');
})
})
})
})
Empty file added cypress/fixtures/empty.txt
Empty file.