-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathintegration.spec.js
More file actions
183 lines (149 loc) · 5.38 KB
/
integration.spec.js
File metadata and controls
183 lines (149 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**
* SPDX-FileCopyrightText: 2023 Julius Härtl <jus@bitgrid.net>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
describe('Nextcloud integration', function() {
let randUser
before(function() {
cy.nextcloudTestingAppConfigSet('richdocuments', 'uiDefaults-UIMode', 'notebookbar')
cy.createRandomUser().then(user => {
randUser = user
cy.login(user)
cy.uploadFile(randUser, 'image.png', 'image/png', '/image.png')
cy.uploadFile(user, 'document.odt', 'application/vnd.oasis.opendocument.text', '/document.odt')
})
})
const filename = 'document.odt'
beforeEach(function() {
cy.login(randUser)
cy.visit('/apps/files', {
onBeforeLoad(win) {
cy.spy(win, 'postMessage').as('postMessage')
},
})
cy.openFile(filename)
cy.waitForViewer()
cy.waitForCollabora()
})
it('Sharing sidebar', function() {
cy.get('@loleafletframe').within(() => {
cy.get('.notebookbar-tabs-container', { timeout: 30_000 })
.should('be.visible')
cy.get('button[aria-label="File"]').click()
cy.get('button#ShareAs-button').click()
})
cy.get('#app-sidebar-vue')
.should('be.visible')
cy.get('.app-sidebar-header__mainname')
.should('be.visible')
.should('contain.text', filename)
cy.get('#tab-sharing').should('be.visible')
})
it('Versions sidebar', function() {
cy.get('@loleafletframe').within(() => {
cy.get('.notebookbar-tabs-container', { timeout: 30_000 })
.should('be.visible')
cy.get('button[aria-label="File"]').click()
cy.get('button[aria-label="See history"]').click()
})
cy.get('#app-sidebar-vue')
.should('be.visible')
cy.get('.app-sidebar-header__mainname')
.should('be.visible')
.should('contain.text', filename)
cy.get('#tab-version_vue').should('be.visible')
cy.get('#tab-version_vue .version__info__label').contains('Current version')
})
it.skip('Save as', function() {
const exportFilename = 'document.rtf'
cy.get('@loleafletframe').within(() => {
cy.get('.notebookbar-tabs-container', { timeout: 30_000 })
.should('be.visible')
cy.get('button[aria-label="File"]').click()
cy.get('button[aria-label="Save As"]').click()
cy.get('#saveas-entries #saveas-entry-1').click()
})
cy.get('.saveas-dialog').should('be.visible')
cy.get('.saveas-dialog input[type=text]')
.should('be.visible')
.should('have.value', `/${exportFilename}`)
cy.get('.saveas-dialog button.button-vue--vue-primary').click()
cy.get('@loleafletframe').within(() => {
cy.get('#closebutton').click()
cy.waitForViewerClose()
})
// FIXME: We should not need to reload
cy.get('.breadcrumb__crumbs a').eq(0).click({ force: true })
cy.openFile(exportFilename)
})
it('Open locally', function() {
cy.get('@loleafletframe').within(() => {
cy.get('.notebookbar-shortcuts-bar', { timeout: 30_000 })
.should('be.visible')
cy.get('button[aria-label="Open in local editor"]').click()
})
cy.get('.confirmation-dialog').should('be.visible')
cy.get('.confirmation-dialog h1')
.should('contain', 'Open file locally')
cy.intercept({
method: 'POST',
url: '**/openlocaleditor',
}).as('getLocalToken')
cy.window()
.then((window) => {
cy.stub(window, 'open').as('open')
})
cy.get('.confirmation-dialog button:contains("Open locally")').click()
cy.wait('@getLocalToken').its('response.statusCode').should('equal', 200)
cy.get('@open').should('have.been.calledOnce')
const nextcloudHost = new URL(Cypress.config('baseUrl')).host
cy.get('@open').its('firstCall.args.0').should('contain', 'nc://open/' + randUser.userId + '@' + nextcloudHost + '/document.odt')
})
it('Insert image', function() {
cy.get('@loleafletframe').within(() => {
cy.get('#Insert-tab-label').click()
cy.get('#insert-insert-graphic-button').click()
cy.get('#insert-insert-graphic-entries #insert-insert-graphic-entry-1').click()
})
cy.get('.modal-container__content').should('be.visible')
})
describe('Smart picker', function() {
describe('Link to office document section', function() {
beforeEach(function() {
// Proc the smart picker from Collabora
cy.get('@loleafletframe').within(() => {
cy.get('#Insert-tab-label').click()
cy.get('#insert-insert-remote-link-button').click()
})
// Wait for the reference picker to show
cy.get('.reference-picker-modal--content')
.should('be.visible')
.as('referencePickerContent')
// Select "Link to office document section"
cy.get('@referencePickerContent')
.find('input[id="provider-select-input"]')
.as('smartPickerDropdown')
cy.get('@smartPickerDropdown').click()
cy.get('@referencePickerContent')
.find('ul[aria-label="Options"]')
.should('be.visible')
.contains('Link to office document section')
.click()
// Pick the fixture document
cy.pickFile('document.odt')
})
it.skip('Can link to heading', function() {
cy.get('[data-cy-section-label="Headings"]').children().first().click()
cy.get('[data-cy-link-to-section=""]').click()
})
it.skip('Can link to section', function() {
cy.get('[data-cy-section-label="Sections"]').children().first().click()
cy.get('[data-cy-link-to-section=""]').click()
})
it.skip('Can link to image', function() {
cy.get('[data-cy-section-label="Images"]').children().first().click()
cy.get('[data-cy-link-to-section=""]').click()
})
})
})
})