-Cypress.Commands.add(
- "appendLog", (token, crUuid, fileName, lines = []) => (
- cy.getContainerRequest(token, crUuid).then((containerRequest) => {
- if (containerRequest.log_uuid) {
- cy.listContainerRequestLogs(token, crUuid).then((logFiles) => {
- if (logFiles.find((file) => (file.name === fileName))) {
- // File exists, fetch and append
- return cy.doKeepRequest(
- "GET",
- `c=${containerRequest.log_uuid}/${fileName}`,
- null,
- null,
- token
- )
- .then(({ body: contents }) => cy.doKeepRequest(
- "PUT",
- `c=${containerRequest.log_uuid}/${fileName}`,
- contents.split("\n").concat(lines).join("\n"),
- null,
- token
- ));
- } else {
- // File not exists, put new file
- cy.doKeepRequest(
- "PUT",
- `c=${containerRequest.log_uuid}/${fileName}`,
- lines.join("\n"),
- null,
- token
- )
- }
- });
- // Fetch current log contents and append new line
- // let newLines = [...lines];
- // return cy.doKeepRequest('GET', `c=${containerRequest.log_uuid}/${fileName}`, null, null, token)
- // .then(({body: contents}) => {
- // newLines = [contents.split('\n'), ...newLines];
- // })
- // .then(() => (
- // cy.doKeepRequest('PUT', `c=${containerRequest.log_uuid}/${fileName}`, newLines.join('\n'), null, token)
- // ));
- } else {
- // Create log collection
- return cy.createCollection(token, {
+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, {