|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import type { User } from '@nextcloud/cypress' |
7 | | -import { getRowForFile, haveValidity, renameFile, triggerActionForFile } from './FilesUtils' |
| 7 | +import { calculateViewportHeight, getRowForFile, haveValidity, renameFile, triggerActionForFile } from './FilesUtils' |
8 | 8 |
|
9 | 9 | describe('files: Rename nodes', { testIsolation: true }, () => { |
10 | 10 | let user: User |
11 | 11 |
|
12 | 12 | beforeEach(() => cy.createRandomUser().then(($user) => { |
13 | 13 | user = $user |
14 | 14 |
|
| 15 | + // remove welcome file |
| 16 | + cy.rm(user, '/welcome.txt') |
| 17 | + // create a file called "file.txt" |
15 | 18 | cy.uploadContent(user, new Blob([]), 'text/plain', '/file.txt') |
| 19 | + |
| 20 | + // login and visit files app |
16 | 21 | cy.login(user) |
17 | 22 | cy.visit('/apps/files') |
18 | 23 | })) |
@@ -116,34 +121,6 @@ describe('files: Rename nodes', { testIsolation: true }, () => { |
116 | 121 | .should('not.exist') |
117 | 122 | }) |
118 | 123 |
|
119 | | - /** |
120 | | - * This is a regression test of: https://github.com/nextcloud/server/issues/47438 |
121 | | - * The issue was that the renaming state was not reset when the new name moved the file out of the view of the current files list |
122 | | - * due to virtual scrolling the renaming state was not changed then by the UI events (as the component was taken out of DOM before any event handling). |
123 | | - */ |
124 | | - it('correctly resets renaming state', () => { |
125 | | - for (let i = 1; i <= 20; i++) { |
126 | | - cy.uploadContent(user, new Blob([]), 'text/plain', `/file${i}.txt`) |
127 | | - } |
128 | | - cy.viewport(1200, 500) // 500px is smaller then 20 * 50 which is the place that the files take up |
129 | | - cy.login(user) |
130 | | - cy.visit('/apps/files') |
131 | | - |
132 | | - getRowForFile('file.txt').should('be.visible') |
133 | | - // Z so it is shown last |
134 | | - renameFile('file.txt', 'zzz.txt') |
135 | | - // not visible any longer |
136 | | - getRowForFile('zzz.txt').should('not.be.visible') |
137 | | - // scroll file list to bottom |
138 | | - cy.get('[data-cy-files-list]').scrollTo('bottom') |
139 | | - cy.screenshot() |
140 | | - // The file is no longer in rename state |
141 | | - getRowForFile('zzz.txt') |
142 | | - .should('be.visible') |
143 | | - .findByRole('textbox', { name: 'Filename' }) |
144 | | - .should('not.exist') |
145 | | - }) |
146 | | - |
147 | 124 | it('cancel renaming on esc press', () => { |
148 | 125 | // All are visible by default |
149 | 126 | getRowForFile('file.txt').should('be.visible') |
@@ -182,4 +159,38 @@ describe('files: Rename nodes', { testIsolation: true }, () => { |
182 | 159 | .find('input[type="text"]') |
183 | 160 | .should('not.exist') |
184 | 161 | }) |
| 162 | + |
| 163 | + /** |
| 164 | + * This is a regression test of: https://github.com/nextcloud/server/issues/47438 |
| 165 | + * The issue was that the renaming state was not reset when the new name moved the file out of the view of the current files list |
| 166 | + * due to virtual scrolling the renaming state was not changed then by the UI events (as the component was taken out of DOM before any event handling). |
| 167 | + */ |
| 168 | + it('correctly resets renaming state', () => { |
| 169 | + // Create 19 additional files |
| 170 | + for (let i = 1; i <= 19; i++) { |
| 171 | + cy.uploadContent(user, new Blob([]), 'text/plain', `/file${i}.txt`) |
| 172 | + } |
| 173 | + |
| 174 | + // Calculate and setup a viewport where only the first 4 files are visible, causing 6 rows to be rendered |
| 175 | + cy.viewport(768, 500) |
| 176 | + cy.login(user) |
| 177 | + calculateViewportHeight(4) |
| 178 | + .then((height) => cy.viewport(768, height)) |
| 179 | + |
| 180 | + cy.visit('/apps/files') |
| 181 | + |
| 182 | + getRowForFile('file.txt').should('be.visible') |
| 183 | + // Z so it is shown last |
| 184 | + renameFile('file.txt', 'zzz.txt') |
| 185 | + // not visible any longer |
| 186 | + getRowForFile('zzz.txt').should('not.exist') |
| 187 | + // scroll file list to bottom |
| 188 | + cy.get('[data-cy-files-list]').scrollTo('bottom') |
| 189 | + cy.screenshot() |
| 190 | + // The file is no longer in rename state |
| 191 | + getRowForFile('zzz.txt') |
| 192 | + .should('be.visible') |
| 193 | + .findByRole('textbox', { name: 'Filename' }) |
| 194 | + .should('not.exist') |
| 195 | + }) |
185 | 196 | }) |
0 commit comments