Skip to content

Commit ef3db38

Browse files
Kocenjeck
authored andcommitted
Enhancement: Make tables import asynchronous
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent afb1f13 commit ef3db38

19 files changed

Lines changed: 1728 additions & 92 deletions

REUSE.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ SPDX-FileCopyrightText = "2017 Nextcloud GmbH and Nextcloud contributors"
6666
SPDX-License-Identifier = "AGPL-3.0-or-later"
6767

6868
[[annotations]]
69-
path = ["cypress/styleguide/assets/img/filetypes/font.svg", "cypress/styleguide/assets/img/actions/star-rounded.svg", "cypress/fixtures/example.json", "cypress/fixtures/NC_server_test.pdf", "cypress/fixtures/photo-test-1.jpeg", "cypress/fixtures/test-import.csv", "playwright/fixtures/example.json", "playwright/fixtures/NC_server_test.pdf", "playwright/fixtures/photo-test-1.jpeg", "playwright/fixtures/test-import.csv", "docs/permissions-matrix.xlsx", "tests/stub.phpstub", "tests/integration/composer.json", "tests/integration/composer.lock", "tests/integration/base-query-count.txt"]
69+
path = ["cypress/styleguide/assets/img/filetypes/font.svg", "cypress/styleguide/assets/img/actions/star-rounded.svg", "cypress/fixtures/example.json", "cypress/fixtures/NC_server_test.pdf", "cypress/fixtures/photo-test-1.jpeg", "cypress/fixtures/test-import-large.csv", "cypress/fixtures/test-import-small.csv", "playwright/fixtures/example.json", "playwright/fixtures/NC_server_test.pdf", "playwright/fixtures/photo-test-1.jpeg", "playwright/fixtures/test-import.csv", "docs/permissions-matrix.xlsx", "tests/stub.phpstub", "tests/integration/composer.json", "tests/integration/composer.lock", "tests/integration/base-query-count.txt"]
7070
precedence = "aggregate"
7171
SPDX-FileCopyrightText = "2023 Nextcloud GmbH and Nextcloud contributors"
7272
SPDX-License-Identifier = "AGPL-3.0-or-later"

appinfo/routes.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,18 @@
104104

105105
// import
106106
['name' => 'import#previewImportTable', 'url' => '/import-preview/table/{tableId}', 'verb' => 'POST'],
107-
['name' => 'import#importInTable', 'url' => '/import/table/{tableId}', 'verb' => 'POST'],
107+
['name' => 'import#importV2InTable', 'url' => '/v2/import/table/{tableId}', 'verb' => 'POST'],
108+
['name' => 'import#importV2InView', 'url' => '/v2/import/view/{viewId}', 'verb' => 'POST'],
108109
['name' => 'import#previewImportView', 'url' => '/import-preview/view/{viewId}', 'verb' => 'POST'],
109-
['name' => 'import#importInView', 'url' => '/import/view/{viewId}', 'verb' => 'POST'],
110110
['name' => 'import#previewUploadImportTable', 'url' => '/importupload-preview/table/{tableId}', 'verb' => 'POST'],
111-
['name' => 'import#importUploadInTable', 'url' => '/importupload/table/{tableId}', 'verb' => 'POST'],
112111
['name' => 'import#previewUploadImportView', 'url' => '/importupload-preview/view/{viewId}', 'verb' => 'POST'],
112+
['name' => 'import#importV2UploadInTable', 'url' => '/v2/importupload/table/{tableId}', 'verb' => 'POST'],
113+
['name' => 'import#importV2UploadInView', 'url' => '/v2/importupload/view/{viewId}', 'verb' => 'POST'],
114+
// deprecated endpoints
115+
['name' => 'import#importUploadInTable', 'url' => '/importupload/table/{tableId}', 'verb' => 'POST'],
113116
['name' => 'import#importUploadInView', 'url' => '/importupload/view/{viewId}', 'verb' => 'POST'],
117+
['name' => 'import#importInTable', 'url' => '/import/table/{tableId}', 'verb' => 'POST'],
118+
['name' => 'import#importInView', 'url' => '/import/view/{viewId}', 'verb' => 'POST'],
114119

115120
// search
116121
['name' => 'search#all', 'url' => '/search/all', 'verb' => 'GET'],

cypress/e2e/tables-import.cy.js

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ describe('Import csv', () => {
1010
cy.createRandomUser().then(user => {
1111
localUser = user
1212
cy.login(localUser)
13-
cy.uploadFile('test-import.csv', 'text/csv')
13+
cy.uploadFile('test-import-small.csv', 'text/csv')
14+
cy.uploadFile('test-import-large.csv', 'text/csv')
1415
})
1516
})
1617

@@ -19,11 +20,11 @@ describe('Import csv', () => {
1920
cy.visit('apps/tables')
2021
})
2122

22-
it('Import csv from Files', () => {
23+
it('Import small csv from Files', () => {
2324
cy.loadTable('Welcome to Nextcloud Tables!')
2425
cy.clickOnTableThreeDotMenu('Import')
2526
cy.get('.modal__content button').contains('Select from Files').click()
26-
cy.get('.file-picker__files').contains('test-import').click()
27+
cy.get('.file-picker__files').contains('test-import-small').click()
2728
cy.get('.file-picker button span').contains('Import').click()
2829
cy.get('.modal__content .import-filename', { timeout: 5000 }).should('be.visible')
2930

@@ -32,7 +33,7 @@ describe('Import csv', () => {
3233
cy.wait('@importPreviewPath')
3334
cy.get('.file_import__preview tbody tr', { timeout: 20000 }).should('have.length', 4)
3435

35-
cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*' }).as('importUploadReq')
36+
cy.intercept({ method: 'POST', url: '**/apps/tables/v2/import/table/*' }).as('importUploadReq')
3637
cy.get('.modal__content button').contains('Import').click()
3738
cy.wait('@importUploadReq')
3839
cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4')
@@ -43,18 +44,36 @@ describe('Import csv', () => {
4344
cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0')
4445
})
4546

46-
it('Import csv from device', () => {
47+
it('Import large csv from Files', () => {
48+
cy.loadTable('Welcome to Nextcloud Tables!')
49+
cy.clickOnTableThreeDotMenu('Import')
50+
cy.get('.modal__content button').contains('Select from Files').click()
51+
cy.get('.file-picker__files').contains('test-import-large').click()
52+
cy.get('.file-picker button span').contains('Import').click()
53+
cy.get('.modal__content .import-filename', { timeout: 5000 }).should('be.visible')
54+
55+
cy.intercept({ method: 'POST', url: '**/apps/tables/import-preview/**' }).as('importPreviewPath')
56+
cy.get('.modal__content button').contains('Preview').click()
57+
cy.wait('@importPreviewPath')
58+
cy.get('.file_import__preview tbody tr', { timeout: 20000 }).should('have.length', 4)
59+
60+
cy.intercept({ method: 'POST', url: '**/apps/tables/v2/import/table/*' }).as('importUploadReq')
61+
cy.get('.modal__content button').contains('Import').click()
62+
cy.wait('@importUploadReq').its('response.statusCode').should('equal', 200)
63+
})
64+
65+
it('Import small csv from device', () => {
4766
cy.loadTable('Welcome to Nextcloud Tables!')
4867
cy.clickOnTableThreeDotMenu('Import')
4968
cy.get('.modal__content button').contains('Upload from device').click()
50-
cy.get('input[type="file"]').selectFile('cypress/fixtures/test-import.csv', { force: true })
69+
cy.get('input[type="file"]').selectFile('cypress/fixtures/test-import-small.csv', { force: true })
5170

5271
cy.intercept({ method: 'POST', url: '**/apps/tables/importupload-preview/**' }).as('importPreviewUpload')
5372
cy.get('.modal__content button').contains('Preview').click()
5473
cy.wait('@importPreviewUpload')
5574
cy.get('.file_import__preview tbody tr', { timeout: 20000 }).should('have.length', 4)
5675

57-
cy.intercept({ method: 'POST', url: '**/apps/tables/importupload/table/*' }).as('importUploadReq')
76+
cy.intercept({ method: 'POST', url: '**/apps/tables/v2/importupload/table/*' }).as('importUploadReq')
5877
cy.get('.modal__content button').contains('Import').click()
5978
cy.wait('@importUploadReq')
6079
cy.get('[data-cy="importResultColumnsFound"]', { timeout: 20000 }).should('contain.text', '4')
@@ -65,6 +84,22 @@ describe('Import csv', () => {
6584
cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0')
6685
})
6786

87+
it('Import large csv from device', () => {
88+
cy.loadTable('Welcome to Nextcloud Tables!')
89+
cy.clickOnTableThreeDotMenu('Import')
90+
cy.get('.modal__content button').contains('Upload from device').click()
91+
cy.get('input[type="file"]').selectFile('cypress/fixtures/test-import-large.csv', { force: true })
92+
93+
cy.intercept({ method: 'POST', url: '**/apps/tables/importupload-preview/**' }).as('importPreviewUpload')
94+
cy.get('.modal__content button').contains('Preview').click()
95+
cy.wait('@importPreviewUpload')
96+
cy.get('.file_import__preview tbody tr', { timeout: 20000 }).should('have.length', 4)
97+
98+
cy.intercept({ method: 'POST', url: '**/apps/tables/v2/importupload/table/*' }).as('importUploadReq')
99+
cy.get('.modal__content button').contains('Import').click()
100+
cy.wait('@importUploadReq').its('response.statusCode').should('equal', 200)
101+
})
102+
68103
it('Import csv from device with updating of existent files', () => {
69104
cy.intercept({ method: 'GET', url: '**/apps/tables/row/table/*' }).as('rowsReq')
70105

@@ -89,7 +124,7 @@ describe('Import csv', () => {
89124
cy.wait('@importPreviewUpdate')
90125
cy.get('.file_import__preview tbody tr', { timeout: 20000 }).should('have.length', 3)
91126

92-
cy.intercept({ method: 'POST', url: '**/apps/tables/importupload/table/*' }).as('importUploadReq')
127+
cy.intercept({ method: 'POST', url: '**/apps/tables/v2/importupload/table/*' }).as('importUploadReq')
93128
cy.get('.modal__content button').contains('Import').click()
94129
cy.wait('@importUploadReq')
95130
cy.get('[data-cy="importResultColumnsFound"]', { timeout: 20000 }).should('contain.text', '2')
@@ -104,10 +139,9 @@ describe('Import csv', () => {
104139
})
105140

106141
describe('Import csv from Files file action', () => {
107-
const rowActionsButton = '[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button'
108142
const importToTablesAction = '[data-cy-files-list-row-action="import-to-tables"]'
109-
110-
const openImportToTablesAction = (retries = 8) => {
143+
const openImportToTablesAction = (file, retries = 8) => {
144+
const rowActionsButton = `[data-cy-files-list-row-name="${file}"] [data-cy-files-list-row-actions] .action-item button`
111145
cy.get(rowActionsButton).click()
112146
cy.get('body').then($body => {
113147
if ($body.find(importToTablesAction).length > 0) {
@@ -116,35 +150,37 @@ describe('Import csv from Files file action', () => {
116150
}
117151

118152
if (retries <= 0) {
119-
throw new Error('Import to Tables action did not become available in file actions menu')
153+
throw new Error(`Import to Tables action did not become available in file actions menu for file: ${file}`)
120154
}
121155

122156
cy.get('body').click(0, 0)
123157
cy.wait(1000)
124-
openImportToTablesAction(retries - 1)
158+
openImportToTablesAction(file, retries - 1)
125159
})
126160
}
127161

128162
before(function() {
129163
cy.createRandomUser().then(user => {
130164
localUser = user
131165
cy.login(localUser)
132-
cy.uploadFile('test-import.csv', 'text/csv')
166+
cy.uploadFile('test-import-small.csv', 'text/csv')
167+
cy.uploadFile('test-import-large.csv', 'text/csv')
133168
})
134169
})
135170

136171
beforeEach(function() {
137172
cy.login(localUser)
138173
cy.visit('apps/files/files', { timeout: 120000 })
139-
cy.get('[data-cy-files-list-row-name="test-import.csv"]', { timeout: 120000 }).should('be.visible')
174+
cy.get('[data-cy-files-list-row-name="test-import-small.csv"]', { timeout: 120000 }).should('be.visible')
175+
cy.get('[data-cy-files-list-row-name="test-import-large.csv"]', { timeout: 120000 }).should('be.visible')
140176
})
141177

142-
it('Import to new table', () => {
143-
openImportToTablesAction()
178+
it('Import small file to new table', () => {
179+
openImportToTablesAction('test-import-small.csv')
144180

145181
cy.intercept({
146182
method: 'POST',
147-
url: '**/apps/tables/import/table/*',
183+
url: '**/apps/tables/v2/import/table/*',
148184
}).as('importNewTableReq')
149185
cy.get('[data-cy="fileActionImportButton"]').click({ force: true })
150186
cy.wait('@importNewTableReq').its('response.statusCode').should('equal', 200)
@@ -157,16 +193,27 @@ describe('Import csv from Files file action', () => {
157193
cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0')
158194
})
159195

160-
it('Import to existing table', () => {
161-
openImportToTablesAction()
196+
it('Import large file to new table', () => {
197+
openImportToTablesAction('test-import-large.csv')
198+
199+
cy.intercept({
200+
method: 'POST',
201+
url: '**/apps/tables/v2/import/table/*',
202+
}).as('importNewTableReq')
203+
cy.get('[data-cy="fileActionImportButton"]').click({ force: true })
204+
cy.wait('@importNewTableReq').its('response.statusCode').should('equal', 200)
205+
})
206+
207+
it('Import small file to existing table', () => {
208+
openImportToTablesAction('test-import-small.csv')
162209

163210
cy.get('.modal__content [data-cy="importAsNewTableSwitch"] input').uncheck({ force: true })
164211
cy.get('[data-cy="selectExistingTableDropdown"]').type('Welcome to Nextcloud Tables!')
165212
cy.get('.name-parts').click()
166213

167214
cy.intercept({
168215
method: 'POST',
169-
url: '**/apps/tables/import/table/*',
216+
url: '**/apps/tables/v2/import/table/*',
170217
}).as('importExistingTableReq')
171218
cy.get('[data-cy="fileActionImportButton"]').click({ force: true })
172219
cy.wait('@importExistingTableReq').its('response.statusCode').should('equal', 200)

cypress/e2e/tables-table.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Manage a table', () => {
3737
})
3838

3939
it('Create with import', () => {
40-
cy.uploadFile('test-import.csv', 'text/csv')
40+
cy.uploadFile('test-import-small.csv', 'text/csv')
4141
cy.get('.icon-loading').should('not.exist')
4242
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
4343
// should type before selecting the table type tile
@@ -47,11 +47,11 @@ describe('Manage a table', () => {
4747
cy.contains('h2', 'Import').should('be.visible')
4848

4949
cy.get('.modal__content button').contains('Select from Files').click()
50-
cy.get('.file-picker__files').contains('test-import').click()
50+
cy.get('.file-picker__files').contains('test-import-small').click()
5151
cy.get('.file-picker button span').contains('Import').click()
5252
cy.get('.modal__content button').contains('Preview').click()
5353
cy.get('.file_import__preview tbody tr').should('have.length', 4)
54-
cy.intercept({ method: 'POST', url: '**/apps/tables/import/table/*' }).as('importUploadReq')
54+
cy.intercept({ method: 'POST', url: '**/apps/tables/v2/import/table/*' }).as('importUploadReq')
5555
cy.get('.modal__content button').contains('Import').scrollIntoView().click()
5656
cy.wait('@importUploadReq')
5757
cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4')

0 commit comments

Comments
 (0)