['bar', '&'],
['&', 'foo'],
['foo', '&'],
- ['&', 'I ❤️ ⛵️']
+ ['&', 'I ❤️ ⛵️'],
+ ['I ❤️ ⛵️', '...']
];
nameTransitions.forEach(([from, to]) => {
cy.get('[data-cy=collection-files-panel]')
.as('testCollection').then(function() {
cy.loginAs(activeUser);
cy.visit(`/collections/${this.testCollection.uuid}`);
- const illegalNamesFromBackend = ['.', '..'];
- illegalNamesFromBackend.forEach((name) => {
- cy.get('[data-cy=collection-files-panel]')
- .contains('bar').rightclick();
- cy.get('[data-cy=context-menu]')
- .contains('Rename')
- .click();
- cy.get('[data-cy=form-dialog]')
- .should('contain', 'Rename')
- .within(() => {
- cy.get('input').type(`{selectall}{backspace}${name}`);
- });
- cy.get('[data-cy=form-submit-btn]').click();
- cy.get('[data-cy=form-dialog]')
- .should('contain', 'Rename')
- .within(() => {
- cy.contains('Could not rename');
- });
- cy.get('[data-cy=form-cancel-btn]').click();
- });
const illegalNamesFromUI = [
+ ['.', "Name cannot be '.' or '..'"],
+ ['..', "Name cannot be '.' or '..'"],
['', 'This field is required'],
[' ', 'Leading/trailing whitespaces not allowed'],
[' foo', 'Leading/trailing whitespaces not allowed'],
.within(() => {
cy.get('input').type(`{selectall}{backspace}${name}`);
});
- cy.get('[data-cy=form-cancel-btn]').focus();
cy.get('[data-cy=form-dialog]')
.should('contain', 'Rename')
.within(() => {
export const validFilePath = (filePath: string) => {
const errors = filePath.split('/').map(pathPart => {
if (pathPart === "") { return "Empty dir name not allowed"; }
- return validFileName(pathPart);
+ return validNameAllowSlash(pathPart) || validFileName(pathPart);
});
return errors.filter(e => e !== undefined)[0];
};
\ No newline at end of file