Skip to content

Commit

Permalink
[ACS-5845] remove deprecated js-api compat mode (#3387)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika authored Aug 16, 2023
1 parent c73ffd8 commit b3aeca7
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions e2e/protractor/e2e-config/utils/upload-output.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,67 @@
const path = require('path');
const fs = require('fs');
const AlfrescoApi = require('@alfresco/js-api').AlfrescoApiCompatibility;
const path = require('node:path');
const fs = require('node:fs');
const child_process = require('node:child_process');
const { AlfrescoApi, NodesApi, UploadApi } = require('@alfresco/js-api');
const buildNumber = require('./build-number');
const outputDir = path.resolve(__dirname, '../../../e2e-output/');

async function saveScreenshots(retryCount) {
const folderName = process.env.GITHUB_JOB;
console.log(`Start uploading report in ${folderName}`);

let alfrescoJsApi = new AlfrescoApi({
const alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: process.env.SCREENSHOT_URL
});

const nodesApi = new NodesApi(alfrescoJsApi);
const uploadApi = new UploadApi(alfrescoJsApi);

await alfrescoJsApi.login(process.env.SCREENSHOT_USERNAME, process.env.SCREENSHOT_PASSWORD);

let folderNode;

try {
folderNode = await alfrescoJsApi.nodes.addNode('-my-', {
'name': `retry-${retryCount}`,
'relativePath': `Builds/ACA-${buildNumber()}/${folderName}/`,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
folderNode = await nodesApi.createNode(
'-my-',
{
name: `retry-${retryCount}`,
relativePath: `Builds/ACA-${buildNumber()}/${folderName}/`,
nodeType: 'cm:folder'
},
{},
{
overwrite: true
}
);
} catch (error) {
folderNode = await alfrescoJsApi.nodes.getNode('-my-', {
'relativePath': `Builds/ACA-${buildNumber()}/${folderName}/retry-${retryCount}`,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
folderNode = await nodesApi.createNode(
'-my-',
{
relativePath: `Builds/ACA-${buildNumber()}/${folderName}/retry-${retryCount}`,
nodeType: 'cm:folder'
},
{},
{
overwrite: true
}
);
}

fs.renameSync(outputDir, path.join(`${outputDir}-${folderName}-${retryCount}/`));

const child_process = require("child_process");
child_process.execSync(` tar -czvf ../e2e-result-${folderName}-${retryCount}.tar .`, {
cwd: `${outputDir}-${folderName}-${retryCount}/`
});

let pathFile = path.join(outputDir, `../e2e-result-${folderName}-${retryCount}.tar`);

let file = fs.createReadStream(pathFile);
await alfrescoJsApi.upload.uploadFile(
file,
'',
folderNode.entry.id,
null,
{
'name': `e2e-result-${folderName}-${retryCount}.tar`,
'nodeType': 'cm:content',
'autoRename': true
}
);
const pathFile = path.join(outputDir, `../e2e-result-${folderName}-${retryCount}.tar`);
const file = fs.createReadStream(pathFile);

await uploadApi.uploadFile(file, '', folderNode.entry.id, null, {
name: `e2e-result-${folderName}-${retryCount}.tar`,
nodeType: 'cm:content',
autoRename: true
});
}

module.exports = {
Expand Down

0 comments on commit b3aeca7

Please sign in to comment.