From 36ef8db7e407e7a3f597bd3dfa5fc49f9ed97d1e Mon Sep 17 00:00:00 2001 From: Tetiana_Paranich Date: Fri, 27 Dec 2024 10:35:52 +0200 Subject: [PATCH] fixed tests --- ...gs-accordion-shared-instance-central.cy.js | 4 +- ...instance-on-member-with-source-folio.cy.js | 81 +++++++++++++++++++ ...instance-on-member-with-source-marc.cy.js} | 64 ++++----------- 3 files changed, 97 insertions(+), 52 deletions(-) create mode 100644 cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-folio.cy.js rename cypress/e2e/consortia/inventory/instance/{duplicating-local-instance-on-member-with-source-marc-folio.cy.js => duplicating-local-instance-on-member-with-source-marc.cy.js} (58%) diff --git a/cypress/e2e/consortia/inventory/instance/consortial-holdings-accordion-shared-instance-central.cy.js b/cypress/e2e/consortia/inventory/instance/consortial-holdings-accordion-shared-instance-central.cy.js index c31f08f4af..6deaf03db5 100644 --- a/cypress/e2e/consortia/inventory/instance/consortial-holdings-accordion-shared-instance-central.cy.js +++ b/cypress/e2e/consortia/inventory/instance/consortial-holdings-accordion-shared-instance-central.cy.js @@ -212,12 +212,12 @@ describe('Inventory', () => { InventoryInstance.expandMemberSubHoldings(Affiliations.College); InventoryInstance.verifyMemberSubSubHoldingsAccordion( Affiliations.College, - testData.collegeHoldingsId, + testData.collegeHolding.id, ); InventoryInstance.expandMemberSubHoldings(Affiliations.University); InventoryInstance.verifyMemberSubSubHoldingsAccordion( Affiliations.University, - testData.universityHoldingsId, + testData.universityHolding.id, ); }, ); diff --git a/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-folio.cy.js b/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-folio.cy.js new file mode 100644 index 0000000000..6e1a92a00e --- /dev/null +++ b/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-folio.cy.js @@ -0,0 +1,81 @@ +import { INSTANCE_SOURCE_NAMES } from '../../../../support/constants'; +import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations'; +import Permissions from '../../../../support/dictionary/permissions'; +import InstanceRecordView from '../../../../support/fragments/inventory/instanceRecordView'; +import InventoryInstance from '../../../../support/fragments/inventory/inventoryInstance'; +import InventoryInstances from '../../../../support/fragments/inventory/inventoryInstances'; +import InventoryNewInstance from '../../../../support/fragments/inventory/inventoryNewInstance'; +import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager'; +import TopMenu from '../../../../support/fragments/topMenu'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; + +describe('Inventory', () => { + describe('Instance', () => { + const testData = { + newResourceTitle: `C410923 instanceTitle${getRandomPostfix()}`, + newResourceType: 'notated movement', + source: INSTANCE_SOURCE_NAMES.FOLIO, + }; + + before('Create test data', () => { + cy.clearCookies({ domain: null }); + cy.getAdminToken(); + cy.setTenant(Affiliations.College); + InventoryInstance.createInstanceViaApi().then(({ instanceData }) => { + testData.instance = instanceData; + }); + + cy.resetTenant(); + cy.createTempUser([Permissions.inventoryAll.gui]).then((userProperties) => { + testData.user = userProperties; + + cy.assignAffiliationToUser(Affiliations.College, testData.user.userId); + cy.setTenant(Affiliations.College); + cy.assignPermissionsToExistingUser(testData.user.userId, [Permissions.inventoryAll.gui]); + }); + }); + + after('Delete test data', () => { + cy.resetTenant(); + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + cy.setTenant(Affiliations.College); + InventoryInstance.deleteInstanceViaApi(testData.instance.instanceId); + cy.getInstance({ + limit: 1, + expandAll: true, + query: `"hrid"=="${testData.instanceHrid}"`, + }).then((instance) => { + InventoryInstance.deleteInstanceViaApi(instance.id); + }); + }); + + it( + 'C410923 (CONSORTIA) Duplicating local instance on Member tenant with Source FOLIO (folijet)', + { tags: ['extendedPathECS', 'folijet', 'C410923'] }, + () => { + cy.login(testData.user.username, testData.user.password, { + path: TopMenu.inventoryPath, + waiter: InventoryInstances.waitContentLoading, + }); + ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college); + ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college); + InventoryInstances.searchByTitle(testData.instance.instanceId); + InventoryInstances.selectInstance(); + InventoryInstance.waitLoading(); + InstanceRecordView.duplicate(); + InventoryNewInstance.fillResourceTitle(testData.newResourceTitle); + InventoryNewInstance.fillResourceType(testData.newResourceType); + InventoryNewInstance.clickSaveAndCloseButton(); + InventoryInstance.waitInstanceRecordViewOpened(testData.newResourceTitle); + InventoryInstance.checkInstanceDetails({ + instanceInformation: [{ key: 'Source', value: testData.source }], + }); + InventoryInstance.getAssignedHRID().then((initialInstanceHrId) => { + testData.instanceHrid = initialInstanceHrId; + }); + }, + ); + }); +}); diff --git a/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-marc-folio.cy.js b/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-marc.cy.js similarity index 58% rename from cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-marc-folio.cy.js rename to cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-marc.cy.js index 7979fc3b11..284ae5fa9e 100644 --- a/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-marc-folio.cy.js +++ b/cypress/e2e/consortia/inventory/instance/duplicating-local-instance-on-member-with-source-marc.cy.js @@ -18,8 +18,7 @@ describe('Inventory', () => { marcFileName: `C410924 marcFileName${getRandomPostfix()}.mrc`, }; const testData = { - newResourceTitleC410923: `C410923 instanceTitle${getRandomPostfix()}`, - newResourceTitleC410924: `C410924 instanceTitle${getRandomPostfix()}`, + newResourceTitle: `C410924 instanceTitle${getRandomPostfix()}`, newResourceType: 'notated movement', source: INSTANCE_SOURCE_NAMES.FOLIO, }; @@ -28,15 +27,12 @@ describe('Inventory', () => { cy.clearCookies({ domain: null }); cy.getAdminToken(); cy.setTenant(Affiliations.College); - InventoryInstance.createInstanceViaApi().then(({ instanceData }) => { - testData.instanceC410923 = instanceData; - }); DataImport.uploadFileViaApi( marcFile.marc, marcFile.marcFileName, DEFAULT_JOB_PROFILE_NAMES.CREATE_INSTANCE_AND_SRS, ).then((response) => { - testData.instanceC410924 = response[0].instance; + testData.instance = response[0].instance; }); cy.resetTenant(); @@ -49,76 +45,44 @@ describe('Inventory', () => { }); }); - beforeEach('Login', () => { - cy.login(testData.user.username, testData.user.password, { - path: TopMenu.inventoryPath, - waiter: InventoryInstances.waitContentLoading, - }); - ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college); - ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college); - }); - after('Delete test data', () => { cy.resetTenant(); cy.getAdminToken(); Users.deleteViaApi(testData.user.userId); cy.setTenant(Affiliations.College); - InventoryInstance.deleteInstanceViaApi(testData.instanceC410923.instanceId); - InventoryInstance.deleteInstanceViaApi(testData.instanceC410924.id); + InventoryInstance.deleteInstanceViaApi(testData.instance.id); cy.getInstance({ limit: 1, expandAll: true, - query: `"hrid"=="${testData.instanceC410923Hrid}"`, - }).then((instance) => { - InventoryInstance.deleteInstanceViaApi(instance.id); - }); - cy.getInstance({ - limit: 1, - expandAll: true, - query: `"hrid"=="${testData.instanceC410924Hrid}"`, + query: `"hrid"=="${testData.instanceHrid}"`, }).then((instance) => { InventoryInstance.deleteInstanceViaApi(instance.id); }); }); - it( - 'C410923 (CONSORTIA) Duplicating local instance on Member tenant with Source FOLIO (folijet)', - { tags: ['extendedPathECS', 'folijet', 'C410923'] }, - () => { - InventoryInstances.searchByTitle(testData.instanceC410923.instanceId); - InventoryInstances.selectInstance(); - InventoryInstance.waitLoading(); - InstanceRecordView.duplicate(); - InventoryNewInstance.fillResourceTitle(testData.newResourceTitleC410923); - InventoryNewInstance.fillResourceType(testData.newResourceType); - InventoryNewInstance.clickSaveAndCloseButton(); - InventoryInstance.waitInstanceRecordViewOpened(testData.newResourceTitleC410923); - InventoryInstance.checkInstanceDetails({ - instanceInformation: [{ key: 'Source', value: testData.source }], - }); - InventoryInstance.getAssignedHRID().then((initialInstanceHrId) => { - testData.instanceC410923Hrid = initialInstanceHrId; - }); - }, - ); - it( 'C410924 (CONSORTIA) Duplicating local instance on Member tenant with Source MARC (folijet)', { tags: ['extendedPathECS', 'folijet', 'C410924'] }, () => { - InventoryInstances.searchByTitle(testData.instanceC410924.id); + cy.login(testData.user.username, testData.user.password, { + path: TopMenu.inventoryPath, + waiter: InventoryInstances.waitContentLoading, + }); + ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college); + ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college); + InventoryInstances.searchByTitle(testData.instance.id); InventoryInstances.selectInstance(); InventoryInstance.waitLoading(); InstanceRecordView.duplicate(); - InventoryNewInstance.fillResourceTitle(testData.newResourceTitleC410924); + InventoryNewInstance.fillResourceTitle(testData.newResourceTitle); InventoryNewInstance.fillResourceType(testData.newResourceType); InventoryNewInstance.clickSaveAndCloseButton(); - InventoryInstance.waitInstanceRecordViewOpened(testData.newResourceTitleC410924); + InventoryInstance.waitInstanceRecordViewOpened(testData.newResourceTitle); InventoryInstance.checkInstanceDetails({ instanceInformation: [{ key: 'Source', value: testData.source }], }); InventoryInstance.getAssignedHRID().then((initialInstanceHrId) => { - testData.instanceC410924Hrid = initialInstanceHrId; + testData.instanceHrid = initialInstanceHrId; }); }, );