})
.as('testCollection').then(function () {
cy.loginAs(activeUser);
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
// Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
cy.get('[data-cy=resource-properties-form]').within(() => {
head_uuid: this.sharedGroup.uuid,
tail_uuid: activeUser.user.uuid
})
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
// Check that name & uuid are correct.
cy.get('[data-cy=collection-info-panel]')
})
.as('testCollection').then(function () {
cy.loginAs(activeUser);
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
const names = [
'bar', // initial name already set
})
.as('testCollection').then(function () {
cy.loginAs(activeUser);
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
cy.get('[data-cy=collection-files-panel]')
})
.as('testCollection').then(function () {
cy.loginAs(activeUser);
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
const illegalNamesFromUI = [
['.', "Name cannot be '.' or '..'"],
});
// Check the old version displays as what it is.
cy.loginAs(activeUser)
- cy.doSearch(`${oldVersionUuid}`);
+ cy.goToPath(`/collections/${oldVersionUuid}`);
cy.get('[data-cy=collection-info-panel]').should('contain', 'This is an old version');
cy.get('[data-cy=read-only-icon]').should('exist');
.as('collection').then(function () {
// Visit collection, check basic information
cy.loginAs(activeUser)
- cy.doSearch(`${this.collection.uuid}`);
+ cy.goToPath(`/collections/${this.collection.uuid}`);
cy.get('[data-cy=collection-info-panel]').should('not.contain', 'This is an old version');
cy.get('[data-cy=read-only-icon]').should('not.exist');
it('creates new collection on home project', function () {
cy.loginAs(activeUser);
- cy.doSearch(`${activeUser.user.uuid}`);
+ cy.goToPath(`/projects/${activeUser.user.uuid}`);
cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
cy.get('[data-cy=breadcrumb-last]').should('not.exist');
// Create new collection
})
.as('testCollection').then(function () {
cy.loginAs(activeUser);
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
cy.get('[data-cy=collection-files-panel]').within(() => {
cy.get('[type="checkbox"]').first().check();
})
.as('testCollection').then(function () {
cy.loginAs(activeUser);
- cy.doSearch(`${this.testCollection.uuid}`);
+ cy.goToPath(`/collections/${this.testCollection.uuid}`);
cy.get('[data-cy=virtual-file-tree] > div > i').first().click();
cy.get('[data-cy=collection-files-panel]')
cy.getUser('admin', 'Admin', 'User', true, true)
.as('adminUser').then(function () {
adminUser = this.adminUser;
- }
- );
+ });
cy.getUser('collectionuser1', 'Collection', 'User', false, true)
.as('activeUser').then(function () {
activeUser = this.activeUser;
- }
- );
- })
+ });
+ });
beforeEach(function () {
cy.clearCookies()
});
it('can copy selected into the collection', () => {
- cy.loginAs(adminUser);
-
cy.createCollection(adminUser.token, {
name: `Test source collection ${Math.floor(Math.random() * 999999)}`,
manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
- })
- .as('testSourceCollection').then(function (testSourceCollection) {
- cy.shareWith(adminUser.token, activeUser.user.uuid, testSourceCollection.uuid, 'can_read');
- });
-
+ }).as('testSourceCollection').then(function (testSourceCollection) {
+ cy.shareWith(adminUser.token, activeUser.user.uuid, testSourceCollection.uuid, 'can_read');
+ });
cy.createCollection(adminUser.token, {
name: `Test target collection ${Math.floor(Math.random() * 999999)}`,
- })
- .as('testTargetCollection').then(function (testTargetCollection) {
- cy.shareWith(adminUser.token, activeUser.user.uuid, testTargetCollection.uuid, 'can_write');
- });
+ }).as('testTargetCollection').then(function (testTargetCollection) {
+ cy.shareWith(adminUser.token, activeUser.user.uuid, testTargetCollection.uuid, 'can_write');
+ cy.addToFavorites(activeUser.token, activeUser.user.uuid, testTargetCollection.uuid);
+ });
cy.getAll('@testSourceCollection', '@testTargetCollection')
.then(function ([testSourceCollection, testTargetCollection]) {
cy.loginAs(activeUser);
-
- cy.get('.layout-pane-primary')
- .contains('Projects').click();
-
- cy.addToFavorites(activeUser.token, activeUser.user.uuid, testTargetCollection.uuid);
-
- cy.get('main').contains(testSourceCollection.name).click();
+ cy.goToPath(`/collections/${testSourceCollection.uuid}`);
cy.get('[data-cy=collection-files-panel]').contains('bar');
cy.get('[data-cy=collection-files-panel]').find('input[type=checkbox]').click({ force: true });
cy.get('[data-cy=collection-files-panel-options-btn]').click();
cy.get('[data-cy=context-menu]')
.contains('Copy selected into the collection').click();
-
cy.get('[data-cy=projects-tree-favourites-tree-picker]')
.find('i')
.click();
-
cy.get('[data-cy=projects-tree-favourites-tree-picker]')
.contains(testTargetCollection.name)
.click();
-
cy.get('[data-cy=form-submit-btn]').click();
-
- cy.get('.layout-pane-primary')
- .contains('Projects').click();
-
- cy.get('main').contains(testTargetCollection.name).click();
-
+ cy.get('.layout-pane-primary').contains('Projects').click();
+ cy.goToPath(`/collections/${testTargetCollection.uuid}`);
cy.get('[data-cy=collection-files-panel]').contains('bar');
});
});
.then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1, testCollection]) {
cy.loginAs(activeUser);
- cy.doSearch(`${activeUser.user.uuid}`);
-
cy.contains(testCollection.name).rightclick();
cy.get('[data-cy=context-menu]').within(() => {
cy.contains('Move to').click();
cy.get('[data-cy=form-submit-btn]').click();
});
- cy.doSearch(`${mySharedWritableProject.uuid}`);
+ cy.goToPath(`/projects/${mySharedWritableProject.uuid}`);
cy.get('main').contains(testCollection.name);
});
});
cy.getAll('@mySharedWritableProject', '@mySharedReadonlyProject', '@myProject1')
.then(function ([mySharedWritableProject, mySharedReadonlyProject, myProject1]) {
- cy.loginAs(activeUser);
-
cy.createWorkflow(adminUser.token, {
name: `TestWorkflow${Math.floor(Math.random() * 999999)}.cwl`,
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}",
})
.as('testWorkflow2');
- cy.contains('Shared with me').click();
-
- cy.doSearch(`${activeUser.user.uuid}`);
+ cy.loginAs(activeUser);
cy.get('main').contains(myProject1.name).click();
});
it('shows not found page', function() {
- // given
- const invalidUUID = '1212r12r12r12r12r12r21r'
-
// when
cy.loginAs(adminUser);
- cy.visit(`/collections/${invalidUUID}`);
+ cy.goToPath(`/this/is/an/invalid/route`);
// then
cy.get('[data-cy=not-found-page]').should('exist');
// when
cy.loginAs(adminUser);
- cy.visit(`/projects/${notExistingUUID}`);
+ cy.goToPath(`/projects/${notExistingUUID}`);
// then
- cy.get('[data-cy=not-found-page]').should('not.exist');
cy.get('[data-cy=not-found-content]').should('exist');
+ cy.get('[data-cy=not-found-page]').should('not.exist');
});
})
\ No newline at end of file
}
cy.loginAs(activeUser);
- cy.doSearch(`${activeUser.user.uuid}`);
+ cy.goToPath(`/projects/${activeUser.user.uuid}`);
cy.get('[data-cy=breadcrumb-first]').should('contain', 'Projects');
cy.get('[data-cy=breadcrumb-last]').should('not.exist');
// Create new project
it('enables the +NEW side panel button on users home project', function() {
cy.loginAs(activeUser);
- cy.doSearch(`${activeUser.user.uuid}`);
cy.get('[data-cy=side-panel-button]')
.should('exist')
.and('not.be.disabled');
head_uuid: this.sharedGroup.uuid,
tail_uuid: activeUser.user.uuid
})
- cy.doSearch(`${this.sharedGroup.uuid}`);
+ cy.goToPath(`/projects/${this.sharedGroup.uuid}`);
cy.get('[data-cy=side-panel-button]')
.should('exist')
.and(`${isWritable ? 'not.' : ''}be.disabled`);
{url: '/all_processes', label: 'All Processes'},
{url: '/trash', label: 'Trash'},
].map(function(section) {
- cy.visit(section.url);
+ cy.goToPath(section.url);
cy.get('[data-cy=breadcrumb-first]')
.should('contain', section.label);
cy.get('[data-cy=side-panel-button]')
properties: {filters: []},
}).as('myFavoriteFilterGroup').then(function (myFavoriteFilterGroup) {
cy.contains('Refresh').click();
- cy.doSearch(`${myFavoriteFilterGroup.uuid}`);
+ cy.goToPath(`/projects/${myFavoriteFilterGroup.uuid}`);
cy.get('[data-cy=breadcrumb-last]').should('contain', 'my-favorite-filter-group');
cy.get('[data-cy=side-panel-button]')
const controllerURL = Cypress.env('controller_url');
const systemToken = Cypress.env('system_token');
+let createdResources = [];
+
+// Clean up on a 'before' hook to allow post-mortem analysis on individual tests.
+beforeEach(function () {
+ if (createdResources.length === 0) {
+ return;
+ }
+ cy.log(`Cleaning ${createdResources.length} previously created resource(s)`);
+ createdResources.forEach(function({suffix, uuid}) {
+ // Don't fail when a resource isn't already there, some objects may have
+ // been removed, directly or indirectly, from the test that created them.
+ cy.deleteResource(systemToken, suffix, uuid, false);
+ });
+ createdResources = [];
+});
Cypress.Commands.add(
"doRequest", (method = 'GET', path = '', data = null, qs = null,
- token = systemToken, auth = false, followRedirect = true) => {
+ token = systemToken, auth = false, followRedirect = true, failOnStatusCode = true) => {
return cy.request({
method: method,
- url: `${controllerURL}/${path}`,
+ url: `${controllerURL.replace(/\/+$/, '')}/${path.replace(/^\/+/, '')}`,
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.
-// TODO: Maybe we can add an optional param to avoid the loading part?
-Cypress.Commands.add(
- "resetDB", () => {
- cy.request('POST', `${controllerURL}/database/reset?api_token=${systemToken}`);
- }
-)
+ followRedirect: followRedirect,
+ failOnStatusCode: failOnStatusCode
+ });
+});
Cypress.Commands.add(
"getUser", (username, first_name = '', last_name = '', is_admin = false, is_active = true) => {
return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true)
.its('body').as('resource')
.then(function () {
+ createdResources.push({suffix, uuid: this.resource.uuid});
return this.resource;
})
}
)
Cypress.Commands.add(
- "deleteResource", (token, suffix, uuid) => {
- return cy.doRequest('DELETE', '/arvados/v1/' + suffix + '/' + uuid)
+ "deleteResource", (token, suffix, uuid, failOnStatusCode = true) => {
+ return cy.doRequest('DELETE', '/arvados/v1/' + suffix + '/' + uuid, null, null, token, false, true, failOnStatusCode)
.its('body').as('resource')
.then(function () {
return this.resource;
Cypress.Commands.add(
"loginAs", (user) => {
+ cy.clearCookies()
+ cy.clearLocalStorage()
cy.visit(`/token/?api_token=${user.token}`);
- cy.url().should('contain', '/projects/');
+ cy.url({timeout: 10000}).should('contain', '/projects/');
cy.get('div#root').should('contain', 'Arvados Workbench (zzzzz)');
cy.get('div#root').should('not.contain', 'Your account is inactive');
}
}
)
+Cypress.Commands.add(
+ "goToPath", (path) => {
+ return cy.window().its('appHistory').invoke('push', path);
+ }
+)
+
Cypress.Commands.add('getAll', (...elements) => {
const promise = cy.wrap([], { log: false })
});
})
-Cypress.Commands.add('addToFavorites', (activeUserToken, activeUserUUID, itemUUID) => {
- cy.createLink(activeUserToken, {
+Cypress.Commands.add('addToFavorites', (userToken, userUUID, itemUUID) => {
+ cy.createLink(userToken, {
head_uuid: itemUUID,
link_class: 'star',
name: '',
- owner_uuid: activeUserUUID,
- tail_uuid: activeUserUUID,
+ owner_uuid: userUUID,
+ tail_uuid: userUUID,
});
})
fetchConfig()
.then(({ config, apiHost }) => {
const history = createBrowserHistory();
+
+ // Provide browser's history access to Cypress to allow programmatic
+ // navigation.
+ if ((window as any).Cypress) {
+ (window as any).appHistory = history;
+ }
+
const services = createServices(config, {
progressFn: (id, working) => {
store.dispatch(progressIndicatorActions.TOGGLE_WORKING({ id, working }));
</Grid>
<Grid item xs className={props.classes.content}>
<Switch>
- {routes}
+ {routes.props.children}
<Route path={Routes.NO_MATCH} component={NotFoundPanel} />
</Switch>
</Grid>