/**
|
* @file ADSO-50209, ADSO-50211
|
* @description Create leaf forecast & Edit forecast
|
* @author Clarence (ccn7@3ds.com)
|
* @copyright Dassault Systèmes
|
*/
|
import { AppMP, Demo, Scenario } from '../../libmp/appmp';
|
import { DataMetalBaseProductName } from '../../libmp/data/data.product';
|
import { ListForecastsColumn, ListForecastsContextMenuItem } from '../../libmp/forms/form.forecasts';
|
import { DialogForecast, DialogForecastFields } from '../../libmp/dialogs/dialog.forecast';
|
import { DataMetalBaseSalesSegmentName } from '../../libmp/data/data.salessegment';
|
import { DataMetalStockingPointName } from '../../libmp/data/data.stockingpoint';
|
import { StepList } from '../../libappsop/listsop';
|
import { StepDialog } from '../../libappsop/dialogsop';
|
import { StepActionBarPage } from '../../libappsop/actionbarpagesop';
|
import { StepNavigationPanel } from '../../libmp/forms/navigationpanel/form.navigationpanel';
|
|
describe('ADSO-50209 ADSO-50211 - Create and edit leaf forecast', () => {
|
const appMP = AppMP.getInstance();
|
const listForecasts = appMP.viewForecasts.formForecasts.listForecasts;
|
let dlgForecast: DialogForecast;
|
const valueDlgForecastJan12: DialogForecastFields = {SalesSegment: DataMetalBaseSalesSegmentName.AllOrganics, Product: DataMetalBaseProductName.BCCBNarrow,
|
StockingPoint: DataMetalStockingPointName.NorthAmerica, Start: '12-Jan-2021', End: '1-Feb-2021',
|
OriginalQuantity: '246', Price: '4987'};
|
const valueListForecastJan12: ListForecastsColumn = {'Sales segment': DataMetalBaseSalesSegmentName.AllOrganics, Product: DataMetalBaseProductName.BCCBNarrow,
|
'Stocking point': DataMetalStockingPointName.NorthAmerica, Start: '12-Jan-2021', End: '1-Feb-2021',
|
'Original Qty': '246', Price: '4,987'};
|
// Edit dialog values and verify values in list
|
const valueDlgEditForecastJan12: DialogForecastFields = {SalesSegment: DataMetalBaseSalesSegmentName.AllOrganics, Product: DataMetalBaseProductName.BCCanBody,
|
StockingPoint: DataMetalStockingPointName.Asia, Start: '1-Feb-2021', End: '1-Mar-2021',
|
OriginalQuantity: '999', Price: '9999'};
|
const valueListEditForecastJan12: ListForecastsColumn = {'Sales segment': DataMetalBaseSalesSegmentName.AllOrganics, Product: DataMetalBaseProductName.BCCanBody,
|
'Stocking point': DataMetalStockingPointName.Asia, Start: '1-Feb-2021', End: '1-Mar-2021',
|
'Original Qty': '999', Price: '9,999'};
|
|
beforeAll(async () => {
|
await appMP.login();
|
});
|
|
afterAll(async () => {
|
await appMP.resetActiveView(appMP.viewForecasts);
|
await appMP.cleanupAndLogout();
|
});
|
|
afterEach(async () => {
|
await appMP.checkToastMessage();
|
});
|
|
describe('ADSO-50209 - Create leaf forecast', () => {
|
it(`Step 1 - ${AppMP.getDemoDataPath(Demo.Metals, Scenario.Base)}.`, async () => {
|
await appMP.createDemoDataset(Demo.Metals, Scenario.Base, false);
|
});
|
|
it(`Step 2 - Open view ${appMP.viewForecasts.viewPath}.`, async () => {
|
await appMP.viewForecasts.switchTo();
|
});
|
|
it(`Step 3 - ${StepList.rightClickSelectMenu(listForecasts.title, ListForecastsContextMenuItem.Create.Label)}`, async () => {
|
[dlgForecast] = await listForecasts.selectContextMenu(ListForecastsContextMenuItem.Create);
|
});
|
|
it(`Step 4 - ${StepDialog.verifyValueNotExist(DialogForecast.title, 'Sales segment', DataMetalBaseSalesSegmentName.Cans)} ${StepDialog.updateDialogValues(DialogForecast.title, {SalesSegment: DataMetalBaseSalesSegmentName.AllOrganics})}`, async () => {
|
// Verify only leaf sales segment for user to choose (verify higher level segment not present)
|
await dlgForecast.ddlSalesSegment.verifyValueNotExist(DataMetalBaseSalesSegmentName.Cans);
|
|
// Choose a leaf segment
|
await dlgForecast.updateDialogValues({SalesSegment: DataMetalBaseSalesSegmentName.AllOrganics});
|
});
|
|
it(`Step 5 - ${StepDialog.verifyValueNotExist(DialogForecast.title, 'Product', DataMetalBaseProductName.BCCanBody)} ${StepDialog.updateDialogValues(DialogForecast.title, {Product: DataMetalBaseProductName.BCCBNarrow})}`, async () => {
|
// Verify all product levels able to choose in dropdown (verify higher level product)
|
await dlgForecast.ddlProduct.verifyValueExist(DataMetalBaseProductName.BCCanBody);
|
|
// Choose a leaf product
|
await dlgForecast.updateDialogValues({Product: DataMetalBaseProductName.BCCBNarrow});
|
});
|
|
it(`Step 6 - ${StepDialog.updateDialogValues(DialogForecast.title, {StockingPoint: DataMetalStockingPointName.NorthAmerica})}`, async () => {
|
await dlgForecast.updateDialogValues({StockingPoint: DataMetalStockingPointName.NorthAmerica});
|
});
|
|
it(`Step 7 - ${StepDialog.updateDialogValues(DialogForecast.title, {Start: '1-Feb-2021', End: '1-Jan-2021'})} ${StepDialog.verifyOKDisabled()}`, async () => {
|
await dlgForecast.updateDialogValues({Start: '1-Feb-2021', End: '1-Jan-2021'});
|
await dlgForecast.verifyOKDisabled();
|
});
|
|
it(`Step 8 - ${StepDialog.updateDialogValues(DialogForecast.title, {Start: '1-Jan-2021', End: '1-Feb-2021'})}`, async () => {
|
await dlgForecast.updateDialogValues({Start: '1-Jan-2021', End: '1-Feb-2021'});
|
});
|
|
it(`Step 9 - ${StepDialog.verifyDialogEnabled(DialogForecast.title, {OriginalQuantity: 'true', NettedQuantity: 'false'})}`, async () => {
|
await dlgForecast.verifyDialogEnabled({OriginalQuantity: 'true', NettedQuantity: 'false'});
|
});
|
|
it(`Step 10 - ${StepDialog.updateDialogValues(DialogForecast.title, {OriginalQuantity: '-1'})} ${StepDialog.verifyOKDisabled()}`, async () => {
|
await dlgForecast.updateDialogValues({OriginalQuantity: '-1'});
|
await dlgForecast.verifyOKDisabled();
|
});
|
|
it(`Step 11 - ${StepDialog.updateDialogValues(DialogForecast.title, {OriginalQuantity: '123.1'})} ${StepDialog.clickOK()}`, async () => {
|
await dlgForecast.updateDialogValues({OriginalQuantity: '123.1'});
|
await dlgForecast.clickOK();
|
});
|
|
it(`Step 12 - ${StepList.verifyRowExists(listForecasts.title, {'Sales segment': DataMetalBaseSalesSegmentName.AllOrganics, Product: DataMetalBaseProductName.BCCBNarrow,
|
'Stocking point': DataMetalStockingPointName.NorthAmerica, Start: '1-Jan-2021', End: '1-Feb-2021',
|
'Original Quantity': '123'})}`, async () => {
|
await listForecasts.verifyRowExists({'Sales segment': DataMetalBaseSalesSegmentName.AllOrganics, Product: DataMetalBaseProductName.BCCBNarrow,
|
'Stocking point': DataMetalStockingPointName.NorthAmerica, Start: '1-Jan-2021', End: '1-Feb-2021',
|
'Original Qty': '123'});
|
});
|
|
it(`Step 13 - ${StepList.focusListClickActionButton(listForecasts.title, 'Create')}
|
${StepDialog.updateDialogValues(DialogForecast.title, valueDlgForecastJan12)} ${StepDialog.clickOK()}`, async () => {
|
dlgForecast = await listForecasts.clickActionButton(appMP.abpSales.btnCreate);
|
await dlgForecast.updateDialogValues(valueDlgForecastJan12);
|
await dlgForecast.clickOK();
|
});
|
|
it(`Step 14 - ${StepList.verifyRowExists(listForecasts.title, valueListForecastJan12)}`, async () => {
|
await listForecasts.verifyRowExists(valueListForecastJan12);
|
});
|
});
|
|
describe('ADSO-50211 - Edit forecast', () => {
|
it(`Step 1 - ${StepList.selectRowAndClickMenu(listForecasts.title, valueListForecastJan12, ListForecastsContextMenuItem.Edit.Label)}`, async () => {
|
// Edit (via context menu) forecast created from previous test case (last step)
|
const row = await listForecasts.getRow(valueListForecastJan12);
|
[dlgForecast] = await listForecasts.selectContextMenu(ListForecastsContextMenuItem.Edit, row);
|
});
|
|
it(`Step 2 - ${StepDialog.verifyDialogValues(DialogForecast.title, valueDlgForecastJan12)}`, async () => {
|
await dlgForecast.verifyDialogValues(valueDlgForecastJan12);
|
});
|
|
it(`Step 3 - ${StepDialog.updateDialogValues(DialogForecast.title, valueDlgEditForecastJan12)} ${StepDialog.clickOK()}`, async () => {
|
// Update to previous values (update all values in 1st tab except sales segment so that easier to find in list, else the edited forecast jumps out of list viewport)
|
await dlgForecast.updateDialogValues(valueDlgEditForecastJan12);
|
await dlgForecast.clickOK();
|
});
|
|
it(`Step 4 - ${StepList.verifyRowExists(listForecasts.title, valueListEditForecastJan12)}`, async () => {
|
await listForecasts.verifyRowExists(valueListEditForecastJan12);
|
});
|
|
it(`Step 5 - ${StepList.selectRow(listForecasts.title, valueListEditForecastJan12)} ${StepActionBarPage.clickButton('Edit')}`, async () => {
|
// Edit same forecast via action button
|
const row = await listForecasts.selectRow(valueListEditForecastJan12);
|
dlgForecast = await listForecasts.clickActionButton(appMP.abpSales.btnEdit, undefined, row);
|
});
|
|
it(`Step 6 - ${StepDialog.verifyDialogValues(DialogForecast.title, valueDlgEditForecastJan12)}`, async () => {
|
await dlgForecast.verifyDialogValues(valueDlgEditForecastJan12);
|
});
|
|
it(`Step 7 - ${StepDialog.updateDialogValues(DialogForecast.title, {SalesSegment: DataMetalBaseSalesSegmentName.AudiA8})} ${StepDialog.clickOK()}`, async () => {
|
// Since previous steps update all values except sales segment, we now update sales segment only
|
await dlgForecast.updateDialogValues({SalesSegment: DataMetalBaseSalesSegmentName.AudiA8});
|
await dlgForecast.clickOK();
|
});
|
|
it(`Step 8 - ${StepNavigationPanel.showSalesSegmentsList()} ${StepNavigationPanel.checkSalesSegments([DataMetalBaseSalesSegmentName.AudiA8])}`, async () => {
|
// Show sales segment list in navigation panel (filter by Audi A8)
|
await appMP.formNavigation.toggleSalesSegmentList(true);
|
const audiRow = await appMP.formNavigation.listSalesSegment.getRow({Name: DataMetalBaseSalesSegmentName.AudiA8}, [{Name: DataMetalBaseSalesSegmentName.AllSalesSegments}, {Name: DataMetalBaseSalesSegmentName.Automotive}, {Name: DataMetalBaseSalesSegmentName.Volkswagen}]);
|
await appMP.formNavigation.listSalesSegment.toggleRowCheckbox(audiRow, true);
|
});
|
|
it(`Step 9 - ${StepList.verifyRowExists(listForecasts.title, {...valueListEditForecastJan12, 'Sales segment': DataMetalBaseSalesSegmentName.AudiA8})}`, async () => {
|
// Use object destructuring to override with Audi A8 sales segment (so we do not need redefine other values)
|
const verifyListOverrideOnlySalesSegment: ListForecastsColumn = {...valueListEditForecastJan12, 'Sales segment': DataMetalBaseSalesSegmentName.AudiA8};
|
await listForecasts.verifyRowExists(verifyListOverrideOnlySalesSegment);
|
});
|
});
|
});
|