Skip to content

Commit

Permalink
add waiter for import job to complete
Browse files Browse the repository at this point in the history
  • Loading branch information
eremv committed Sep 23, 2024
1 parent 0ebc97b commit 15df73b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ describe('eHoldings', () => {
EHoldingsPackageView.selectTitleRecord();
eHoldingsResourceView.openExportModal();
ExportSettingsModal.clickExportButton();
EHoldingsPackageView.verifyDetailViewPage(testData.title, testData.selectionStatus);
EHoldingsPackageView.getJobIDFromCalloutMessage().then((id) => {
const jobId = id;

EHoldingsPackageView.waitForJobToComplete(jobId);
cy.visit(TopMenu.exportManagerPath);
ExportManagerSearchPane.searchByEHoldings();
ExportManagerSearchPane.verifyResult(jobId);
Expand Down
26 changes: 26 additions & 0 deletions cypress/support/fragments/eholdings/eHoldingsPackageView.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { recurse } from 'cypress-recurse';
import {
Button,
HTML,
Expand Down Expand Up @@ -181,6 +182,31 @@ export default {
});
},

waitForJobToComplete: (jobId) => {
function getImportJobStatus() {
return cy.okapiRequest({
method: 'GET',
path: 'data-export-spring/jobs',
searchParams: {
limit: 100,
offset: 0,
query: `((name="*${jobId}*"))`,
},
isDefaultSearchParamsRequired: false,
});
}
recurse(
() => getImportJobStatus(),
(response) => {
return response.body.jobRecords[0].status === 'SUCCESSFUL';
},
{
limit: 10,
delay: 1_000,
},
);
},

selectTitleFieldsToExport: (value) => {
cy.do(titleFieldsSelect.select(value));
},
Expand Down

0 comments on commit 15df73b

Please sign in to comment.