cells-component-back-compatibility
Version:
Repository where the functional tests of the components will be executed
128 lines (117 loc) • 3.69 kB
JavaScript
;
const fs = require('fs-extra');
const path = require('path');
const expect = require('chai').expect;
const exec = require('child_process').exec;
const p = require('pisco-callback-to-promise');
/* global define, it, describe, before, beforeEach, afterEach, after */
// constants
const testComponents = [
{
name: 'cells-atom-button',
url: 'ssh://git@globaldevtools.bbva.com:7999/ca/cells-atom-button.git'
},
{
name: 'cells-molecule-star-rating',
url: 'ssh://git@globaldevtools.bbva.com:7999/bgcm/cells-molecule-star-rating.git'
},
{
name: 'cells-ajax-behavior',
url: 'ssh://globaldevtools.bbva.com:7999/CBH/cells-ajax-behavior.git',
disabled: true
},
{
name: 'cells-template-animation-behavior',
url: 'ssh://git@globaldevtools.bbva.com:7999/cbh/cells-template-animation-behavior.git',
disabled: true
},
{
name: 'bgadp-employees',
url: 'ssh://git@globaldevtools.bbva.com:7999/bbvacellsapi/bgadp-employees.git',
disabled: true
},
{
name: 'bgadp-investment-funds',
url: 'ssh://git@globaldevtools.bbva.com:7999/bbvacellsapi/bgadp-investment-funds.git',
disabled: true
},
{
name: 'cells-http-native',
url: 'ssh://git@globaldevtools.bbva.com:7999/cel/cells-http-native.git',
disabled: true
},
{
name: 'cells-input-validations-behavior',
url: '--branch 0.1.2 ssh://git@globaldevtools.bbva.com:7999/cbh/cells-input-validations-behavior.git'
},
{
name: 'cells-i18n-behavior',
url: '--branch 3.5.0 ssh://git@globaldevtools.bbva.com:7999/cbh/cells-i18n-behavior.git'
},
{
name: 'cells-d3-import',
url: '--branch 1.0.2 ssh://git@globaldevtools.bbva.com:7999/cc/cells-d3-import.git'
},
{
name: 'coronita-icons',
url: '--branch 3.0.2 ssh://git@globaldevtools.bbva.com:7999/ct/coronita-icons.git'
},
{
name: 'cells-bgadp-account-dm',
url: '--branch 0.1.6 ssh://git@globaldevtools.bbva.com:7999/bbvacellsapi/cells-bgadp-account-dm.git'
},
{
name: 'bgadp-accounts',
url: '--branch 1.2.0 ssh://git@globaldevtools.bbva.com:7999/bbvacellsapi/bgadp-accounts.git'
}
];
const base = `${__dirname}/../tmp`;
const context = 'component';
// --- Actions ---------
const setPisco = () => {
if (!process.env.piscoExec) {
process.env.piscoExec = 'cells';
}
};
const clone = (config) => {
return p.c2p(fs.ensureDir, base)
.then(() => p.c2p(exec, `git clone ${config.url}`, {cwd: base}));
};
const validate = (config) => {
return clone(config)
.then(() => p.c2p(exec, `${process.env.piscoExec} ${context}:validate`, {cwd: path.join(base, config.name)}));
};
const flowsToTest = () => {
return [
{
name: 'validate',
exec: validate,
timeout: 500000
}
];
};
// ---- Tests --------
flowsToTest().forEach((flow) => {
describe(`Run cells ${context}:${flow.name}`, () => {
beforeEach('Set pisco if necessary', setPisco);
testComponents.forEach((config) => {
if (!config.disabled) {
it(`Should build ${context} "${config.name}" --> "(${config.url})"`, (done) => {
flow.exec(config)
.then((stdout) => {
expect(stdout).contain(`Flow [ ${flow.name} ] finished`);
}).catch((error) => {
p.logError(error);
return Promise.resolve(error.error ? error.error : error);
}).then(done);
}).timeout(flow.timeout);
} else {
it(`Test of ${context} "${config.name}" --> TEMPORARY DISABLED!`, (done) => done());
}
});
afterEach('Should delete the tmp directory', (done) => {
p.c2p(fs.remove, base)
.then(() => done());
});
});
});