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

Draft 2: Use a minimal fixture for customer-specific data only #295

Merged
merged 4 commits into from
Aug 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"priceSystemName": "IntergalacticPriceSystem",
"priceListName": "PlanetaryPriceList",
"priceListVersionName": "PlanetaryPriceListVersion",


"priceListSchemaVersionName": "ProductPriceListSchemaVersion",
"priceListVersion2ValidFrom": "01/02/2019",

"priceListVersionNameSearch1": "PlanetaryPriceList.*2019-01-01$",
"priceListVersionNameSearch2": "PlanetaryPriceList.*2019-01-02$",


"categoryName": "PopsiclesCategory",
"productName1": "StrawberryPopsicleProduct",
"productName2": "LemonPopsicleProduct",
"productType": "Item",


"priceListSchemaName": "PriceListSchema",
"surchargeAmount": 22
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@
* #L%
*/

import { humanReadableNow } from '../../support/utils/utils';
import { appendHumanReadableNow } from '../../support/utils/utils';
import { PriceListSchema, PriceListSchemaLine } from '../../support/utils/price_list_schema';
import { Builder } from '../../support/utils/builder';
import { applyFilters, selectNotFrequentFilterWidget, toggleNotFrequentFilters } from '../../support/functions';
import { ProductPrices } from '../../page_objects/product_prices';
import { PriceList, PriceListVersion } from '../../support/utils/pricelist';

const date = humanReadableNow();

// Price
const priceSystemName = `PriceSystem_${date}`;
const priceListVersionName = `PriceListVersion_${date}`;
const priceListName = `PriceList_${date}`;
const priceListSchemaVersionName = `PriceListSchemaVersion_${date}`;
const priceListVersion2ValidFrom = '01/02/2019';
const priceListVersionNameSearch1 = new RegExp(priceListName + '.*' + '2019-01-01$'); // magic from fixture (PLV doesn't have standard name :( )
const priceListVersionNameSearch2 = new RegExp(priceListName + '.*' + '2019-01-02$'); // magic from fixture (PLV doesn't have standard name :( )
let priceSystemName;
let priceListName;
let priceListVersionName;

let priceListSchemaVersionName;
let priceListVersion2ValidFrom;

let priceListVersionNameSearch1; // magic from fixture (PLV doesnt have standard name :( )"
let priceListVersionNameSearch2; // magic from fixture (PLV doesnt have standard name :( )"

// Product
const categoryName = `Category_${date}`;
const productName1 = `Product1 ${date}`;
const productName2 = `Product2 ${date}`;
const productType = 'Item';
let categoryName;
let productName1;
let productName2;
let productType;

// Price List Schema
const priceListSchemaName = `PriceListSchema_${date}`;
const surchargeAmount = 222;
let priceListSchemaName;
let surchargeAmount;

// test
let priceListID;
Expand All @@ -56,7 +56,33 @@ let originalPriceList;
let originalUOM;
let originalTaxCategory;

it('Read fixture and prepare the names', function() {
cy.fixture('price/add_a_product_to_a_pricelist_schema_and_create_a_new_PLV.json').then(f => {
priceSystemName = appendHumanReadableNow(f['priceSystemName']);
priceListName = appendHumanReadableNow(f['priceListName']);
priceListVersionName = appendHumanReadableNow(f['priceListVersionName']);

priceListSchemaVersionName = appendHumanReadableNow(f['priceListSchemaVersionName']);
priceListVersion2ValidFrom = f['priceListVersion2ValidFrom'];

priceListVersionNameSearch1 = new RegExp(f['priceListVersionNameSearch1']);
priceListVersionNameSearch2 = new RegExp(f['priceListVersionNameSearch2']);

categoryName = appendHumanReadableNow(f['categoryName']);
productName1 = appendHumanReadableNow(f['productName1']);
productName2 = appendHumanReadableNow(f['productName2']);
productType = f['productType'];

priceListSchemaName = appendHumanReadableNow(f['priceListSchemaName']);
surchargeAmount = f['surchargeAmount'];
});
});

describe('Create Price and Products', function() {
it('reaaaaaalyyyyyyyyy', function() {
cy.wait(5000);
});

Copy link
Member

Choose a reason for hiding this comment

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

This looks a bit ugly:( do we reaaaalyyy need the wait in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, sometimes (eg. 2/5 maybe) we get that problem with getLanguageSpecific, so this wait is needed right now -- at least on my machine :(

Copy link
Member

Choose a reason for hiding this comment

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

ok

it('Create Price', function() {
Builder.createBasicPriceEntities(priceSystemName, priceListVersionName, priceListName, false);

Expand Down
16 changes: 14 additions & 2 deletions cypress/support/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ const findByName = (dataArray, name) => {
*/
const humanReadableNow = () => {
const date = new Date(Date.now() - new Date().getTimezoneOffset() * 60000).toISOString();
return date.slice(8, date.length - 1).split(/:|\./g).join('_');
// noinspection RegExpSingleCharAlternation
return date
.slice(8, date.length - 1)
.split(/:|\./g)
.join('_');
};

export {getLanguageSpecific, wrapRequest, findByName, humanReadableNow};
let date;
const appendHumanReadableNow = (str) => {
if (!date) {
date = humanReadableNow();
}
return `${str}_${date}`;
};

export { getLanguageSpecific, wrapRequest, findByName, humanReadableNow, appendHumanReadableNow };