Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing of FAT-10862 #3079

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import Permissions from '../../../support/dictionary/permissions';
import Affiliations, { tenantNames } from '../../../support/dictionary/affiliations';
import Users from '../../../support/fragments/users/users';
import TopMenu from '../../../support/fragments/topMenu';
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
import ConsortiumManager from '../../../support/fragments/settings/consortium-manager/consortium-manager';
import getRandomPostfix from '../../../support/utils/stringTools';
import ServicePoints from '../../../support/fragments/settings/tenant/servicePoints/servicePoints';
import { NewOrder, Orders } from '../../../support/fragments/orders';
import { NewOrganization, Organizations } from '../../../support/fragments/organizations';
import OrderLines from '../../../support/fragments/orders/orderLines';
import NewLocation from '../../../support/fragments/settings/tenant/locations/newLocation';

describe('Orders -> Consortium (Orders)', () => {
describe('Orders', () => {
describe('Consortia', () => {
const randomPostfix = getRandomPostfix();
const instancePrefix = `C422238 Instance ${randomPostfix}`;
const subjectPrefix = `C422238 Subject ${randomPostfix}`;
const testData = {
collegeHoldings: [],
universityHoldings: [],
sharedInstance: {
title: `${instancePrefix} Shared`,
subjects: [{ value: `${subjectPrefix} 1` }, { value: `${subjectPrefix} 2` }],
},
sharedAccordionName: 'Shared',
subjectBrowseoption: 'Subjects',
organization: NewOrganization.getDefaultOrganization(),
order: {},
user: {},
};
let location;
let servicePointId;
let instanceHRID;

before('Create user, data', () => {
cy.getAdminToken();
cy.createTempUser([Permissions.uiInventoryViewInstances.gui])
.then((userProperties) => {
testData.userProperties = userProperties;

cy.assignAffiliationToUser(Affiliations.College, testData.userProperties.userId);
cy.setTenant(Affiliations.College);
cy.assignPermissionsToExistingUser(testData.userProperties.userId, [
Permissions.uiInventoryViewInstances.gui,
Permissions.uiOrdersApprovePurchaseOrders.gui,
Permissions.uiOrdersCreate.gui,
]);
ServicePoints.getViaApi().then((servicePoint) => {
servicePointId = servicePoint[0].id;
NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then(
(res) => {
location = res;
},
);
});
Organizations.createOrganizationViaApi(testData.organization).then(() => {
testData.order = NewOrder.getDefaultOngoingOrder({
vendorId: testData.organization.id,
});

Orders.createOrderViaApi(testData.order).then((orderResponse) => {
testData.order = orderResponse;
});
});
})
.then(() => {
cy.resetTenant();
InventoryInstance.createInstanceViaApi({
instanceTitle: testData.sharedInstance.title,
}).then((instanceData) => {
testData.sharedInstance.id = instanceData.instanceData.instanceId;
cy.getInstanceHRID(instanceData.instanceData.instanceId).then(
(instanceHRIDResponse) => {
instanceHRID = instanceHRIDResponse;
},
);
});

cy.login(testData.userProperties.username, testData.userProperties.password, {
path: TopMenu.inventoryPath,
waiter: InventoryInstances.waitContentLoading,
}).then(() => {
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.central);
ConsortiumManager.switchActiveAffiliation(tenantNames.college);
InventoryInstances.waitContentLoading();
ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college);
cy.visit(TopMenu.ordersPath);
});
});
});

after('Delete user, data', () => {
cy.resetTenant();
cy.getAdminToken();
Users.deleteViaApi(testData.userProperties.userId);
cy.setTenant(Affiliations.College);
Orders.updateOrderViaApi({ ...testData.order, workflowStatus: 'Pending' });
Orders.deleteOrderViaApi(testData.order.id);
Organizations.deleteOrganizationViaApi(testData.organization.id);
NewLocation.deleteViaApiIncludingInstitutionCampusLibrary(
location.institutionId,
location.campusId,
location.libraryId,
location.id,
);
cy.resetTenant();
InventoryInstance.deleteInstanceViaApi(testData.sharedInstance.id);
});

it(
'C411665: Shared instance can be created for linked instance record when order line is connected to "Shared instance" (Member tenant) (consortia) (thunderjet)',
{ tags: ['criticalPathECS', 'thunderjet'] },
() => {
Orders.searchByParameter('PO number', testData.order.poNumber);
Orders.selectFromResultsList(testData.order.poNumber);
OrderLines.addPOLine();
OrderLines.selectRandomInstanceInTitleLookUP(testData.sharedInstance.title, 0);
OrderLines.fillInPOLineInfoForExportWithLocation('Purchase', location.institutionId);
OrderLines.backToEditingOrder();
Orders.openOrder();
OrderLines.selectPOLInOrder();
OrderLines.openInstanceInPOL(testData.sharedInstance.title);
InventoryInstance.checkInstanceTitle(testData.sharedInstance.title);
InventoryInstance.checkInstanceHrId(instanceHRID);
},
);
});
});
});
3 changes: 3 additions & 0 deletions cypress/support/fragments/inventory/inventoryInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -1417,4 +1417,7 @@ export default {
}
});
},
checkInstanceHrId: (expectedInstanceHrId) => cy.expect(
instanceDetailsSection.find(KeyValue('Instance HRID')).has({ value: expectedInstanceHrId }),
),
};
Loading