}
)
+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', {
}
)
+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', {
+ virtual_machine: JSON.stringify(data),
+ ensure_unique_name: true
+ })
+ }
+)
+
Cypress.Commands.add(
"createResource", (token, suffix, data) => {
return cy.doRequest('POST', '/arvados/v1/' + suffix, data, null, token, true)
cy.addToFavorites(user.token, user.user.uuid, project.uuid);
}
});
-});
\ No newline at end of file
+});
+
+Cypress.Commands.add(
+ 'upload',
+ {
+ prevSubject: 'element',
+ },
+ (subject, file, fileName) => {
+ cy.window().then(window => {
+ const blob = b64toBlob(file, '', 512);
+ const testFile = new window.File([blob], fileName);
+
+ cy.wrap(subject).trigger('drop', {
+ dataTransfer: { files: [testFile] },
+ });
+ })
+ }
+)
+
+function b64toBlob(b64Data, contentType = '', sliceSize = 512) {
+ const byteCharacters = atob(b64Data)
+ const byteArrays = []
+
+ for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
+ const slice = byteCharacters.slice(offset, offset + sliceSize);
+
+ const byteNumbers = new Array(slice.length);
+ for (let i = 0; i < slice.length; i++) {
+ byteNumbers[i] = slice.charCodeAt(i);
+ }
+
+ const byteArray = new Uint8Array(byteNumbers);
+
+ byteArrays.push(byteArray);
+ }
+
+ const blob = new Blob(byteArrays, { type: contentType });
+ return blob
+}