16672: Adds Cypress tests on process logs viewing.
[arvados-workbench2.git] / cypress / support / commands.js
index cfdfa9ecffb0e94c2262d0f580b8222f3d7b2c72..5a2428b2c5e7764f1f8c1c30cb9a221a7bb61ffc 100644 (file)
@@ -133,6 +133,16 @@ Cypress.Commands.add(
     }
 )
 
+Cypress.Commands.add(
+    "getCollection", (token, uuid) => {
+        return cy.doRequest('GET', `/arvados/v1/collections/${uuid}`, null, {}, token)
+            .its('body')
+            .then(function (theCollection) {
+                return theCollection;
+            })
+    }
+)
+
 Cypress.Commands.add(
     "createCollection", (token, data) => {
         return cy.createResource(token, 'collections', {
@@ -150,6 +160,49 @@ Cypress.Commands.add(
     }
 )
 
+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)
+        })
+    }
+)
+
+Cypress.Commands.add(
+    "createLog", (token, data) => {
+        return cy.createResource(token, 'logs', {
+            log: JSON.stringify(data)
+        })
+    }
+)
+
+Cypress.Commands.add(
+    "logsForContainer", (token, uuid, logType, logTextArray = []) => {
+        let logs = [];
+        for (const logText of logTextArray) {
+            logs.push(cy.createLog(token, {
+                object_uuid: uuid,
+                event_type: logType,
+                properties: {
+                    text: logText
+                }
+            }).as('lastLogRecord'))
+        }
+        cy.getAll('@lastLogRecord').then(function () {
+            return logs;
+        })
+    }
+)
+
 Cypress.Commands.add(
     "createVirtualMachine", (token, data) => {
         return cy.createResource(token, 'virtual_machines', {