Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
cy.loginAs(activeUser);
cy.doSearch(`${this.testCollection.uuid}`);
- // Rename 'bar' to 'subdir/foo'
- 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}subdir/foo`);
- });
- cy.get('[data-cy=form-submit-btn]').click();
- cy.get('[data-cy=collection-files-panel]')
- .should('not.contain', 'bar')
- .and('contain', 'subdir');
- // Look for the "arrow icon" and expand the "subdir" directory.
- cy.get('[data-cy=virtual-file-tree] > div > i').click();
- // Rename 'subdir/foo' to 'baz'
- cy.get('[data-cy=collection-files-panel]')
- .contains('foo').rightclick();
- cy.get('[data-cy=context-menu]')
- .contains('Rename')
- .click();
- cy.get('[data-cy=form-dialog]')
- .should('contain', 'Rename')
- .within(() => {
- cy.get('input')
- .should('have.value', 'subdir/foo')
- .type(`{selectall}{backspace}baz`);
- });
- cy.get('[data-cy=form-submit-btn]').click();
- cy.get('[data-cy=collection-files-panel]')
- .should('contain', 'subdir') // empty dir kept
- .and('contain', 'baz');
+ ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('bar').rightclick({force: true});
+ 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}${subdir}/foo`);
+ });
+ cy.get('[data-cy=form-submit-btn]').click();
+ cy.get('[data-cy=collection-files-panel]')
+ .should('not.contain', 'bar')
+ .and('contain', subdir);
+ // Look for the "arrow icon" and expand the "subdir" directory.
+ cy.get('[data-cy=virtual-file-tree] > div > i').click();
+ // Rename 'subdir/foo' to 'foo'
+ cy.get('[data-cy=collection-files-panel]')
+ .contains('foo').rightclick();
+ cy.get('[data-cy=context-menu]')
+ .contains('Rename')
+ .click();
+ cy.get('[data-cy=form-dialog]')
+ .should('contain', 'Rename')
+ .within(() => {
+ cy.get('input')
+ .should('have.value', `${subdir}/foo`)
+ .type(`{selectall}{backspace}bar`);
+ });
+ cy.get('[data-cy=form-submit-btn]').click();
+ cy.get('[data-cy=collection-files-panel]')
+ .should('contain', subdir) // empty dir kept
+ .and('contain', 'bar');
+
+ cy.get('[data-cy=collection-files-panel]')
+ .contains(subdir).rightclick();
+ cy.get('[data-cy=context-menu]')
+ .contains('Remove')
+ .click();
+ cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
+ });
});
});
//
// SPDX-License-Identifier: AGPL-3.0
-import { customDecodeURI, customEncodeURI, encodeHash } from './url';
+import { customDecodeURI, customEncodeURI } from './url';
describe('url', () => {
- describe('encodeHash', () => {
- it('should ignore path without hash', () => {
- // given
- const path = 'path/without/hash';
-
- // when
- const result = encodeHash(path);
-
- // then
- expect(result).toEqual(path);
- });
-
- it('should replace all hashes within the path', () => {
- // given
- const path = 'path/with/hash # and one more #';
- const expectedResult = 'path/with/hash %23 and one more %23';
-
- // when
- const result = encodeHash(path);
-
- // then
- expect(result).toEqual(expectedResult);
- });
- });
-
describe('customDecodeURI', () => {
it('should decode encoded URI', () => {
// given
return path;
};
-
-export const encodeHash = (path: string) => {
- return path.replace(/#/g, '%23');
-};
\ No newline at end of file
? this.defaults.baseURL+'/'
: ''}${customEncodeURI(config.url)}`);
- if (config.headers && config.headers.Destination) {
- const regexp = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/;
- const match = decodeURIComponent(config.headers.Destination).match(regexp) || {};
- config.headers.Destination = `${match[1]}${match[2]}${customEncodeURI(match[3])}`;
- }
-
const headers = { ...this.defaults.headers, ...config.headers };
Object
.keys(headers)
it('should correctly decode URLs & file names', () => {
const testCases = [
// input URL, input display name, expected URL, expected name
- ['table%201%202%203', 'table 1 2 3', 'table 1 2 3', 'table 1 2 3'],
- ['table%25&%3F%2A2', 'table%&?*2', 'table%&?*2', 'table%&?*2'],
- ["G%C3%BCnter%27s%20file.pdf", "Günter's file.pdf", "Günter's file.pdf", "Günter's file.pdf"],
- ['G%25C3%25BCnter%27s%2520file.pdf', 'G%C3%BCnter's%20file.pdf', "G%C3%BCnter's%20file.pdf", "G%C3%BCnter's%20file.pdf"]
+ ['table%201%202%203', 'table 1 2 3', 'table%201%202%203', 'table 1 2 3'],
+ ['table%25&%3F%2A2', 'table%&?*2', 'table%25&%3F%2A2', 'table%&?*2'],
+ ["G%C3%BCnter%27s%20file.pdf", "Günter's file.pdf", "G%C3%BCnter%27s%20file.pdf", "Günter's file.pdf"],
+ ['G%25C3%25BCnter%27s%2520file.pdf', 'G%C3%BCnter's%20file.pdf', "G%25C3%25BCnter%27s%2520file.pdf", "G%C3%BCnter's%20file.pdf"]
];
testCases.forEach(([inputURL, inputDisplayName, expectedURL, expectedName]) => {
const result = extractFilesData(xmlDoc);
// then
- expect(result).toEqual([{ id: `${collUUID}/${expectedURL}`, name: expectedName, path: "", size: 3, type: "file", url: `/c=${collUUID}/${expectedURL}` }]);
+ expect(result).toEqual([{ id: `${collUUID}/${expectedName}`, name: expectedName, path: "", size: 3, type: "file", url: `/c=${collUUID}/${expectedURL}` }]);
});
});
});
.map(element => {
const name = getTagValue(element, 'D:displayname', '', true); // skip decoding as value should be already decoded
const size = parseInt(getTagValue(element, 'D:getcontentlength', '0', true), 10);
- const url = getTagValue(element, 'D:href', '');
- const nameSuffix = name;
+ const url = getTagValue(element, 'D:href', '', true);
const collectionUuidMatch = collectionUrlPrefix.exec(url);
const collectionUuid = collectionUuidMatch ? collectionUuidMatch.pop() : '';
- const directory = url
+ const pathArray = url.split(`/`);
+ if (!pathArray.pop()) {
+ pathArray.pop();
+ }
+ const directory = pathArray.join('/')
.replace(collectionUrlPrefix, '')
- .replace(nameSuffix, '')
.replace(/\/\//g, '/');
const parentPath = directory.replace(/\/$/, '');
url,
id: [
collectionUuid ? collectionUuid : '',
- directory ? parentPath : '',
+ directory ? unescape(parentPath) : '',
'/' + name
].join(''),
name,
- path: parentPath,
+ path: unescape(parentPath),
};
const result = getTagValue(element, 'D:resourcetype', '')