/**
|
* @file ADSO-48768 - Define campaign type Quantity constraints
|
* @description Create campaign type in quantity constraint
|
* @testCategory Web app - Campaigns
|
* @author Zan Sen (zansen.tai@3ds.com)
|
* @copyright Dassault Systèmes
|
*/
|
|
import { AppMP, Demo, Scenario, Timeout } from '../../libmp/appmp';
|
import { qCustomMatcher } from '../../e2elib/lib/src/main/qmatchers.const';
|
import { DataMetalBaseEntityName } from '../../libmp/data/data.unit';
|
import { DialogCampaignType } from '../../libmp/dialogs/dialog.campaigntype';
|
import { ListCampaignTypeContextMenuItem } from '../../libmp/forms/form.campaigntypes';
|
import { DataMetalBaseCampaignType, DataRadioGroupButtonSelection } from '../../libmp/data/data.campaign';
|
import { DurationInputHelper } from '../../libappsop/durationselectorsop';
|
|
describe('ADSO-48768 Define campaign type Quantity constraints', () => {
|
const appMP = AppMP.getInstance();
|
const formNavigation = appMP.formNavigation;
|
const viewCampaignsAndTransitions = appMP.viewCampaignsAndTransitions;
|
const formCampaignTypes = viewCampaignsAndTransitions.formCampaignTypes;
|
const listCampaignType = formCampaignTypes.listCampaignType;
|
|
const campaignName = 'Test';
|
const existingCampaignName = DataMetalBaseCampaignType.Campaignfor5XXXsmelt;
|
const quantity = DataRadioGroupButtonSelection.Quantity;
|
const duration = DataRadioGroupButtonSelection.Duration;
|
const meltingfurnaceQuilmes = DataMetalBaseEntityName.MeltingFurnaceQuilmes;
|
|
let dlgCampaignType: DialogCampaignType;
|
|
beforeAll(async () => {
|
// Deprecated: to be replaced with QJasmine.initGlobal(true)
|
jasmine.addMatchers(qCustomMatcher);
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
// Reset views
|
await formNavigation.reset();
|
await viewCampaignsAndTransitions.reset();
|
await appMP.cleanupAndLogout();
|
});
|
|
afterEach(async () => {
|
await appMP.checkToastMessage();
|
});
|
|
it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}`, async () => {
|
await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
|
});
|
|
it(`Step 2 - Open view ${viewCampaignsAndTransitions.viewPath}`, async () => {
|
await viewCampaignsAndTransitions.switchTo();
|
});
|
|
it(`Step 3 - On Campaign types list, right click and select Create.
|
Verify dialog by default selected radio button = quantity, min qty = 0 and max quantity disabled.
|
Verify OK button disabled as Name is empty`, async () => {
|
[dlgCampaignType] = await listCampaignType.selectContextMenu(ListCampaignTypeContextMenuItem.Create);
|
await dlgCampaignType.verifyDialogValues({ QuantityOrDuration: quantity, MinQuantity: '0' });
|
await dlgCampaignType.verifyDialogEnabled({ MaxQuantity: 'false' });
|
await dlgCampaignType.verifyOKDisabled();
|
});
|
|
it('Step 4 - Hover min and max quantity and verify tooltip display', async () => {
|
await dlgCampaignType.hoverElementVerifyTooltip({
|
MinQuantity: 'Default minimum quantity to be produced during the campaign.',
|
MaxQuantity: 'Default maximum quantity to be produced during the campaign.',
|
});
|
});
|
|
it(`Step 5 - Select unit ${meltingfurnaceQuilmes}, Campaign type Name = ${existingCampaignName} and set min quantity = 1000.
|
Verify OK button is disabled as campaign type name must be unique`, async () => {
|
await dlgCampaignType.updateDialogValues({ Unit: meltingfurnaceQuilmes, Name: existingCampaignName, MinQuantity: '1000' });
|
await dlgCampaignType.verifyOKDisabled();
|
});
|
|
it(`Step 6 - Enter Campaign type Name = ${campaignName} and set min quantity = negative number. Verify OK button is disabled as min quantity must be greater than 0`, async () => {
|
await dlgCampaignType.updateDialogValues({ Name: campaignName, MinQuantity: '-5' });
|
await dlgCampaignType.verifyOKDisabled();
|
});
|
|
it('Step 7 - Enter as Minimum ton: 75, verify OK button is enabled', async () => {
|
await dlgCampaignType.updateDialogValues({ MinQuantity: '75' });
|
await dlgCampaignType.verifyOKEnabled();
|
});
|
|
it('Step 8 - Click Enable to enable max quantity, verify OK button is disabled as maximum quantity must be greater than 0', async () => {
|
await dlgCampaignType.updateDialogValues({ MaxQuantity: '0' });
|
await dlgCampaignType.verifyOKDisabled();
|
});
|
|
it('Step 9 - Enter maximum quantity = 50, verify OK button is disabled as maximum must be greater than or equal to minimum', async () => {
|
await dlgCampaignType.updateDialogValues({ MaxQuantity: '50' });
|
await dlgCampaignType.verifyOKDisabled();
|
});
|
|
it(`Step 10 - Change the maximum quantity to 150, verify OK button is enabled, hit OK.
|
Verify campaign type created correctly in list and has constraint violation as no operation assigned yet`, async () => {
|
await dlgCampaignType.updateDialogValues({ MaxQuantity: '150' });
|
await dlgCampaignType.verifyOKEnabled();
|
await dlgCampaignType.clickOK(Timeout.ButtonState);
|
|
const row = await listCampaignType.getRow({ Unit: meltingfurnaceQuilmes, Name: campaignName });
|
await listCampaignType.verifyRowValues(row, { 'Default Min': '75 Ton', 'Default Max': '150 Ton' });
|
await listCampaignType.verifyRowHasConstraintViolation(row);
|
});
|
|
it(`Step 11 - On row Campaign type [${campaignName}], right-click and click Edit. Verify dialog populated with name = ${campaignName}, radiobutton = ${quantity}, min qty = 75, max qty = 150 `, async () => {
|
const testCampaignTypeRow = await listCampaignType.getRow({ Name: campaignName });
|
[dlgCampaignType] = await listCampaignType.selectContextMenu(ListCampaignTypeContextMenuItem.Edit, testCampaignTypeRow);
|
await dlgCampaignType.verifyDialogValues({ QuantityOrDuration: quantity, MinQuantity: '75', MaxQuantity: '150' });
|
});
|
|
it('Step 12 - Select Duration radio button and verify min duration = 0 and max duration disabled. Verify OK disabled as min duration must be greater than 0', async () => {
|
await dlgCampaignType.updateDialogValues({ QuantityOrDuration: duration });
|
|
// Verify dialog now changed to duration UI
|
await dlgCampaignType.verifyDialogEnabled({ MaxDuration: 'false' });
|
await dlgCampaignType.verifyDialogValues({ Unit: meltingfurnaceQuilmes, Name: campaignName, QuantityOrDuration: duration, MinDuration: '0' });
|
await dlgCampaignType.verifyOKDisabled();
|
});
|
|
it('Step 13 - Edit default min duration = 1 day. Verify Ok button is enabled', async () => {
|
await dlgCampaignType.updateDialogValues({ MinDuration: DurationInputHelper.getDurationString({Days: 1}) });
|
await dlgCampaignType.verifyOKEnabled();
|
});
|
|
it('Step 14 - Enable maximum duration by clicking Enable and enter 2 days and hit OK. Verify list row updated to show min = 1 day and max = 2 days', async () => {
|
await dlgCampaignType.updateDialogValues({ MaxDuration: DurationInputHelper.getDurationString({Days: 2}) });
|
await dlgCampaignType.verifyOKEnabled();
|
await dlgCampaignType.clickOK(Timeout.ButtonState);
|
|
const row = await listCampaignType.getRow({ Unit: meltingfurnaceQuilmes, Name: campaignName });
|
await listCampaignType.verifyRowValues(row, { 'Default Min': '1 day', 'Default Max': '2 days' });
|
});
|
});
|