Skip to content

Commit

Permalink
Move files uploads to upload via API (#3599)
Browse files Browse the repository at this point in the history
  • Loading branch information
sviatlana-stsiapanava committed May 9, 2024
1 parent 70071e0 commit c0e0bd1
Show file tree
Hide file tree
Showing 22 changed files with 293 additions and 468 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import InventoryInstance from '../../../../support/fragments/inventory/inventory
import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager';
import getRandomPostfix from '../../../../support/utils/stringTools';
import DataImport from '../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../support/fragments/data_import/logs/logs';
import { JOB_STATUS_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../../../support/constants';
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../../support/constants';
import InventorySearchAndFilter from '../../../../support/fragments/inventory/inventorySearchAndFilter';
import Location from '../../../../support/fragments/settings/tenant/locations/newLocation';
import InventoryHoldings from '../../../../support/fragments/inventory/holdings/inventoryHoldings';
Expand Down Expand Up @@ -213,33 +211,23 @@ describe('Inventory', () => {
// 1 Local "Instance" record with source = "MARC" and filled alternative title fields should exist on Member 1 tenant.
// 1 Local "Instance" record with source = "MARC" and filled alternative title fields should exist on Member 2 tenant.

cy.loginAsAdmin({ path: TopMenu.dataImportPath, waiter: DataImport.waitLoading }).then(
() => {
marcFiles.forEach((marcFile, index) => {
if (marcFile.tenant !== tenantNames.central) {
ConsortiumManager.switchActiveAffiliation(
marcFiles[index - 1].tenant,
marcFile.tenant,
);
DataImport.waitLoading();
ConsortiumManager.checkCurrentTenantInTopMenu(marcFile.tenant);
}
DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(marcFile.marc, marcFile.fileName);
JobProfiles.waitLoadingList();
JobProfiles.search(marcFile.jobProfileToRun);
JobProfiles.runImportFile();
Logs.waitFileIsImported(marcFile.fileName);
Logs.checkJobStatus(marcFile.fileName, JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(marcFile.fileName);
for (let i = 0; i < marcFile.numOfRecords; i++) {
Logs.getCreatedItemsID(i).then((link) => {
marcFile.createdRecordsId.push(link.split('/')[5]);
});
}
cy.resetTenant();
marcFiles.forEach((marcFile) => {
if (marcFile.tenant === 'College') {
cy.setTenant(Affiliations.College);
} else if (marcFile.tenant === 'University') {
cy.setTenant(Affiliations.University);
}
DataImport.uploadFileViaApi(
marcFile.marc,
marcFile.fileName,
marcFile.jobProfileToRun,
).then((response) => {
response.forEach((record) => {
marcFile.createdRecordsId.push(record.instance.id);
});
},
);
});
});
})
.then(() => {
// 1 Shared "Instance" record with source = "MARC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Users from '../../../../support/fragments/users/users';
import MarcAuthorities from '../../../../support/fragments/marcAuthority/marcAuthorities';
import MarcAuthority from '../../../../support/fragments/marcAuthority/marcAuthority';
import DataImport from '../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../support/fragments/data_import/logs/logs';
import { JOB_STATUS_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../../../support/constants';
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../../support/constants';
import QuickMarcEditor from '../../../../support/fragments/quickMarcEditor';
import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations';
import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager';
Expand Down Expand Up @@ -42,22 +40,15 @@ describe('MARC', () => {
let createdAuthorityID;

before('Create test data', () => {
cy.resetTenant();
cy.getAdminToken();
cy.loginAsAdmin({
path: TopMenu.dataImportPath,
waiter: DataImport.waitLoading,
}).then(() => {
DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(marcFile.marc, marcFile.fileName);
JobProfiles.waitFileIsUploaded();
JobProfiles.waitLoadingList();
JobProfiles.search(marcFile.jobProfileToRun);
JobProfiles.runImportFile();
JobProfiles.waitFileIsImported(marcFile.fileName);
Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(marcFile.fileName);
Logs.getCreatedItemsID().then((link) => {
createdAuthorityID = link.split('/')[5];
DataImport.uploadFileViaApi(
marcFile.marc,
marcFile.fileName,
marcFile.jobProfileToRun,
).then((response) => {
response.forEach((record) => {
createdAuthorityID = record.authority.id;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import Users from '../../../../support/fragments/users/users';
import MarcAuthorities from '../../../../support/fragments/marcAuthority/marcAuthorities';
import MarcAuthority from '../../../../support/fragments/marcAuthority/marcAuthority';
import DataImport from '../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../support/fragments/data_import/logs/logs';
import { JOB_STATUS_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../../../support/constants';
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../../support/constants';
import QuickMarcEditor from '../../../../support/fragments/quickMarcEditor';
import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations';
import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager';
Expand Down Expand Up @@ -43,22 +41,15 @@ describe('MARC', () => {
let createdAuthorityID;

before('Create test data', () => {
cy.resetTenant();
cy.getAdminToken();
cy.loginAsAdmin({
path: TopMenu.dataImportPath,
waiter: DataImport.waitLoading,
}).then(() => {
DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(marcFile.marc, marcFile.fileName);
JobProfiles.waitFileIsUploaded();
JobProfiles.waitLoadingList();
JobProfiles.search(marcFile.jobProfileToRun);
JobProfiles.runImportFile();
JobProfiles.waitFileIsImported(marcFile.fileName);
Logs.checkStatusOfJobProfile(JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(marcFile.fileName);
Logs.getCreatedItemsID().then((link) => {
createdAuthorityID = link.split('/')[5];
DataImport.uploadFileViaApi(
marcFile.marc,
marcFile.fileName,
marcFile.jobProfileToRun,
).then((response) => {
response.forEach((record) => {
createdAuthorityID = record.authority.id;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import Users from '../../../../../support/fragments/users/users';
import TopMenu from '../../../../../support/fragments/topMenu';
import ConsortiumManager from '../../../../../support/fragments/settings/consortium-manager/consortium-manager';
import {
JOB_STATUS_NAMES,
MARC_AUTHORITY_SEARCH_OPTIONS,
DEFAULT_JOB_PROFILE_NAMES,
} from '../../../../../support/constants';
import getRandomPostfix from '../../../../../support/utils/stringTools';
import DataImport from '../../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../../support/fragments/data_import/logs/logs';
import MarcAuthority from '../../../../../support/fragments/marcAuthority/marcAuthority';
import MarcAuthorities from '../../../../../support/fragments/marcAuthority/marcAuthorities';
import MarcAuthoritiesSearch from '../../../../../support/fragments/marcAuthority/marcAuthoritiesSearch';
Expand Down Expand Up @@ -104,32 +101,21 @@ describe('MARC', () => {
]);
})
.then(() => {
cy.loginAsAdmin({
path: TopMenu.dataImportPath,
waiter: DataImport.waitLoading,
});
})
.then(() => {
marcFiles.forEach((marcFile, index) => {
if (marcFile.tenant !== tenantNames.central) {
ConsortiumManager.switchActiveAffiliation(
marcFiles[index - 1].tenant,
marcFile.tenant,
);
DataImport.waitLoading();
ConsortiumManager.checkCurrentTenantInTopMenu(marcFile.tenant);
cy.resetTenant();
marcFiles.forEach((marcFile) => {
if (marcFile.tenant === 'College') {
cy.setTenant(Affiliations.College);
} else if (marcFile.tenant === 'University') {
cy.setTenant(Affiliations.University);
}

DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(marcFile.marc, marcFile.fileName);
JobProfiles.waitLoadingList();
JobProfiles.search(marcFile.jobProfileToRun);
JobProfiles.runImportFile();
Logs.waitFileIsImported(marcFile.fileName);
Logs.checkJobStatus(marcFile.fileName, JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(marcFile.fileName);
Logs.getCreatedItemsID().then((link) => {
marcFile.createdAuthorityID = link.split('/')[5];
DataImport.uploadFileViaApi(
marcFile.marc,
marcFile.fileName,
marcFile.jobProfileToRun,
).then((response) => {
response.forEach((record) => {
marcFile.createdAuthorityID = record.authority.id;
});
});
});
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import Permissions from '../../../../../support/dictionary/permissions';
import Affiliations, { tenantNames } from '../../../../../support/dictionary/affiliations';
import Affiliations from '../../../../../support/dictionary/affiliations';
import Users from '../../../../../support/fragments/users/users';
import TopMenu from '../../../../../support/fragments/topMenu';
import ConsortiumManager from '../../../../../support/fragments/settings/consortium-manager/consortium-manager';
import { JOB_STATUS_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../../../../support/constants';
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../../../support/constants';
import getRandomPostfix from '../../../../../support/utils/stringTools';
import DataImport from '../../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../../support/fragments/data_import/logs/logs';
import MarcAuthority from '../../../../../support/fragments/marcAuthority/marcAuthority';
import MarcAuthorities from '../../../../../support/fragments/marcAuthority/marcAuthorities';
import InventorySearchAndFilter from '../../../../../support/fragments/inventory/inventorySearchAndFilter';
Expand Down Expand Up @@ -59,34 +56,23 @@ describe('MARC', () => {
})
.then(() => {
cy.resetTenant();
cy.loginAsAdmin().then(() => {
marcFiles.forEach((marcFile) => {
cy.visit(TopMenu.dataImportPath);
if (marcFile.tenant === 'College') {
ConsortiumManager.switchActiveAffiliation(
tenantNames.central,
tenantNames.college,
);
DataImport.waitLoading();
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college);
}
DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(marcFile.marc, marcFile.fileNameImported);
JobProfiles.waitLoadingList();
JobProfiles.search(marcFile.jobProfileToRun);
JobProfiles.runImportFile();
Logs.waitFileIsImported(marcFile.fileNameImported);
Logs.checkJobStatus(marcFile.fileNameImported, JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(marcFile.fileNameImported);
Logs.getCreatedItemsID().then((link) => {
createdRecordIDs.push(link.split('/')[5]);
marcFiles.forEach((marcFile) => {
if (marcFile.tenant === 'College') {
cy.setTenant(Affiliations.College);
}
DataImport.uploadFileViaApi(
marcFile.marc,
marcFile.fileNameImported,
marcFile.jobProfileToRun,
).then((response) => {
response.forEach((record) => {
createdRecordIDs.push(record.authority.id);
});
});

cy.login(users.userProperties.username, users.userProperties.password, {
path: TopMenu.marcAuthorities,
waiter: MarcAuthorities.waitLoading,
});
});
cy.login(users.userProperties.username, users.userProperties.password, {
path: TopMenu.marcAuthorities,
waiter: MarcAuthorities.waitLoading,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import Affiliations, { tenantNames } from '../../../../../support/dictionary/aff
import Users from '../../../../../support/fragments/users/users';
import TopMenu from '../../../../../support/fragments/topMenu';
import ConsortiumManager from '../../../../../support/fragments/settings/consortium-manager/consortium-manager';
import { JOB_STATUS_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../../../../support/constants';
import { DEFAULT_JOB_PROFILE_NAMES } from '../../../../../support/constants';
import getRandomPostfix from '../../../../../support/utils/stringTools';
import DataImport from '../../../../../support/fragments/data_import/dataImport';
import JobProfiles from '../../../../../support/fragments/data_import/job_profiles/jobProfiles';
import Logs from '../../../../../support/fragments/data_import/logs/logs';
import MarcAuthority from '../../../../../support/fragments/marcAuthority/marcAuthority';
import MarcAuthorities from '../../../../../support/fragments/marcAuthority/marcAuthorities';

Expand Down Expand Up @@ -83,44 +81,34 @@ describe('MARC', () => {
})
.then(() => {
cy.resetTenant();
cy.loginAsAdmin().then(() => {
marcFiles.forEach((marcFile) => {
cy.visit(TopMenu.dataImportPath);
if (marcFile.tenant === 'University') {
ConsortiumManager.switchActiveAffiliation(
tenantNames.central,
tenantNames.university,
);
} else if (marcFile.tenant === 'College') {
ConsortiumManager.switchActiveAffiliation(
tenantNames.university,
tenantNames.college,
);
}
DataImport.verifyUploadState();
DataImport.uploadFileAndRetry(marcFile.marc, marcFile.fileNameImported);
JobProfiles.waitLoadingList();
JobProfiles.search(marcFile.jobProfileToRun);
JobProfiles.runImportFile();
Logs.waitFileIsImported(marcFile.fileNameImported);
Logs.checkJobStatus(marcFile.fileNameImported, JOB_STATUS_NAMES.COMPLETED);
Logs.openFileDetails(marcFile.fileNameImported);
Logs.getCreatedItemsID().then((link) => {
createdRecordIDs.push(link.split('/')[5]);
marcFiles.forEach((marcFile) => {
if (marcFile.tenant === 'University') {
cy.setTenant(Affiliations.University);
} else if (marcFile.tenant === 'College') {
cy.setTenant(Affiliations.College);
}

DataImport.uploadFileViaApi(
marcFile.marc,
marcFile.fileNameImported,
marcFile.jobProfileToRun,
).then((response) => {
response.forEach((record) => {
createdRecordIDs.push(record.authority.id);
});
});
});

cy.login(users.userProperties.username, users.userProperties.password, {
path: TopMenu.marcAuthorities,
waiter: MarcAuthorities.waitLoading,
}).then(() => {
ConsortiumManager.switchActiveAffiliation(
tenantNames.central,
tenantNames.university,
);
MarcAuthorities.waitLoading();
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.university);
});
cy.login(users.userProperties.username, users.userProperties.password, {
path: TopMenu.marcAuthorities,
waiter: MarcAuthorities.waitLoading,
}).then(() => {
ConsortiumManager.switchActiveAffiliation(
tenantNames.central,
tenantNames.university,
);
MarcAuthorities.waitLoading();
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.university);
});
});
});
Expand Down

0 comments on commit c0e0bd1

Please sign in to comment.