Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

Commit

Permalink
Merge pull request #311 from metasfresh/gh291-app
Browse files Browse the repository at this point in the history
#291 Open Picking Terminal and filter for Date, Product and BPartner
  • Loading branch information
TheBestPessimist committed Aug 16, 2019
2 parents 6461282 + bd1b3de commit 2b57991
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 13 deletions.
@@ -0,0 +1,78 @@
/** todo The test is done but is failing due to https://github.com/metasfresh/me03/issues/2381.
* After this issue will be fixed, the test will pass.
* It will need to be moved from integration/defunct dir. */
import { BPartner } from '../../support/utils/bpartner';
import { DiscountSchema } from '../../support/utils/discountschema';
import { Builder } from '../../support/utils/builder';
import { humanReadableNow } from '../../support/utils/utils';
import { SalesOrder, SalesOrderLine } from '../../support/utils/sales_order';
import {
applyFilters,
selectNotFrequentFilterWidget,
selectFrequentFilterWidget,
toggleNotFrequentFilters,
toggleFrequentFilters,
} from '../../support/functions';

describe('Create Sales order, open Picking Terminal and filter for Date, Product and BPartner', function() {
const date = humanReadableNow();
const customer1 = `CustomerTest1 ${date}`;
const productName1 = `ProductTest1 ${date}`;
const productCategoryName = `ProductCategoryName ${date}`;
const discountSchemaName = `DiscountSchemaTest ${date}`;
const priceSystemName = `PriceSystem ${date}`;
const priceListName = `PriceList ${date}`;
const priceListVersionName = `PriceListVersion ${date}`;
const productType = 'Item';

before(function() {
Builder.createBasicPriceEntities(priceSystemName, priceListVersionName, priceListName, true);
Builder.createBasicProductEntities(
productCategoryName,
productCategoryName,
priceListName,
productName1,
productName1,
productType
);
cy.fixture('discount/discountschema.json').then(discountSchemaJson => {
Object.assign(new DiscountSchema(), discountSchemaJson)
.setName(discountSchemaName)
.apply();
});
cy.fixture('sales/simple_customer.json').then(customerJson => {
const bpartner = new BPartner({ ...customerJson, name: customer1 }).setCustomerDiscountSchema(discountSchemaName);
bpartner.apply();
});
});
it('Create the sales order', function() {
new SalesOrder()
.setBPartner(customer1)
.setPriceSystem(priceSystemName)
.addLine(new SalesOrderLine().setProduct(productName1).setQuantity(1))
.apply();
cy.completeDocument();
});
it('Open Picking terminal', function() {
cy.visitWindow('540345');
toggleFrequentFilters();
selectFrequentFilterWidget(true);
cy.get('.ranges')
.find('li')
.first()
.should('contain', 'Today')
.click();
applyFilters();
/**Even though the date selected is today, the filter label will show yesterday's date due to: https://github.com/metasfresh/me03/issues/2381
* that's the reason why the test is failing currently
*/

toggleNotFrequentFilters();
selectNotFrequentFilterWidget('default');
cy.writeIntoLookupListField('M_Product_ID', productName1, productName1, false, false, null, true);
cy.writeIntoLookupListField('C_BPartner_Customer_ID', customer1, customer1, false, false, null, true);
applyFilters();

cy.expectNumberOfRows(2);
});
});
2 changes: 2 additions & 0 deletions cypress/support/commands/form.js
Expand Up @@ -143,6 +143,8 @@ Cypress.Commands.add(
);
/*
* Right now it can only select the current date
* @param {string} fieldName - name of the field
* @param {boolean} modal - use true, if the field is in a modal overlay
*/
Cypress.Commands.add('selectDateViaPicker', (fieldName, modal) => {
const path = createFieldPath(fieldName, modal);
Expand Down
10 changes: 10 additions & 0 deletions cypress/support/commands/navigation.js
Expand Up @@ -107,3 +107,13 @@ Cypress.Commands.add('selectNthRow', (rowNumber, modal = false) => {
Cypress.Commands.add('expectNumberOfRows', numberOfRows => {
return cy.get('table tbody tr').should('have.length', numberOfRows);
});
/**
* Expect the table rows to be greater than a given number
*
* @param numberOfRows - the number of rows
*/
Cypress.Commands.add('expectNumberOfRowsToBeGreaterThan', numberOfRows => {
return cy.get('table tbody tr').should(el => {
expect(el).to.have.length.greaterThan(numberOfRows);
});
});
5 changes: 4 additions & 1 deletion cypress/support/functions/index.js
Expand Up @@ -8,7 +8,10 @@ const toggleNotFrequentFilters = () => {
cy.get('.filter-menu').should('exist');
};

const selectFrequentFilterWidget = () => {
const selectFrequentFilterWidget = isDate => {
if (isDate) {
cy.clickElementWithClass(`.meta-icon-calendar.input-icon-right`, true);
}
return cy.get('.filters-frequent .filter-widget');
};

Expand Down
29 changes: 17 additions & 12 deletions cypress/support/index.d.ts
Expand Up @@ -466,21 +466,21 @@ declare namespace Cypress {


/**
* Please help with documentation!
* The file where this function is declared appears below, however the parameters in this definition may be wrong. Please adjust as needed.
*
* It selects the current date from the picker
* @fieldName - the date field for which the current date is selected
* @modal - optional, default false, set to true is the date field is in a modal
* from cypress/support/commands/form.js
*/
selectDateViaPicker(fieldName, modal): Chainable<any>
selectDateViaPicker(fieldName: string, modal?: boolean): Chainable<any>


/**
* Please help with documentation!
* The file where this function is declared appears below, however the parameters in this definition may be wrong. Please adjust as needed.
*
* from cypress/support/commands/form.js
/**Selects a date in the picker
* should not be used for offsets larger than a couple of days
* @param {string} fieldName - name of the field
* @param {number} dayOffset - the number of days before/after today;
* @param {boolean} modal - optional, default false, use true, if the field is in a modal overlay; required if the underlying window has a field with the same name
*/
selectOffsetDateViaPicker(fieldName, dayOffset, modal): Chainable<any>
selectOffsetDateViaPicker(fieldName: string, dayOffset: number, modal?: boolean): Chainable<any>


/**
Expand Down Expand Up @@ -565,7 +565,7 @@ declare namespace Cypress {
*
* @param numberOfRows - the number of rows
*/
expectNumberOfRows(numberOfRows): Chainable<any>
expectNumberOfRows(numberOfRows: number): Chainable<any>

/**
* Complete the current document
Expand Down Expand Up @@ -604,7 +604,12 @@ declare namespace Cypress {
* @param destinationWindowID - the expected window where the notification redirects
*/
openNotificationContaining(expectedValue: string | RegExp, destinationWindowID: string | number): Chainable<any>

/**
* Expect the table rows to be greater than a given number
*
* @param numberOfRows - the number of rows
*/
expectNumberOfRowsToBeGreaterThan(numberOfRows: number): Chainable<any>
}

}

0 comments on commit 2b57991

Please sign in to comment.