-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: cypress: e2e: Add test for open read-only mode
Signed-off-by: Benjamin Thiemann <[email protected]>
- Loading branch information
Showing
1 changed file
with
108 additions
and
0 deletions.
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,108 @@ | ||
import { User } from '@nextcloud/cypress' | ||
import { randUser } from '../utils/index.js' | ||
|
||
|
||
const admin = new User('admin', 'admin') | ||
const user = randUser() | ||
|
||
describe('Open read-only mode', function () { | ||
|
||
describe('Disabled', function() { | ||
const checkMenubar = function() { | ||
cy.get('.text-editor--readonly-bar').should('not.exist') | ||
cy.get('.text-menubar').getActionEntry('done').should('not.exist') | ||
} | ||
|
||
beforeEach(function() { | ||
cy.createUser(user) | ||
cy.login(user) | ||
cy.uploadFile('test.md', 'text/markdown') | ||
cy.uploadFile('test.md', 'text/markdown', 'test.txt') | ||
cy.visit('/apps/files') | ||
}) | ||
|
||
it('Test writable markdown file', function() { | ||
cy.openFile('test.md') | ||
checkMenubar() | ||
}) | ||
|
||
it('Test writable text file', function() { | ||
cy.openFile('test.txt') | ||
checkMenubar() | ||
}) | ||
}) | ||
|
||
describe('Enabled', function () { | ||
const requireReadOnlyBar = function () { | ||
cy.get('.text-editor--readonly-bar').should('exist') | ||
cy.get('.text-editor--readonly-bar').getActionEntry('edit').should('exist') | ||
} | ||
|
||
const requireMenubar = function () { | ||
cy.get('.text-editor--readonly-bar').should('not.exist') | ||
cy.get('.text-menubar').getActionEntry('done').should('exist') | ||
} | ||
|
||
beforeEach(function () { | ||
cy.login(admin) | ||
cy.ocsRequest({ | ||
method: 'POST', | ||
url: `http://localhost/ocs/v2.php/apps/testing/api/v1/app/text/open_read_only`, | ||
body: { value: '1' } | ||
}).then(response => { | ||
cy.log(response.status) | ||
}) | ||
cy.logout() | ||
|
||
cy.createUser(user) | ||
cy.login(user) | ||
// cy.runOccCommand('config:app:set text open_read_only_enabled --value=1') | ||
|
||
// const requestData = { | ||
// method: 'POST', | ||
// url: 'http://localhost/ocs/v1.php/apps/testing/api/v1/app/text/open_read_only_enabled', | ||
// body: '1' | ||
// } | ||
|
||
// cy.request(requestData).then(({ status }) => { | ||
// expect(status).to.eq(200) | ||
// }) | ||
|
||
// cy.removeFile('test.md') | ||
// cy.removeFile('test.txt') | ||
|
||
cy.uploadFile('test.md', 'text/markdown') | ||
cy.uploadFile('test.md', 'text/plain', 'test.txt') | ||
|
||
cy.visit('/apps/files') | ||
}) | ||
|
||
it('Test read-only markdown file', function () { | ||
cy.openFile('test.md') | ||
|
||
requireReadOnlyBar() | ||
|
||
// Switch to edit-mode | ||
cy.get('.text-editor--readonly-bar').getActionEntry('edit').click() | ||
|
||
requireMenubar() | ||
|
||
// Switch to read-only mode | ||
cy.get('.text-menubar').getActionEntry('done').click() | ||
|
||
requireReadOnlyBar() | ||
}) | ||
|
||
it('Test read-only text file', function () { | ||
cy.openFile('test.txt') | ||
|
||
requireReadOnlyBar() | ||
|
||
// Switch to edit-mode | ||
cy.get('.text-editor--readonly-bar').getActionEntry('edit').click() | ||
|
||
// Check that read-only bar does not exist | ||
cy.get('.text-editor--readonly-bar').should('not.exist') | ||
}) | ||
}) | ||
}) |