Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla@contractors.roche.com>
});
});
- it.only('can copy collection to favorites', () => {
+ it('can copy collection to favorites', () => {
cy.loginAs(adminUser);
cy.createGroup(adminUser.token, {
name: `my-shared-writable-project ${Math.floor(Math.random() * 999999)}`,
group_class: 'project',
- }).as('mySharedProject1').then(function () {
+ }).as('mySharedProject1').then(function (mySharedProject1) {
cy.contains('Refresh').click();
- cy.get('main').contains(this.mySharedProject1.name).rightclick();
+ cy.get('main').contains(mySharedProject1.name).rightclick();
cy.get('[data-cy=context-menu]').within(() => {
cy.contains('Share').click();
});
- cy.wait(1000);
cy.get('[id="select-permissions"]').as('selectPermissions');
cy.get('@selectPermissions').click();
cy.contains('Write').click();
cy.createGroup(adminUser.token, {
name: `my-shared-readonly-project ${Math.floor(Math.random() * 999999)}`,
group_class: 'project',
- }).as('mySharedProject2').then(function () {
+ }).as('mySharedProject2').then(function (mySharedProject2) {
cy.contains('Refresh').click();
- cy.get('main').contains(this.mySharedProject2.name).rightclick();
+ cy.get('main').contains(mySharedProject2.name).rightclick();
cy.get('[data-cy=context-menu]').within(() => {
cy.contains('Share').click();
});
- cy.wait(1000);
cy.get('.sharing-dialog').as('sharingDialog');
cy.get('@sharingDialog').find('input').first().type(activeUser.user.email);
cy.get('[role=tooltip]').click();
group_class: 'project',
}).as('myProject1');
- cy.get('@mySharedProject1').then(function () {
- cy.get('@mySharedProject2').then(function () {
- cy.get('@myProject1').then(function () {
- cy.createCollection(adminUser.token, {
- name: `Test collection ${Math.floor(Math.random() * 999999)}`,
- owner_uuid: activeUser.user.uuid,
- manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
- })
- .as('testCollection').then(function () {
- cy.loginAs(activeUser);
-
- cy.contains('Shared with me').click();
-
- cy.get('main').contains(this.mySharedProject1.name).rightclick();
- cy.get('[data-cy=context-menu]').within(() => {
- cy.contains('Add to favorites').click();
- });
-
- cy.get('main').contains(this.mySharedProject2.name).rightclick();
- cy.get('[data-cy=context-menu]').within(() => {
- cy.contains('Add to favorites').click();
- });
-
- cy.doSearch(`${activeUser.user.uuid}`);
-
- cy.get('main').contains(this.myProject1.name).rightclick();
- cy.get('[data-cy=context-menu]').within(() => {
- cy.contains('Add to favorites').click();
- });
-
- cy.contains(this.testCollection.name).rightclick();
- cy.get('[data-cy=context-menu]').within(() => {
- cy.contains('Move to').click();
- });
-
- cy.get('[data-cy=form-dialog]').within(function() {
- cy.get('ul').last().find('i').click();
- cy.contains(this.myProject1.name);
- cy.contains(this.mySharedProject1.name);
- cy.get('ul').last()
- .should('not.contain', this.mySharedProject2.name);
- });
- });
+ cy.createCollection(adminUser.token, {
+ name: `Test collection ${Math.floor(Math.random() * 999999)}`,
+ owner_uuid: activeUser.user.uuid,
+ manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
+ })
+ .as('testCollection');
+
+ cy.getAll('@mySharedProject1', '@mySharedProject2', '@myProject1', '@testCollection')
+ .then(function ([mySharedProject1, mySharedProject2, myProject1, testCollection]) {
+ cy.loginAs(activeUser);
+
+ cy.contains('Shared with me').click();
+
+ cy.get('main').contains(mySharedProject1.name).rightclick();
+ cy.get('[data-cy=context-menu]').within(() => {
+ cy.contains('Add to favorites').click();
+ });
+
+ cy.get('main').contains(mySharedProject2.name).rightclick();
+ cy.get('[data-cy=context-menu]').within(() => {
+ cy.contains('Add to favorites').click();
+ });
+
+ cy.doSearch(`${activeUser.user.uuid}`);
+
+ cy.get('main').contains(myProject1.name).rightclick();
+ cy.get('[data-cy=context-menu]').within(() => {
+ cy.contains('Add to favorites').click();
+ });
+
+ cy.contains(testCollection.name).rightclick();
+ cy.get('[data-cy=context-menu]').within(() => {
+ cy.contains('Move to').click();
+ });
+
+ cy.get('[data-cy=form-dialog]').within(function () {
+ cy.get('ul').last().find('i').click();
+ cy.contains(myProject1.name);
+ cy.contains(mySharedProject1.name);
+ cy.get('ul').last()
+ .should('not.contain', mySharedProject2.name);
});
});
- });
});
-})
+});
\ No newline at end of file
const systemToken = Cypress.env('system_token');
Cypress.Commands.add(
- "doRequest", (method='GET', path='', data=null, qs=null,
- token=systemToken, auth=false, followRedirect=true) => {
- return cy.request({
- method: method,
- url: `${controllerURL}/${path}`,
- body: data,
- qs: auth ? qs : Object.assign({api_token: token}, qs),
- auth: auth ? {bearer: `${token}`} : undefined,
- followRedirect: followRedirect
- })
- }
+ "doRequest", (method = 'GET', path = '', data = null, qs = null,
+ token = systemToken, auth = false, followRedirect = true) => {
+ return cy.request({
+ method: method,
+ url: `${controllerURL}/${path}`,
+ body: data,
+ qs: auth ? qs : Object.assign({ api_token: token }, qs),
+ auth: auth ? { bearer: `${token}` } : undefined,
+ followRedirect: followRedirect
+ })
+}
)
// This resets the DB removing all content and seeding it with the fixtures.
)
Cypress.Commands.add(
- "getUser", (username, first_name='', last_name='', is_admin=false, is_active=true) => {
+ "getUser", (username, first_name = '', last_name = '', is_admin = false, is_active = true) => {
// Create user if not already created
return cy.doRequest('POST', '/auth/controller/callback', {
auth_info: JSON.stringify({
}),
return_to: ',https://example.local'
}, null, systemToken, true, false) // Don't follow redirects so we can catch the token
- .its('headers.location').as('location')
- // Get its token and set the account up as admin and/or active
- .then(function() {
- this.userToken = this.location.split("=")[1]
- assert.isString(this.userToken)
- return cy.doRequest('GET', '/arvados/v1/users', null, {
- filters: `[["username", "=", "${username}"]]`
- })
- .its('body.items.0')
- .as('aUser')
- .then(function() {
- cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, {
- user: {
- is_admin: is_admin,
- is_active: is_active
- }
- })
- .its('body')
- .as('theUser')
- .then(function() {
- return {user: this.theUser, token: this.userToken};
+ .its('headers.location').as('location')
+ // Get its token and set the account up as admin and/or active
+ .then(function () {
+ this.userToken = this.location.split("=")[1]
+ assert.isString(this.userToken)
+ return cy.doRequest('GET', '/arvados/v1/users', null, {
+ filters: `[["username", "=", "${username}"]]`
})
+ .its('body.items.0')
+ .as('aUser')
+ .then(function () {
+ cy.doRequest('PUT', `/arvados/v1/users/${this.aUser.uuid}`, {
+ user: {
+ is_admin: is_admin,
+ is_active: is_active
+ }
+ })
+ .its('body')
+ .as('theUser')
+ .then(function () {
+ return { user: this.theUser, token: this.userToken };
+ })
+ })
})
- })
}
)
Cypress.Commands.add(
"createResource", (token, suffix, data) => {
- return cy.doRequest('POST', '/arvados/v1/'+suffix, data, null, token, true)
- .its('body').as('resource')
- .then(function() {
- return this.resource;
- })
+ return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true)
+ .its('body').as('resource')
+ .then(function () {
+ return this.resource;
+ })
}
)
Cypress.Commands.add(
"deleteResource", (token, suffix, uuid) => {
- return cy.doRequest('DELETE', '/arvados/v1/'+suffix+'/'+uuid)
- .its('body').as('resource')
- .then(function() {
- return this.resource;
- })
+ return cy.doRequest('DELETE', '/arvados/v1/' + suffix + '/' + uuid)
+ .its('body').as('resource')
+ .then(function () {
+ return this.resource;
+ })
}
)
Cypress.Commands.add(
"updateResource", (token, suffix, uuid, data) => {
- return cy.doRequest('PUT', '/arvados/v1/'+suffix+'/'+uuid, data, null, token, true)
- .its('body').as('resource')
- .then(function() {
- return this.resource;
- })
+ return cy.doRequest('PUT', '/arvados/v1/' + suffix + '/' + uuid, data, null, token, true)
+ .its('body').as('resource')
+ .then(function () {
+ return this.resource;
+ })
}
)
"doSearch", (searchTerm) => {
cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);
}
-)
\ No newline at end of file
+)
+
+Cypress.Commands.add('getAll', (...elements) => {
+ const promise = cy.wrap([], { log: false })
+
+ for (let element of elements) {
+ promise.then(arr => cy.get(element).then(got => cy.wrap([...arr, got])))
+ }
+
+ return promise
+})
\ No newline at end of file
includeFiles?: boolean;
}
-export const loadFavoritesProject = (params: LoadFavoritesProjectParams) =>
+export const loadFavoritesProject = (params: LoadFavoritesProjectParams,
+ options: { showOnlyOwned: boolean, showOnlyWritable: boolean } = { showOnlyOwned: true, showOnlyWritable: false }) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
const { pickerId, includeCollections = false, includeFiles = false } = params;
const uuid = getUserUuid(getState());
fb => fb.getFilters(),
)(new FilterBuilder());
- const { items } = await services.favoriteService.list(uuid, { filters }, false);
+ const { items } = await services.favoriteService.list(uuid, { filters }, options.showOnlyOwned);
dispatch<any>(receiveTreePickerData<GroupContentsResource>({
id: 'Favorites',
pickerId,
data: items.filter((item) => {
- if ((item as GroupResource).writableBy && (item as GroupResource).writableBy.indexOf(uuid) === -1) {
+ if (options.showOnlyWritable && (item as GroupResource).writableBy && (item as GroupResource).writableBy.indexOf(uuid) === -1) {
return false;
}
export const FavoritesTreePicker = connect(() => ({
rootItemIcon: FavoriteIcon,
}), (dispatch: Dispatch): Pick<ProjectsTreePickerProps, 'loadRootItem'> => ({
- loadRootItem: (_, pickerId, includeCollections, includeFiles) => {
- dispatch<any>(loadFavoritesProject({ pickerId, includeCollections, includeFiles }));
+ loadRootItem: (_, pickerId, includeCollections, includeFiles, options) => {
+ dispatch<any>(loadFavoritesProject({ pickerId, includeCollections, includeFiles }, options));
},
}))(ProjectsTreePicker);
\ No newline at end of file
showSelection?: boolean;
relatedTreePickers?: string[];
disableActivation?: string[];
- loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string, includeCollections?: boolean, includeFiles?: boolean) => void;
+ options?: { showOnlyOwned: boolean, showOnlyWritable: boolean };
+ loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string,
+ includeCollections?: boolean, includeFiles?: boolean, options?: { showOnlyOwned: boolean, showOnlyWritable: boolean }) => void;
}
export type ProjectsTreePickerProps = ProjectsTreePickerDataProps & Partial<PickedTreePickerProps>;
showSelection: isSelectionVisible(showSelection),
});
-const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, relatedTreePickers, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
+const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, relatedTreePickers, options, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
onContextMenu: () => { return; },
toggleItemActive: (event, item, pickerId) => {
: loadProject({ id, pickerId, includeCollections, includeFiles })
);
} else if (!('type' in data) && loadRootItem) {
- loadRootItem(item as TreeItem<ProjectsTreePickerRootItem>, pickerId, includeCollections, includeFiles);
+ loadRootItem(item as TreeItem<ProjectsTreePickerRootItem>, pickerId, includeCollections, includeFiles, options);
}
} else if (status === TreeItemStatus.LOADED) {
dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ id, pickerId }));
<HomeTreePicker pickerId={home} {...p} />
<SharedTreePicker pickerId={shared} {...p} />
<PublicFavoritesTreePicker pickerId={publicFavorites} {...p} />
- <FavoritesTreePicker pickerId={favorites} {...p} />
+ <FavoritesTreePicker pickerId={favorites} options={{ showOnlyOwned: false, showOnlyWritable: true }} {...p} />
</div>;
};