1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Project 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('user', 'Active', 'User', false, true)
20 .as('activeUser').then(function() {
21 activeUser = this.activeUser;
26 beforeEach(function() {
28 cy.clearLocalStorage();
31 it('creates a new project with multiple properties', function() {
32 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
33 cy.loginAs(activeUser);
34 cy.get('[data-cy=side-panel-button]').click();
35 cy.get('[data-cy=side-panel-new-project]').click();
36 cy.get('[data-cy=form-dialog]')
37 .should('contain', 'New Project')
39 cy.get('[data-cy=name-field]').within(() => {
40 cy.get('input').type(projName);
44 // Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
45 cy.get('[data-cy=form-dialog]').should('not.contain', 'Color: Magenta');
46 cy.get('[data-cy=resource-properties-form]').within(() => {
47 cy.get('[data-cy=property-field-key]').within(() => {
48 cy.get('input').type('Color');
50 cy.get('[data-cy=property-field-value]').within(() => {
51 cy.get('input').type('Magenta');
54 cy.get('[data-cy=property-field-value]').within(() => {
55 cy.get('input').type('Pink');
58 cy.get('[data-cy=property-field-value]').within(() => {
59 cy.get('input').type('Yellow');
63 // Confirm proper vocabulary labels are displayed on the UI.
64 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Magenta');
65 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Pink');
66 cy.get('[data-cy=form-dialog]').should('contain', 'Color: Yellow');
68 cy.get('[data-cy=resource-properties-form]').within(() => {
69 cy.get('[data-cy=property-field-key]').within(() => {
70 cy.get('input').focus();
72 cy.get('[data-cy=property-field-key]').should('not.contain', 'Color');
75 // Create project and confirm the properties' real values.
76 cy.get('[data-cy=form-submit-btn]').click();
77 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
78 cy.doRequest('GET', '/arvados/v1/groups', null, {
79 filters: `[["name", "=", "${projName}"], ["group_class", "=", "project"]]`,
81 .its('body.items').as('projects')
83 expect(this.projects).to.have.lengthOf(1);
84 expect(this.projects[0].properties).to.deep.equal(
85 // Pink is not in the test vocab
86 {IDTAGCOLORS: ['IDVALCOLORS3', 'Pink', 'IDVALCOLORS1']});
90 it('creates new project on home project and then a subproject inside it', function() {
91 const createProject = function(name, parentName) {
92 cy.get('[data-cy=side-panel-button]').click();
93 cy.get('[data-cy=side-panel-new-project]').click();
94 cy.get('[data-cy=form-dialog]')
95 .should('contain', 'New Project')
97 cy.get('[data-cy=parent-field]').within(() => {
98 cy.get('input').invoke('val').then((val) => {
99 expect(val).to.include(parentName);
102 cy.get('[data-cy=name-field]').within(() => {
103 cy.get('input').type(name);
106 cy.get('[data-cy=form-submit-btn]').click();
109 cy.loginAs(activeUser);
110 cy.goToPath(`/projects/${activeUser.user.uuid}`);
111 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
112 cy.get('[data-cy=breadcrumb-last]').should('not.exist');
113 // Create new project
114 const projName = `Test project (${Math.floor(999999 * Math.random())})`;
115 createProject(projName, 'Home project');
116 // Confirm that the user was taken to the newly created thing
117 cy.get('[data-cy=form-dialog]').should('not.exist');
118 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
119 cy.get('[data-cy=breadcrumb-last]').should('contain', projName);
120 // Create a subproject
121 const subProjName = `Test project (${Math.floor(999999 * Math.random())})`;
122 createProject(subProjName, projName);
123 cy.get('[data-cy=form-dialog]').should('not.exist');
124 cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
125 cy.get('[data-cy=breadcrumb-last]').should('contain', subProjName);
128 it('navigates to the parent project after trashing the one being displayed', function() {
129 cy.createGroup(activeUser.token, {
130 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
131 group_class: 'project',
132 }).as('testRootProject').then(function() {
133 cy.createGroup(activeUser.token, {
134 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
135 group_class: 'project',
136 owner_uuid: this.testRootProject.uuid,
137 }).as('testSubProject');
139 cy.getAll('@testRootProject', '@testSubProject').then(function([testRootProject, testSubProject]) {
140 cy.loginAs(activeUser);
142 // Go to subproject and trash it.
143 cy.goToPath(`/projects/${testSubProject.uuid}`);
144 cy.get('[data-cy=side-panel-tree]').should('contain', testSubProject.name);
145 cy.get('[data-cy=breadcrumb-last]')
146 .should('contain', testSubProject.name)
148 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
150 // Confirm that the parent project should be displayed.
151 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
152 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
153 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
155 // Checks for bugfix #17637.
156 cy.get('[data-cy=not-found-content]').should('not.exist');
157 cy.get('[data-cy=not-found-page]').should('not.exist');
161 it('navigates to the root project after trashing the parent of the one being displayed', function() {
162 cy.createGroup(activeUser.token, {
163 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
164 group_class: 'project',
165 }).as('testRootProject').then(function() {
166 cy.createGroup(activeUser.token, {
167 name : `Test subproject ${Math.floor(Math.random() * 999999)}`,
168 group_class: 'project',
169 owner_uuid: this.testRootProject.uuid,
170 }).as('testSubProject').then(function() {
171 cy.createGroup(activeUser.token, {
172 name : `Test sub subproject ${Math.floor(Math.random() * 999999)}`,
173 group_class: 'project',
174 owner_uuid: this.testSubProject.uuid,
175 }).as('testSubSubProject');
178 cy.getAll('@testRootProject', '@testSubProject', '@testSubSubProject').then(function([testRootProject, testSubProject, testSubSubProject]) {
179 cy.loginAs(activeUser);
181 // Go to innermost project and trash its parent.
182 cy.goToPath(`/projects/${testSubSubProject.uuid}`);
183 cy.get('[data-cy=side-panel-tree]').should('contain', testSubSubProject.name);
184 cy.get('[data-cy=breadcrumb-last]').should('contain', testSubSubProject.name);
185 cy.get('[data-cy=side-panel-tree]')
186 .contains(testSubProject.name)
188 cy.get('[data-cy=context-menu]').contains('Move to trash').click();
190 // Confirm that the trashed project's parent should be displayed.
191 cy.get('[data-cy=breadcrumb-last]').should('contain', testRootProject.name);
192 cy.url().should('contain', `/projects/${testRootProject.uuid}`);
193 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubProject.name);
194 cy.get('[data-cy=side-panel-tree]').should('not.contain', testSubSubProject.name);
196 // Checks for bugfix #17637.
197 cy.get('[data-cy=not-found-content]').should('not.exist');
198 cy.get('[data-cy=not-found-page]').should('not.exist');
202 it('shows details panel when clicking on the info icon', () => {
203 cy.createGroup(activeUser.token, {
204 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
205 group_class: 'project',
206 }).as('testRootProject').then(function(testRootProject) {
207 cy.loginAs(activeUser);
209 cy.get('[data-cy=side-panel-tree]').contains(testRootProject.name).click();
211 cy.get('[data-cy=additional-info-icon]').click();
213 cy.contains(testRootProject.uuid).should('exist');
217 it('clears search input when changing project', () => {
218 cy.createGroup(activeUser.token, {
219 name: `Test root project ${Math.floor(Math.random() * 999999)}`,
220 group_class: 'project',
221 }).as('testProject1').then((testProject1) => {
222 cy.shareWith(adminUser.token, activeUser.user.uuid, testProject1.uuid, 'can_write');
225 cy.getAll('@testProject1').then(function([testProject1]) {
226 cy.loginAs(activeUser);
228 cy.get('[data-cy=side-panel-tree]').contains(testProject1.name).click();
230 cy.get('[data-cy=search-input] input').type('test123');
232 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
234 cy.get('[data-cy=search-input] input').should('not.have.value', 'test123');
238 it('opens advanced popup for project with username', () => {
239 const projectName = `Test project ${Math.floor(Math.random() * 999999)}`;
241 cy.createGroup(adminUser.token, {
243 group_class: 'project',
246 cy.getAll('@mainProject')
247 .then(function ([mainProject]) {
248 cy.loginAs(adminUser);
250 cy.get('[data-cy=side-panel-tree]').contains('Groups').click();
252 cy.get('[data-cy=uuid]').eq(0).invoke('text').then(uuid => {
253 cy.createLink(adminUser.token, {
255 link_class: 'permission',
256 head_uuid: mainProject.uuid,
260 cy.createLink(adminUser.token, {
262 link_class: 'permission',
263 head_uuid: mainProject.uuid,
264 tail_uuid: activeUser.user.uuid
267 cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
269 cy.get('main').contains(projectName).rightclick();
271 cy.get('[data-cy=context-menu]').contains('Advanced').click();
273 cy.get('[role=tablist]').contains('METADATA').click();
275 cy.get('td').contains(uuid).should('exist');
277 cy.get('td').contains(activeUser.user.uuid).should('exist');
282 describe('Frozen projects', () => {
284 cy.createGroup(activeUser.token, {
285 name: `Main project ${Math.floor(Math.random() * 999999)}`,
286 group_class: 'project',
287 }).as('mainProject');
289 cy.createGroup(adminUser.token, {
290 name: `Admin project ${Math.floor(Math.random() * 999999)}`,
291 group_class: 'project',
292 }).as('adminProject').then((mainProject) => {
293 cy.shareWith(adminUser.token, activeUser.user.uuid, mainProject.uuid, 'can_write');
296 cy.get('@mainProject').then((mainProject) => {
297 cy.createGroup(adminUser.token, {
298 name : `Sub project ${Math.floor(Math.random() * 999999)}`,
299 group_class: 'project',
300 owner_uuid: mainProject.uuid,
303 cy.createCollection(adminUser.token, {
304 name: `Main collection ${Math.floor(Math.random() * 999999)}`,
305 owner_uuid: mainProject.uuid,
306 manifest_text: "./subdir 37b51d194a7513e45b56f6524f2d51f2+3 0:3:foo\n. 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
307 }).as('mainCollection');
311 it('should be able to froze own project', () => {
312 cy.getAll('@mainProject').then(([mainProject]) => {
313 cy.loginAs(activeUser);
315 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
317 cy.get('[data-cy=context-menu]').contains('Freeze').click();
319 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
321 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
325 it('should not be able to modify items within the frozen project', () => {
326 cy.getAll('@mainProject', '@mainCollection').then(([mainProject, mainCollection]) => {
327 cy.loginAs(activeUser);
329 cy.get('[data-cy=project-panel]').contains(mainProject.name).rightclick();
331 cy.get('[data-cy=context-menu]').contains('Freeze').click();
333 cy.get('[data-cy=project-panel]').contains(mainProject.name).click();
335 cy.get('[data-cy=project-panel]').contains(mainCollection.name).rightclick();
337 cy.get('[data-cy=context-menu]').contains('Move to trash').should('not.exist');
341 it('should be able to froze not owned project', () => {
342 cy.getAll('@adminProject').then(([adminProject]) => {
343 cy.loginAs(activeUser);
345 cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
347 cy.get('main').contains(adminProject.name).rightclick();
349 cy.get('[data-cy=context-menu]').contains('Freeze').should('not.exist');
353 it('should be able to unfroze project if user is an admin', () => {
354 cy.getAll('@adminProject').then(([adminProject]) => {
355 cy.loginAs(adminUser);
357 cy.get('main').contains(adminProject.name).rightclick();
359 cy.get('[data-cy=context-menu]').contains('Freeze').click();
363 cy.get('main').contains(adminProject.name).rightclick();
365 cy.get('[data-cy=context-menu]').contains('Unfreeze').click();
367 cy.get('main').contains(adminProject.name).rightclick();
369 cy.get('[data-cy=context-menu]').contains('Freeze').should('exist');