+ );
+});
+
+Cypress.Commands.add("createLink", (token, data) => {
+ return cy.createResource(token, "links", {
+ link: JSON.stringify(data),
+ });
+});
+
+Cypress.Commands.add("createGroup", (token, data) => {
+ return cy.createResource(token, "groups", {
+ group: JSON.stringify(data),
+ ensure_unique_name: true,
+ });
+});
+
+Cypress.Commands.add("trashGroup", (token, uuid) => {
+ return cy.deleteResource(token, "groups", uuid);
+});
+
+Cypress.Commands.add("createWorkflow", (token, data) => {
+ return cy.createResource(token, "workflows", {
+ workflow: JSON.stringify(data),
+ ensure_unique_name: true,
+ });
+});
+
+Cypress.Commands.add("createCollection", (token, data) => {
+ return cy.createResource(token, "collections", {
+ collection: JSON.stringify(data),
+ ensure_unique_name: true,
+ });
+});
+
+Cypress.Commands.add("getCollection", (token, uuid) => {
+ return cy.getResource(token, "collections", uuid);
+});
+
+Cypress.Commands.add("updateCollection", (token, uuid, data) => {
+ return cy.updateResource(token, "collections", uuid, {
+ collection: JSON.stringify(data),
+ });
+});
+
+Cypress.Commands.add("collectionReplaceFiles", (token, uuid, data) => {
+ return cy.updateResource(token, "collections", uuid, {
+ collection: {
+ preserve_version: true,
+ },
+ replace_files: JSON.stringify(data),
+ });
+});
+
+Cypress.Commands.add("getContainer", (token, uuid) => {
+ return cy.getResource(token, "containers", uuid);
+});
+
+Cypress.Commands.add("updateContainer", (token, uuid, data) => {
+ return cy.updateResource(token, "containers", uuid, {
+ container: JSON.stringify(data),
+ });
+});
+
+Cypress.Commands.add("getContainerRequest", (token, uuid) => {
+ return cy.getResource(token, "container_requests", uuid);
+});
+
+Cypress.Commands.add("createContainerRequest", (token, data) => {
+ return cy.createResource(token, "container_requests", {
+ container_request: JSON.stringify(data),
+ ensure_unique_name: true,
+ });
+});
+
+Cypress.Commands.add("updateContainerRequest", (token, uuid, data) => {
+ return cy.updateResource(token, "container_requests", uuid, {
+ container_request: JSON.stringify(data),
+ });
+});
+
+/**
+ * Requires an admin token for log_uuid modification to succeed
+ */
+Cypress.Commands.add("appendLog", (token, crUuid, fileName, lines = []) =>
+ cy.getContainerRequest(token, crUuid).then(containerRequest => {
+ if (containerRequest.log_uuid) {
+ cy.listContainerRequestLogs(token, crUuid).then(logFiles => {
+ const filePath = `${containerRequest.log_uuid}/${containerLogFolderPrefix}${containerRequest.container_uuid}/${fileName}`;
+ if (logFiles.find(file => file.name === fileName)) {
+ // File exists, fetch and append
+ return cy
+ .doWebDAVRequest("GET", `c=${filePath}`, null, null, token)
+ .then(({ body: contents }) =>
+ cy.doWebDAVRequest("PUT", `c=${filePath}`, contents.split("\n").concat(lines).join("\n"), null, token)
+ );
+ } else {
+ // File not exists, put new file
+ cy.doWebDAVRequest("PUT", `c=${filePath}`, lines.join("\n"), null, token);
+ }
+ });
+ } else {
+ // Create log collection
+ return cy
+ .createCollection(token, {
+ name: `Test log collection ${Math.floor(Math.random() * 999999)}`,
+ owner_uuid: containerRequest.owner_uuid,
+ manifest_text: "",