Skip to content

Commit

Permalink
Merge branch 'master' into US1340669
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrener-eis committed Dec 18, 2024
2 parents 7d9e683 + 140fff6 commit 0790c21
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import getRandomPostfix from '../../../support/utils/stringTools';
import InstanceRecordEdit from '../../../support/fragments/inventory/instanceRecordEdit';
import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
import TopMenu from '../../../support/fragments/topMenu';
import { INSTANCE_DATE_TYPES } from '../../../support/constants';
import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView';
import Users from '../../../support/fragments/users/users';
import Permissions from '../../../support/dictionary/permissions';

describe('Inventory', () => {
describe('Instance', () => {
const testData = {
instanceTitle: `C552531 Auto ${getRandomPostfix()}`,
date1set: ['1999u', '1', '12', '12b', '12b6', '12b6', '12b6'],
date2set: ['20b27', '9', '199u', '199u', '19', '199', '199u'],
dateType: INSTANCE_DATE_TYPES.RANGE,
};

before('Login', () => {
cy.createTempUser([Permissions.uiInventoryViewCreateEditInstances.gui]).then(
(userProperties) => {
testData.user = userProperties;
InventoryInstance.createInstanceViaApi({ instanceTitle: testData.instanceTitle }).then(
({ instanceData }) => {
testData.instanceId = instanceData.instanceId;
cy.login(testData.user.username, testData.user.password, {
path: TopMenu.inventoryPath,
waiter: InventoryInstances.waitContentLoading,
});
InventoryInstances.searchByTitle(testData.instanceId);
InventoryInstances.selectInstanceById(testData.instanceId);
},
);
},
);
});

after('Delete test data', () => {
cy.getAdminToken();
InventoryInstance.deleteInstanceViaApi(testData.instanceId);
Users.deleteViaApi(testData.user.userId);
});

it(
'C552531 Cannot update Instance with more or less than 4 characters in "Date 1" and "Date 2" fields (spitfire)',
{ tags: ['criticalPath', 'spitfire', 'C552531'] },
() => {
InstanceRecordView.verifyInstancePaneExists();
InstanceRecordView.edit();
InstanceRecordEdit.waitLoading();
InstanceRecordEdit.verifyDateFieldsValues();
InstanceRecordEdit.fillDates(
testData.date1set[0],
testData.date2set[0],
testData.dateType,
true,
);
InstanceRecordEdit.clickSaveAndKeepEditingButton();
InstanceRecordEdit.verifySuccessfulMessage();
InstanceRecordEdit.waitLoading();
InstanceRecordEdit.verifyDateFieldsValues(
testData.date1set[0].slice(0, 4),
testData.date2set[0].slice(0, 4),
testData.dateType,
);

InstanceRecordEdit.fillDates(testData.date1set[1], testData.date2set[1]);
InstanceRecordEdit.clickSaveAndCloseButton();
InstanceRecordEdit.verifyDateFieldsValidationErrors(true, true);

InstanceRecordEdit.fillDates(testData.date1set[2], testData.date2set[2]);
InstanceRecordEdit.clickSaveAndCloseButton();
InstanceRecordEdit.verifyDateFieldsValidationErrors(true, false);

InstanceRecordEdit.fillDates(testData.date1set[3], testData.date2set[3]);
InstanceRecordEdit.clickSaveAndCloseButton();
InstanceRecordEdit.verifyDateFieldsValidationErrors(true, false);

InstanceRecordEdit.fillDates(testData.date1set[4], testData.date2set[4]);
InstanceRecordEdit.clickSaveAndCloseButton();
InstanceRecordEdit.verifyDateFieldsValidationErrors(false, true);

InstanceRecordEdit.fillDates(testData.date1set[5], testData.date2set[5]);
InstanceRecordEdit.clickSaveAndCloseButton();
InstanceRecordEdit.verifyDateFieldsValidationErrors(false, true);

InstanceRecordEdit.fillDates(testData.date1set[6], testData.date2set[6]);
InstanceRecordEdit.saveAndClose();
InstanceRecordEdit.verifySuccessfulMessage();
InstanceRecordView.verifyInstanceIsOpened(testData.instanceTitle);
InstanceRecordView.verifyDates(
testData.date1set[6],
testData.date2set[6],
testData.dateType,
);
},
);
});
});
60 changes: 60 additions & 0 deletions cypress/e2e/inventory/instance/edit-instance-no-date2.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import getRandomPostfix from '../../../support/utils/stringTools';
import InstanceRecordEdit from '../../../support/fragments/inventory/instanceRecordEdit';
import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance';
import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances';
import TopMenu from '../../../support/fragments/topMenu';
import { INSTANCE_DATE_TYPES } from '../../../support/constants';
import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView';
import Users from '../../../support/fragments/users/users';
import Permissions from '../../../support/dictionary/permissions';

describe('Inventory', () => {
describe('Instance', () => {
const testData = {
instanceTitle: `C552528 Auto ${getRandomPostfix()}`,
date1: '0981',
dateType: INSTANCE_DATE_TYPES.QUESTIONABLE,
};

before('Login', () => {
cy.createTempUser([Permissions.uiInventoryViewCreateEditInstances.gui]).then(
(userProperties) => {
testData.user = userProperties;
InventoryInstance.createInstanceViaApi({ instanceTitle: testData.instanceTitle }).then(
({ instanceData }) => {
testData.instanceId = instanceData.instanceId;
cy.login(testData.user.username, testData.user.password, {
path: TopMenu.inventoryPath,
waiter: InventoryInstances.waitContentLoading,
});
InventoryInstances.searchByTitle(testData.instanceId);
InventoryInstances.selectInstanceById(testData.instanceId);
},
);
},
);
});

after('Delete test data', () => {
cy.getAdminToken();
InventoryInstance.deleteInstanceViaApi(testData.instanceId);
Users.deleteViaApi(testData.user.userId);
});

it(
'C552528 Edit Instance with selected "Date type" and field "Date 1" filled only (spitfire)',
{ tags: ['criticalPath', 'spitfire', 'C552528'] },
() => {
InstanceRecordView.verifyInstancePaneExists();
InstanceRecordView.edit();
InstanceRecordEdit.waitLoading();
InstanceRecordEdit.verifyDateFieldsValues();
InstanceRecordEdit.fillDates(testData.date1, undefined, testData.dateType);
InstanceRecordEdit.saveAndClose();
InstanceRecordEdit.verifySuccessfulMessage();
InstanceRecordView.verifyInstanceIsOpened(testData.instanceTitle);
InstanceRecordView.verifyDates(testData.date1, undefined, testData.dateType);
},
);
});
});
7 changes: 7 additions & 0 deletions cypress/support/fragments/inventory/instanceRecordEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const date1Field = descriptiveDataAccordion.find(TextField({ name: 'dates.date1'
const date2Field = descriptiveDataAccordion.find(TextField({ name: 'dates.date2' }));
const dateTypePlaceholderOption = 'Select date type';
const dateValueLengthErrorText = 'Date must contain four characters.';
const saveAndKeepEditing = Button('Save & keep editing');

const checkboxes = {
'Suppress from discovery': supressFromDiscoveryCheckbox,
Expand Down Expand Up @@ -295,6 +296,7 @@ export default {
InteractorsTools.checkCalloutMessage(
matching(new RegExp(InstanceStates.instanceSavedSuccessfully)),
);
InteractorsTools.dismissCallout(matching(new RegExp(InstanceStates.instanceSavedSuccessfully)));
},
checkCheckboxConditions(fields = []) {
fields.forEach(({ label, conditions }) => {
Expand Down Expand Up @@ -476,4 +478,9 @@ export default {
);
} else cy.expect(date2Field.has({ errorBorder: false, error: undefined }));
},

clickSaveAndKeepEditingButton(saved = true) {
cy.do(saveAndKeepEditing.click());
if (saved) cy.expect(saveAndKeepEditing.has({ disabled: true }));
},
};

0 comments on commit 0790c21

Please sign in to comment.