1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Favorites tests', function () {
10 // Only set up common users once. These aren't set up as aliases because
11 // aliases are cleaned up after every test. Also it doesn't make sense
12 // to set the same users on beforeEach() over and over again, so we
13 // separate a little from Cypress' 'Best Practices' here.
14 cy.getUser('admin', 'Admin', 'User', true, true)
15 .as('adminUser').then(function () {
16 adminUser = this.adminUser;
19 cy.getUser('collectionuser1', 'Collection', 'User', false, true)
20 .as('activeUser').then(function () {
21 activeUser = this.activeUser;
26 beforeEach(function () {
28 cy.clearLocalStorage()
31 it('creates and removes a public favorite', function () {
32 cy.loginAs(adminUser);
33 cy.createGroup(adminUser.token, {
34 name: `my-favorite-project`,
35 group_class: 'project',
36 }).as('myFavoriteProject').then(function () {
37 cy.contains('Refresh').click();
38 cy.get('main').contains('my-favorite-project').rightclick();
39 cy.contains('Add to public favorites').click();
40 cy.contains('Public Favorites').click();
41 cy.get('main').contains('my-favorite-project').rightclick();
42 cy.contains('Remove from public favorites').click();
43 cy.get('main').contains('my-favorite-project').should('not.exist');
44 cy.trashGroup(adminUser.token, this.myFavoriteProject.uuid);
48 it('can copy selected into the collection', () => {
49 cy.loginAs(adminUser);
51 cy.createCollection(adminUser.token, {
52 name: `Test source collection ${Math.floor(Math.random() * 999999)}`,
53 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
55 .as('testSourceCollection').then(function (testSourceCollection) {
56 cy.shareWith(adminUser.token, activeUser.user.uuid, testSourceCollection.uuid, 'can_read');
59 cy.createCollection(adminUser.token, {
60 name: `Test target collection ${Math.floor(Math.random() * 999999)}`,
62 .as('testTargetCollection').then(function (testTargetCollection) {
63 cy.shareWith(adminUser.token, activeUser.user.uuid, testTargetCollection.uuid, 'can_write');
66 cy.getAll('@testSourceCollection', '@testTargetCollection')
67 .then(function ([testSourceCollection, testTargetCollection]) {
68 cy.loginAs(activeUser);
70 cy.get('.layout-pane-primary')
71 .contains('Projects').click();
73 cy.addToFavorites(activeUser.token, activeUser.user.uuid, testTargetCollection.uuid);
75 cy.get('main').contains(testSourceCollection.name).click();
76 cy.get('[data-cy=collection-files-panel]').contains('bar');
77 cy.get('[data-cy=collection-files-panel]').find('input[type=checkbox]').click({ force: true });
78 cy.get('[data-cy=collection-files-panel-options-btn]').click();
79 cy.get('[data-cy=context-menu]')
80 .contains('Copy selected into the collection').click();
82 cy.get('[data-cy=projects-tree-favourites-tree-picker]')
86 cy.get('[data-cy=projects-tree-favourites-tree-picker]')
87 .contains(testTargetCollection.name)
90 cy.get('[data-cy=form-submit-btn]').click();
92 cy.get('.layout-pane-primary')
93 .contains('Projects').click();
95 cy.get('main').contains(testTargetCollection.name).click();
97 cy.get('[data-cy=collection-files-panel]').contains('bar');
101 it('can copy collection to favorites', () => {
102 cy.loginAs(adminUser);
104 cy.createSharedProjects(adminUser, activeUser);
106 cy.createCollection(adminUser.token, {
107 name: `Test collection ${Math.floor(Math.random() * 999999)}`,
108 owner_uuid: activeUser.user.uuid,
109 manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
111 .as('testCollection');
113 cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject', '@myProject1', '@testCollection')
114 .then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1, testCollection]) {
115 cy.loginAs(activeUser);
117 cy.doSearch(`${activeUser.user.uuid}`);
119 cy.contains(testCollection.name).rightclick();
120 cy.get('[data-cy=context-menu]').within(() => {
121 cy.contains('Move to').click();
124 cy.get('[data-cy=form-dialog]').within(function () {
125 cy.get('[data-cy=projects-tree-favourites-tree-picker]').find('i').click();
126 cy.contains(myProject1.name);
127 cy.contains(mySharedWritableProject.name);
128 cy.get('[data-cy=projects-tree-favourites-tree-picker]')
129 .should('not.contain', mySharedReadonlyProject.name);
130 cy.contains(mySharedWritableProject.name).click();
131 cy.get('[data-cy=form-submit-btn]').click();
134 cy.doSearch(`${mySharedWritableProject.uuid}`);
135 cy.get('main').contains(testCollection.name);
139 it('can view favourites in workflow', () => {
140 cy.loginAs(adminUser);
142 cy.createSharedProjects(adminUser, activeUser);
144 cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject', '@myProject1')
145 .then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1]) {
146 cy.loginAs(activeUser);
148 cy.createWorkflow(adminUser.token, {
149 name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
150 definition: "{\n \"$graph\": [\n {\n \"class\": \"Workflow\",\n \"doc\": \"Reverse the lines in a document, then sort those lines.\",\n \"hints\": [\n {\n \"acrContainerImage\": \"99b0201f4cade456b4c9d343769a3b70+261\",\n \"class\": \"http://arvados.org/cwl#WorkflowRunnerResources\"\n }\n ],\n \"id\": \"#main\",\n \"inputs\": [\n {\n \"default\": null,\n \"doc\": \"The input file to be processed.\",\n \"id\": \"#main/input\",\n \"type\": \"File\"\n },\n {\n \"default\": true,\n \"doc\": \"If true, reverse (decending) sort\",\n \"id\": \"#main/reverse_sort\",\n \"type\": \"boolean\"\n }\n ],\n \"outputs\": [\n {\n \"doc\": \"The output with the lines reversed and sorted.\",\n \"id\": \"#main/output\",\n \"outputSource\": \"#main/sorted/output\",\n \"type\": \"File\"\n }\n ],\n \"steps\": [\n {\n \"id\": \"#main/rev\",\n \"in\": [\n {\n \"id\": \"#main/rev/input\",\n \"source\": \"#main/input\"\n }\n ],\n \"out\": [\n \"#main/rev/output\"\n ],\n \"run\": \"#revtool.cwl\"\n },\n {\n \"id\": \"#main/sorted\",\n \"in\": [\n {\n \"id\": \"#main/sorted/input\",\n \"source\": \"#main/rev/output\"\n },\n {\n \"id\": \"#main/sorted/reverse\",\n \"source\": \"#main/reverse_sort\"\n }\n ],\n \"out\": [\n \"#main/sorted/output\"\n ],\n \"run\": \"#sorttool.cwl\"\n }\n ]\n },\n {\n \"baseCommand\": \"rev\",\n \"class\": \"CommandLineTool\",\n \"doc\": \"Reverse each line using the `rev` command\",\n \"hints\": [\n {\n \"class\": \"ResourceRequirement\",\n \"ramMin\": 8\n }\n ],\n \"id\": \"#revtool.cwl\",\n \"inputs\": [\n {\n \"id\": \"#revtool.cwl/input\",\n \"inputBinding\": {},\n \"type\": \"File\"\n }\n ],\n \"outputs\": [\n {\n \"id\": \"#revtool.cwl/output\",\n \"outputBinding\": {\n \"glob\": \"output.txt\"\n },\n \"type\": \"File\"\n }\n ],\n \"stdout\": \"output.txt\"\n },\n {\n \"baseCommand\": \"sort\",\n \"class\": \"CommandLineTool\",\n \"doc\": \"Sort lines using the `sort` command\",\n \"hints\": [\n {\n \"class\": \"ResourceRequirement\",\n \"ramMin\": 8\n }\n ],\n \"id\": \"#sorttool.cwl\",\n \"inputs\": [\n {\n \"id\": \"#sorttool.cwl/reverse\",\n \"inputBinding\": {\n \"position\": 1,\n \"prefix\": \"-r\"\n },\n \"type\": \"boolean\"\n },\n {\n \"id\": \"#sorttool.cwl/input\",\n \"inputBinding\": {\n \"position\": 2\n },\n \"type\": \"File\"\n }\n ],\n \"outputs\": [\n {\n \"id\": \"#sorttool.cwl/output\",\n \"outputBinding\": {\n \"glob\": \"output.txt\"\n },\n \"type\": \"File\"\n }\n ],\n \"stdout\": \"output.txt\"\n }\n ],\n \"cwlVersion\": \"v1.0\"\n}",
151 owner_uuid: myProject1.uuid,
155 cy.contains('Shared with me').click();
157 cy.doSearch(`${activeUser.user.uuid}`);
159 cy.get('main').contains(myProject1.name).click();
161 cy.get('[data-cy=side-panel-button]').click();
163 cy.get('#aside-menu-list').contains('Run a process').click();
165 cy.get('@testWorkflow')
166 .then((testWorkflow) => {
167 cy.get('main').contains(testWorkflow.name).click();
168 cy.get('[data-cy=run-process-next-button]').click();
169 cy.get('[readonly]').click();
170 cy.get('[data-cy=choose-a-file-dialog]').as('chooseFileDialog');
171 cy.get('[data-cy=projects-tree-favourites-tree-picker]').contains('Favorites').closest('ul').find('i').click();
172 cy.get('@chooseFileDialog').find(`[data-id=${mySharedWritableProject.uuid}]`);
173 cy.get('@chooseFileDialog').find(`[data-id=${mySharedReadonlyProject.uuid}]`);