|
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 | })) |
@@ -113,34 +118,6 @@ describe('files: Rename nodes', { testIsolation: true }, () => { |
113 | 118 | .should('not.exist') |
114 | 119 | }) |
115 | 120 |
|
116 | | - /** |
117 | | - * This is a regression test of: https://github.com/nextcloud/server/issues/47438 |
118 | | - * 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 |
119 | | - * 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). |
120 | | - */ |
121 | | - it('correctly resets renaming state', () => { |
122 | | - for (let i = 1; i <= 20; i++) { |
123 | | - cy.uploadContent(user, new Blob([]), 'text/plain', `/file${i}.txt`) |
124 | | - } |
125 | | - cy.viewport(1200, 500) // 500px is smaller then 20 * 50 which is the place that the files take up |
126 | | - cy.login(user) |
127 | | - cy.visit('/apps/files') |
128 | | - |
129 | | - getRowForFile('file.txt').should('be.visible') |
130 | | - // Z so it is shown last |
131 | | - renameFile('file.txt', 'zzz.txt') |
132 | | - // not visible any longer |
133 | | - getRowForFile('zzz.txt').should('not.be.visible') |
134 | | - // scroll file list to bottom |
135 | | - cy.get('[data-cy-files-list]').scrollTo('bottom') |
136 | | - cy.screenshot() |
137 | | - // The file is no longer in rename state |
138 | | - getRowForFile('zzz.txt') |
139 | | - .should('be.visible') |
140 | | - .findByRole('textbox', { name: 'Filename' }) |
141 | | - .should('not.exist') |
142 | | - }) |
143 | | - |
144 | 121 | it('cancel renaming on esc press', () => { |
145 | 122 | // All are visible by default |
146 | 123 | getRowForFile('file.txt').should('be.visible') |
@@ -179,4 +156,38 @@ describe('files: Rename nodes', { testIsolation: true }, () => { |
179 | 156 | .find('input[type="text"]') |
180 | 157 | .should('not.exist') |
181 | 158 | }) |
| 159 | + |
| 160 | + /** |
| 161 | + * This is a regression test of: https://github.com/nextcloud/server/issues/47438 |
| 162 | + * 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 |
| 163 | + * 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). |
| 164 | + */ |
| 165 | + it('correctly resets renaming state', () => { |
| 166 | + // Create 19 additional files |
| 167 | + for (let i = 1; i <= 19; i++) { |
| 168 | + cy.uploadContent(user, new Blob([]), 'text/plain', `/file${i}.txt`) |
| 169 | + } |
| 170 | + |
| 171 | + // Calculate and setup a viewport where only the first 4 files are visible, causing 6 rows to be rendered |
| 172 | + cy.viewport(768, 500) |
| 173 | + cy.login(user) |
| 174 | + calculateViewportHeight(4) |
| 175 | + .then((height) => cy.viewport(768, height)) |
| 176 | + |
| 177 | + cy.visit('/apps/files') |
| 178 | + |
| 179 | + getRowForFile('file.txt').should('be.visible') |
| 180 | + // Z so it is shown last |
| 181 | + renameFile('file.txt', 'zzz.txt') |
| 182 | + // not visible any longer |
| 183 | + getRowForFile('zzz.txt').should('not.exist') |
| 184 | + // scroll file list to bottom |
| 185 | + cy.get('[data-cy-files-list]').scrollTo('bottom') |
| 186 | + cy.screenshot() |
| 187 | + // The file is no longer in rename state |
| 188 | + getRowForFile('zzz.txt') |
| 189 | + .should('be.visible') |
| 190 | + .findByRole('textbox', { name: 'Filename' }) |
| 191 | + .should('not.exist') |
| 192 | + }) |
182 | 193 | }) |
0 commit comments