Skip to content

Commit

Permalink
frontend: Fix for e2e tests in Executions
Browse files Browse the repository at this point in the history
Fix for Cypress e2e tests to correctly assert table values

Signed-off-by: Goran Kokinovski <[email protected]>
  • Loading branch information
gorankokin committed May 30, 2023
1 parent f08ecce commit 6763e14
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe(
});

describe('smoke', { tags: ['@smoke'] }, () => {
it('Validate Data Jobs Health Overview panel when switching Teams', () => {
it('Validate Data Jobs Health Overview panel', () => {
getStartedPage
.getPageTitle()
.should('contain.text', 'Get Started with Data Pipelines');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,10 @@ describe(
// verify cell elements
dataJobExecutionsPage
.getDataGridExecTypeContainers('manual')
.should('have.length', 0);
.should('have.length.gte', 0);
dataJobExecutionsPage
.getDataGridExecTypeContainers('scheduled')
.should('have.length.gte', 0);

// verify current URL has appended manual and scheduled execution trigger and sort by type ascending
dataJobExecutionsPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

const { default: axios } = require('axios');

const { cloneDeep } = require('lodash');

const { Logger } = require('./logger-helpers.plugins');

const { trimArraysToNElements } = require('./util-helpers.plugins');
Expand Down Expand Up @@ -246,7 +248,7 @@ const _filterResponseDataForDebug = (response) => {
method: response.config.method,
data: response.config.data
},
data: trimArraysToNElements(response.data, 5)
data: trimArraysToNElements(cloneDeep(response.data), 5)
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,46 @@ const waitForDataJobExecutionToComplete = (
});
};

/**
* ** Delete Data Jobs without deployment with parallelism.
*
* @param {Cypress.ResolvedConfigOptions} config
* @return {Promise<boolean[]>}
*/
const deleteDataJobsWithoutDeployment = (config) => {
const url = `${config.env['data_jobs_url']}/data-jobs/for-team/cy-e2e-vdk/jobs?operationName=jobsQuery&variables=%7B%22pageNumber%22:1,%22pageSize%22:100,%22filter%22:%5B%5D,%22search%22:%22%22%7D&query=query%20jobsQuery($filter:%20%5BPredicate%5D,%20$search:%20String,%20$pageNumber:%20Int,%20$pageSize:%20Int)%20%7B%0A%20%20jobs(%0A%20%20%20%20pageNumber:%20$pageNumber%0A%20%20%20%20pageSize:%20$pageSize%0A%20%20%20%20filter:%20$filter%0A%20%20%20%20search:%20$search%0A%20%20)%20%7B%0A%20%20%20%20content%20%7B%0A%20%20%20%20%20%20jobName%0A%20%20%20%20%20%20config%20%7B%0A%20%20%20%20%20%20%20%20team%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20deployments%20%7B%0A%20%20%20%20%20%20%20%20id%0A%20%20%20%20%20%20%20%20enabled%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20totalPages%0A%20%20%20%20totalItems%0A%20%20%7D%0A%7D`;

return httpGetReq(url).then((response) => {
const jobs = response.data.data.content;
const remappedJobs = jobs
.filter(
(job) => !job.deployments && job.jobName?.includes('cy-e2e-vdk')
)
.map((job) => {
return {
job_name: job.jobName,
team: job.config?.team ?? 'cy-e2e-vdk'
};
});

// log which Data Jobs should be deleted
remappedJobs.forEach((job, index) => {
Logger.debug(
'Deleting',
index + 1,
'jobName:',
job.jobName,
'team:',
job?.config?.team,
'deployments:',
job.deployments
);
});

return _deleteDataJobsWithoutDeployment(remappedJobs, config);
});
};

/**
* ** Compare dates ASC.
*
Expand Down Expand Up @@ -1224,12 +1264,45 @@ const _loadFixturesValuesAndBinariesPaths = (pathToFixtures) => {
});
};

/**
** Delete Data Jobs without deployment in a chunks of max 10 parallel requests.
*
* @param {{team: string; job_name: string;}} jobFixtures
* @param {Cypress.ResolvedConfigOptions} config
* @param {boolean[]} responses
* @return {Promise<boolean[]>}
* @private
*/
const _deleteDataJobsWithoutDeployment = (
jobFixtures,
config,
responses = []
) => {
const chunk =
jobFixtures.length > 10 ? jobFixtures.splice(0, 10) : jobFixtures;

return deleteJobs(chunk, config).then((statuses) => {
responses.push(...statuses);

if (jobFixtures.length > 0) {
return _deleteDataJobsWithoutDeployment(
jobFixtures,
config,
responses
);
}

return responses;
});
};

module.exports = {
createDeployJobs,
deleteJobsFixtures,
deleteJobs,
provideDataJobsExecutions,
changeJobsStatusesFixtures,
waitForDataJobExecutionToComplete,
deleteDataJobsWithoutDeployment,
compareDatesASC
};
12 changes: 10 additions & 2 deletions projects/frontend/data-pipelines/gui/e2e/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const {
waitForDataJobExecutionToComplete,
deleteJobs,
deleteJobsFixtures,
changeJobsStatusesFixtures
changeJobsStatusesFixtures,
deleteDataJobsWithoutDeployment
} = require('./helpers/job-helpers.plugins');

/**
Expand All @@ -48,6 +49,14 @@ const {
// `cypressConfig` is the resolved Cypress config
module.exports = (on, cypressConfig) => {
const TASKS = {
/**
* ** Delete Data Jobs without deployment with parallelism.
*
* @return {Promise<boolean[]>}
*/
deleteDataJobsWithoutDeployment: () => {
return deleteDataJobsWithoutDeployment({ ...cypressConfig });
},
/**
* ** Create test Data Jobs if they don't exist.
*
Expand Down Expand Up @@ -101,7 +110,6 @@ module.exports = (on, cypressConfig) => {
{ ...cypressConfig }
);
},

/**
* ** Change Data Jobs statuses for provided fixtures.
*
Expand Down

0 comments on commit 6763e14

Please sign in to comment.