|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | import type { User } from '@nextcloud/cypress' |
7 | | -import { calculateViewportHeight, getRowForFile, haveValidity, renameFile, triggerActionForFile } from './FilesUtils' |
| 7 | +import { calculateViewportHeight, createFolder, getRowForFile, haveValidity, renameFile, triggerActionForFile } from './FilesUtils' |
8 | 8 |
|
9 | 9 | describe('files: Rename nodes', { testIsolation: true }, () => { |
10 | 10 | let user: User |
@@ -193,4 +193,67 @@ describe('files: Rename nodes', { testIsolation: true }, () => { |
193 | 193 | .findByRole('textbox', { name: 'Filename' }) |
194 | 194 | .should('not.exist') |
195 | 195 | }) |
| 196 | + |
| 197 | + it('shows warning on extension change', () => { |
| 198 | + getRowForFile('file.txt').should('be.visible') |
| 199 | + |
| 200 | + triggerActionForFile('file.txt', 'rename') |
| 201 | + getRowForFile('file.txt') |
| 202 | + .findByRole('textbox', { name: 'Filename' }) |
| 203 | + .should('be.visible') |
| 204 | + .type('{selectAll}file.md') |
| 205 | + .should(haveValidity('')) |
| 206 | + .type('{enter}') |
| 207 | + |
| 208 | + // See warning dialog |
| 209 | + cy.findByRole('dialog', { name: 'Change file extension' }) |
| 210 | + .should('be.visible') |
| 211 | + .findByRole('button', { name: /use/i }) |
| 212 | + .click() |
| 213 | + |
| 214 | + // See it is renamed |
| 215 | + getRowForFile('file.md').should('be.visible') |
| 216 | + }) |
| 217 | + |
| 218 | + it('shows warning on extension change and allow cancellation', () => { |
| 219 | + getRowForFile('file.txt').should('be.visible') |
| 220 | + |
| 221 | + triggerActionForFile('file.txt', 'rename') |
| 222 | + getRowForFile('file.txt') |
| 223 | + .findByRole('textbox', { name: 'Filename' }) |
| 224 | + .should('be.visible') |
| 225 | + .type('{selectAll}file.md') |
| 226 | + .should(haveValidity('')) |
| 227 | + .type('{enter}') |
| 228 | + |
| 229 | + // See warning dialog |
| 230 | + cy.findByRole('dialog', { name: 'Change file extension' }) |
| 231 | + .should('be.visible') |
| 232 | + .findByRole('button', { name: /keep/i }) |
| 233 | + .click() |
| 234 | + |
| 235 | + // See it is not renamed |
| 236 | + getRowForFile('file.txt').should('be.visible') |
| 237 | + getRowForFile('file.md').should('not.exist') |
| 238 | + }) |
| 239 | + |
| 240 | + it('does not show warning on folder renaming with a dot', () => { |
| 241 | + createFolder('folder.2024') |
| 242 | + |
| 243 | + getRowForFile('folder.2024').should('be.visible') |
| 244 | + |
| 245 | + triggerActionForFile('folder.2024', 'rename') |
| 246 | + getRowForFile('folder.2024') |
| 247 | + .findByRole('textbox', { name: 'Folder name' }) |
| 248 | + .should('be.visible') |
| 249 | + .type('{selectAll}folder.2025') |
| 250 | + .should(haveValidity('')) |
| 251 | + .type('{enter}') |
| 252 | + |
| 253 | + // See warning dialog |
| 254 | + cy.get('[role=dialog]').should('not.exist') |
| 255 | + |
| 256 | + // See it is not renamed |
| 257 | + getRowForFile('folder.2025').should('be.visible') |
| 258 | + }) |
196 | 259 | }) |
0 commit comments