Skip to content

Commit 80a83de

Browse files
mejo-pbirrer
authored andcommitted
text(cy): Fix CSS selectors for readonly bar
Signed-off-by: Jonas <jonas@freesources.org>
1 parent 1f0fb45 commit 80a83de

2 files changed

Lines changed: 32 additions & 26 deletions

File tree

cypress/e2e/openreadonly.spec.js

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,80 @@ import { randUser } from '../utils/index.js'
99
const admin = new User('admin', 'admin')
1010
const user = randUser()
1111

12-
describe('Open read-only mode', function() {
13-
14-
before(function() {
12+
describe('Open read-only mode', function () {
13+
before(function () {
1514
cy.createUser(user)
1615
cy.login(user)
1716
cy.uploadFile('test.md', 'text/markdown')
1817
cy.uploadFile('test.md', 'text/plain', 'test.txt')
1918
})
2019

21-
const setReadOnlyMode = function(mode) {
20+
const setReadOnlyMode = function (mode) {
2221
cy.login(admin)
2322
cy.setAppConfig('open_read_only_enabled', mode)
2423
}
2524

26-
describe('Disabled', function() {
27-
const checkMenubar = function() {
28-
cy.get('.text-editor--readonly-bar').should('not.exist')
25+
describe('Disabled', function () {
26+
const checkMenubar = function () {
27+
cy.get('[data-text-el="readonly-bar"]').should('not.exist')
2928
cy.get('.text-menubar', { timeout: 10000 })
30-
.getActionEntry('done').should('not.exist')
29+
.getActionEntry('done')
30+
.should('not.exist')
3131
}
3232

33-
before(function() {
33+
before(function () {
3434
setReadOnlyMode(0)
3535
})
3636

37-
beforeEach(function() {
37+
beforeEach(function () {
3838
cy.login(user)
3939
cy.visit('/apps/files')
4040
})
4141

42-
it('Test writable markdown file', function() {
42+
it('Test writable markdown file', function () {
4343
cy.openFile('test.md')
4444
checkMenubar()
4545
})
4646

47-
it('Test writable text file', function() {
47+
it('Test writable text file', function () {
4848
cy.openFile('test.txt')
4949
checkMenubar()
5050
})
5151
})
5252

53-
describe('Enabled', function() {
54-
const requireReadOnlyBar = function() {
55-
cy.get('.text-editor--readonly-bar').should('exist')
56-
cy.get('.text-editor--readonly-bar').getActionEntry('edit').should('exist')
53+
describe('Enabled', function () {
54+
const requireReadOnlyBar = function () {
55+
cy.get('[data-text-el="readonly-bar"]').should('exist')
56+
cy.get('[data-text-el="readonly-bar"]')
57+
.getActionEntry('edit')
58+
.should('exist')
5759
}
5860

59-
const requireMenubar = function() {
60-
cy.get('.text-editor--readonly-bar').should('not.exist')
61+
const requireMenubar = function () {
62+
cy.get('[data-text-el="readonly-bar"]').should('not.exist')
6163
cy.get('.text-menubar').getActionEntry('done').should('exist')
6264
}
6365

64-
before(function() {
66+
before(function () {
6567
setReadOnlyMode(1)
6668
})
6769

68-
beforeEach(function() {
70+
beforeEach(function () {
6971
cy.login(user)
7072
cy.visit('/apps/files')
7173
})
7274

73-
it('Test read-only markdown file', function() {
75+
after(function () {
76+
setReadOnlyMode(0)
77+
})
78+
79+
it('Test read-only markdown file', function () {
7480
cy.openFile('test.md')
7581

7682
requireReadOnlyBar()
7783

7884
// Switch to edit-mode
79-
cy.get('.text-editor--readonly-bar').getActionEntry('edit').click()
85+
cy.get('[data-text-el="readonly-bar"]').getActionEntry('edit').click()
8086

8187
requireMenubar()
8288

@@ -86,16 +92,16 @@ describe('Open read-only mode', function() {
8692
requireReadOnlyBar()
8793
})
8894

89-
it('Test read-only text file', function() {
95+
it('Test read-only text file', function () {
9096
cy.openFile('test.txt')
9197

9298
requireReadOnlyBar()
9399

94100
// Switch to edit-mode
95-
cy.get('.text-editor--readonly-bar').getActionEntry('edit').click()
101+
cy.get('[data-text-el="readonly-bar"]').getActionEntry('edit').click()
96102

97103
// Check that read-only bar does not exist
98-
cy.get('.text-editor--readonly-bar').should('not.exist')
104+
cy.get('[data-text-el="readonly-bar"]').should('not.exist')
99105
})
100106
})
101107
})

cypress/e2e/share.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Open test.md in viewer', function() {
4040
.should('contain', 'Hello world')
4141
.find('h2').should('contain', 'Hello world')
4242

43-
cy.get('.text-editor--readonly-bar')
43+
cy.get('[data-text-el="readonly-bar"]')
4444
.getActionEntry('outline')
4545
.click()
4646

0 commit comments

Comments
 (0)