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

Fix tests 3 #261

Merged
merged 16 commits into from Aug 5, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 29 additions & 32 deletions cypress/integration/logistics/create_delivery_days.js
@@ -1,67 +1,64 @@
import { BPartner } from '../../support/utils/bpartner';
import { toggleNotFrequentFilters, selectNotFrequentFilterWidget, applyFilters } from '../../support/functions';
import { humanReadableNow } from '../../support/utils/utils';
import { Tour } from '../../support/utils/tour';
import { TourVersion } from '../../support/utils/tour_version';
import { TourVersion, TourVersionLine } from '../../support/utils/tour_version';

describe('Create a tour and a tourversion', function() {
describe('Create a Tour, a Tour Version and Delivery Days', function() {
const date = humanReadableNow();
const customerName = `Customer ${date}`;
const tourName = `TestTour ${date}`;
const tourVersionName = `TestTourVersion ${date}`;
// let mainTourId;

const tourName = `TestTour_${date}`;
const tourVersionName = `TestTourVersion_${date}`;

// test
let tourID;

it('Create customer for which we will create a tour', function() {
cy.fixture('sales/simple_customer.json').then(customerJson => {
new BPartner({ ...customerJson, name: customerName }).setCustomer(true).apply();
});
});

it('Create a tour', function() {
cy.fixture('logistics/tour.json').then(tourJson => {
Object.assign(new Tour(), tourJson)
.setName(tourName)
.apply();
});
// cy.get(`@${tourName}`).then(mainTour => {
// mainTourId = mainTour.documentId;
// });

cy.getCurrentWindowRecordId().then(id => {
tourID = id;
});
});

it('Create a tour version', function() {
cy.fixture('logistics/tourversion.json').then(tourVersionJson => {
Object.assign(new TourVersion(), tourVersionJson)
.setName(tourVersionName)
.setTour(tourName)
.setCustomer(customerName)
// eslint-disable-next-line
.addLine(new TourVersionLine().setBpartner(customerName).setBuffer(0))
.apply();
});
});
it('Create delivery days for this tour', function() {
cy.visitWindow(540331);
toggleNotFrequentFilters();
selectNotFrequentFilterWidget('default');
cy.writeIntoStringField('Name', tourName, false, null, true);
applyFilters();
cy.get('tbody tr')
.eq(0)
.dblclick();
/**Create delivery days for this tour */

it('Create delivery days for the tour', function() {
cy.visitWindow(540331, tourID);
cy.executeHeaderActionWithDialog('GenerateDeliveryDays');
cy.writeIntoStringField('DateFrom', '07/01/2019', true, null, true);
cy.writeIntoStringField('DateTo', '07/19/2019', true, null, true);
cy.pressStartButton();
cy.waitUntilProcessIsFinished();
cy.visitWindow(540110);
toggleNotFrequentFilters();
selectNotFrequentFilterWidget('default');
cy.writeIntoLookupListField('M_TourVersion_ID', tourVersionName, tourVersionName, false, false, null, true);
cy.writeIntoLookupListField('C_BPartner_ID', customerName, customerName, false, false, null, true);
applyFilters();
/**the tour version is created weekly - each day from Monday to Friday; the delivery dates were generated
});

it('Open Referenced Delivery Days and expect 15 rows', function() {
const expectedDeliveryDays = 15;
cy.getNotificationModal(`Created #${expectedDeliveryDays}`);
cy.openReferencedDocuments('540110');
/**
* the tour version is created weekly - each day from Monday to Friday; the delivery dates were generated
* for the interval 1st of July - 19th of July - this means that there will be 15 delivery days in this interval
* => we will check that the number of rows after filtering to be equal to 15;
*/
cy.get('tbody tr').should(el => {
expect(el.length).to.be.equal(15);
});
cy.expectNumberOfRows(expectedDeliveryDays);
});
});
});
12 changes: 8 additions & 4 deletions cypress/integration/logistics/create_tour_tour_version.js
@@ -1,32 +1,36 @@
import { BPartner } from '../../support/utils/bpartner';
import { humanReadableNow } from '../../support/utils/utils';
import { Tour } from '../../support/utils/tour';
import { TourVersion } from '../../support/utils/tour_version';
import { TourVersion, TourVersionLine } from '../../support/utils/tour_version';

describe('Create a tour and a tour version', function() {
const date = humanReadableNow();
const customerName = `Customer ${date}`;
const tourName = `TestTour ${date}`;
const tourVersionName = `TestTourVersion ${date}`;

const tourName = `TestTour_${date}`;
const tourVersionName = `TestTourVersion_${date}`;

it('Create customer for which we will create a tour', function() {
cy.fixture('sales/simple_customer.json').then(customerJson => {
new BPartner({ ...customerJson, name: customerName }).setCustomer(true).apply();
});
});

it('Create a tour', function() {
cy.fixture('logistics/tour.json').then(tourJson => {
Object.assign(new Tour(), tourJson)
.setName(tourName)
.apply();
});
});

it('Create a tour version', function() {
cy.fixture('logistics/tourversion.json').then(tourVersionJson => {
Object.assign(new TourVersion(), tourVersionJson)
.setName(tourVersionName)
.setTour(tourName)
.setCustomer(customerName)
// eslint-disable-next-line
.addLine(new TourVersionLine().setBpartner(customerName).setBuffer(0))
.apply();
});
});
Expand Down
39 changes: 12 additions & 27 deletions cypress/integration/payment/create_manual_payment.js
Expand Up @@ -7,6 +7,8 @@ import { Bank } from '../../support/utils/bank';
import { Builder } from '../../support/utils/builder';
import { getLanguageSpecific } from '../../support/utils/utils';

// task: https://github.com/metasfresh/metasfresh-e2e/issues/111
TheBestPessimist marked this conversation as resolved.
Show resolved Hide resolved

describe('Create a manual Payment for a Sales Invoice', function() {
const timestamp = new Date().getTime();
// const timestamp = 'latest timestamp'; // to use this just comment the `before` function
Expand Down Expand Up @@ -63,32 +65,19 @@ describe('Create a manual Payment for a Sales Invoice', function() {
cy.fixture('sales/simple_customer.json').then(customerJson => {
new BPartner({ ...customerJson, name: bPartnerName }).setCustomerDiscountSchema(discountSchemaName).apply();
});
cy.readAllNotifications();
});

it('Create a Sales Invoice', function() {
cy.fixture('sales/sales_invoice.json').then(salesInvoiceJson => {
new SalesInvoice(bPartnerName, salesInvoiceTargetDocumentType)
.addLine(
new SalesInvoiceLine().setProduct(productName).setQuantity(20)
// todo @dh: how to add packing item
// .setPackingItem('IFCO 6410 x 10 Stk')
// .setTuQuantity(2)
)
// .addLine(
// todo @dh: how to add this line which depends on the packing item?
// new SalesInvoiceLine()
// .setProduct('IFCO 6410_P001512')
// .setQuantity(2)
// )
.addLine(new SalesInvoiceLine().setProduct(productName).setQuantity(20))
.setPriceList(priceListName)
.setDocumentAction(getLanguageSpecific(salesInvoiceJson, 'docActionComplete'))
.setDocumentStatus(getLanguageSpecific(salesInvoiceJson, 'docStatusCompleted'))
.apply();

cy.get('@newInvoiceDocumentId').then(salesInvoice => {
salesInvoiceID = salesInvoice.documentId;
cy.log(`salesInvoiceID is ${salesInvoiceID}`);
cy.getCurrentWindowRecordId().then(id => {
salesInvoiceID = id;
});
});
});
Expand All @@ -104,8 +93,8 @@ describe('Create a manual Payment for a Sales Invoice', function() {
salesInvoiceNumber = documentNumber;
});

cy.get('.header-breadcrumb-sitename').then(si => {
salesInvoiceTotalAmount = parseFloat(si.html().split(' ')[2], 10); // the format is "DOC_NO MM/DD/YYYY total"
cy.getSalesInvoiceTotalAmount().then(totalAmount => {
salesInvoiceTotalAmount = totalAmount;
});
});

Expand All @@ -125,13 +114,7 @@ describe('Create a manual Payment for a Sales Invoice', function() {

cy.writeIntoLookupListField('C_Invoice_ID', salesInvoiceNumber, salesInvoiceNumber);

// complete it and verify the status
cy.fixture('misc/misc_dictionary.json').then(miscDictionary => {
cy.processDocument(
getLanguageSpecific(miscDictionary, 'docActionComplete'),
getLanguageSpecific(miscDictionary, 'docStatusCompleted')
);
});
cy.completeDocument();
});

it('Checks the paid + discount amount', function() {
Expand All @@ -147,15 +130,17 @@ describe('Create a manual Payment for a Sales Invoice', function() {

cy.getStringFieldValue('Amount').then(val => {
const value = parseFloat(val).toFixed(2);
paymentTotalAmount = parseFloat(salesInvoiceTotalAmount - discountAmount).toFixed(2);
paymentTotalAmount = salesInvoiceTotalAmount - discountAmount;
assert.equal(value, paymentTotalAmount);
});

cy.pressDoneButton();
});

it('Accounting transactions are created', function() {
it('Expect 2 Accounting transactions are created', function() {
cy.openReferencedDocuments('AD_RelationType_ID-540201');
cy.expectNumberOfRows(2);
cy.go('back');
});

it('The paid Sales Invoice is linked to this Payment', function() {
Expand Down
5 changes: 2 additions & 3 deletions cypress/integration/product/create_bill_of_material.js
@@ -1,6 +1,5 @@
import { Product, ProductCategory } from '../../support/utils/product';
import { BillOfMaterial } from '../../support/utils/billOfMaterial';
import { applyFilters, toggleNotFrequentFilters, selectNotFrequentFilterWidget } from '../../support/functions';

describe('Create Product', function() {
const timestamp = new Date().getTime();
Expand Down Expand Up @@ -35,8 +34,8 @@ describe('Create Product', function() {
.setSold(true)
.apply();
});
cy.get(`@${productName}`).then(mainProduct => {
mainProductId = mainProduct.documentId;
cy.getCurrentWindowRecordId().then(id => {
mainProductId = id;
});
});

Expand Down
Expand Up @@ -13,19 +13,17 @@ import { purchaseOrders } from '../../page_objects/purchase_orders';
// task: https://github.com/metasfresh/metasfresh-e2e/issues/161

const date = humanReadableNow();
const productForPackingMaterial = `ProductPackingMaterial ${date}`;
const packingInstructionsName = `ProductPackingInstructions ${date}`;
const productName1 = `ProductTest1 ${date}`;
const productName2 = `ProductTest2 ${date}`;
const productValue1 = `purchase_order_test ${date}`;
const productValue2 = `purchase_order_test ${date}`;
const productCategoryName = `ProductCategoryName ${date}`;
const discountSchemaName = `DiscountSchemaTest ${date}`;
const priceSystemName = `PriceSystem ${date}`;
const priceListName = `PriceList ${date}`;
const priceListVersionName = `PriceListVersion ${date}`;
const productForPackingMaterial = `ProductPackingMaterial_${date}`;
const packingInstructionsName = `ProductPackingInstructions_${date}`;
const productName1 = `Product1_${date}`;
const productName2 = `Product2_${date}`;
const productCategoryName = `ProductCategoryName_${date}`;
const discountSchemaName = `DiscountSchema_${date}`;
const priceSystemName = `PriceSystem_${date}`;
const priceListName = `PriceList_${date}`;
const priceListVersionName = `PriceListVersion_${date}`;
const productType = 'Item';
const vendorName = `Vendor ${date}`;
const vendorName = `Vendor_${date}`;
const generateInvoicesNotificationModalText =
'Fakturlauf mit 1 Rechnungen eingeplant. Es sind bereits 0 zu erstellende Rechnungen in der Warteschlange, die vorher verarbeitet werden.';

Expand Down Expand Up @@ -64,32 +62,41 @@ describe('Create test data', function() {
.apply();
});
});
it('Create product, category and vendor entities', function() {

it('Create category', function() {
cy.fixture('product/simple_productCategory.json').then(productCategoryJson => {
Object.assign(new ProductCategory(), productCategoryJson)
.setName(productCategoryName)
.setValue(productCategoryName)
.apply();
});
});

it('Create product1', function() {
Builder.createProductWithPriceAndCUTUAllocationUsingExistingCategory(
productCategoryName,
productCategoryName,
priceListName,
productName1,
productValue1,
productName1,
productType,
packingInstructionsName
);
});

it('Create product2', function() {
// these are split into multiple "it" blocks as maybe this fixes some stupid ` Cannot read property 'body' of null` error
Builder.createProductWithPriceAndCUTUAllocationUsingExistingCategory(
productCategoryName,
productCategoryName,
priceListName,
productName2,
productValue2,
productName2,
productType,
packingInstructionsName
);
});
it('Create vendor', function() {
new BPartner({ name: vendorName })
.setVendor(true)
.setVendorPricingSystem(priceSystemName)
Expand Down Expand Up @@ -180,8 +187,11 @@ describe('Create a purchase order and Material Receipts', function() {
.first()
.click();

// wait until current window is PurchaseInvoice
cy.url().should('contain', '/183/');

// hope this is enough for the whole window to load
cy.waitForSaveIndicator(false);
cy.waitForSaveIndicator();

cy.openAdvancedEdit();
cy.getStringFieldValue('GrandTotal').then(el => {
Expand Down
Expand Up @@ -102,8 +102,8 @@ describe('Void Sales Invoice and invoice the billing candidates again', function
});

it('Billing Candidates checks after Sales Order created', function() {
const qtyDelivered = '0'; // backend is flaky and keeps switching between '' and '0' and back to ''
const qtyInvoiced = '0'; // backend is flaky and keeps switching between '' and '0' and back to ''
const qtyDelivered = '0';
const qtyInvoiced = '0';

checkBillingCandidate(qtyDelivered, qtyInvoiced);
});
Expand Down Expand Up @@ -339,8 +339,20 @@ describe('Void Sales Invoice and invoice the billing candidates again', function
cy.getStringFieldValue('M_Product_ID').should('contain', productName);
cy.getStringFieldValue('QtyEntered').should('equal', originalQuantity.toString(10));
cy.getStringFieldValue('QtyOrdered').should('equal', originalQuantity.toString(10));
cy.getStringFieldValue('QtyDelivered ').should('equal', qtyDelivered);
cy.getStringFieldValue('QtyInvoiced ').should('equal', qtyInvoiced);

// backend is flaky and keeps switching between '' and '0' and back to '', so we need this workaround
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheBestPessimist do you think it makes sense to create a backend task to fix that ? Having types problems on top of what we already have makes it even harder to maintain the whole thing :)

cy.getStringFieldValue('QtyDelivered ').then(qty => {
if (qty === '') {
qty = '0';
}
expect(qty).to.equal(qtyDelivered);
});
cy.getStringFieldValue('QtyInvoiced ').then(qty => {
if (qty === '') {
qty = '0';
}
expect(qty).to.equal(qtyInvoiced);
});
}
});

Expand Down