Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get bvt ready #2230

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
7 changes: 3 additions & 4 deletions build-tests/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
build:
npm install

test:
./node_modules/.bin/ava --verbose --concurrency=3 > results.txt 2>&1
test-bvt:
rm -rf allure-report allure-results
./node_modules/mocha/bin/mocha --compilers js:babel-core/register 'test/*' --reporter mocha-allure-reporter

report:
rm -rf allure-report allure-results
node make-allure-report.js results.txt
allure generate allure-results
78 changes: 78 additions & 0 deletions build-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# build-tests

API based tests automation framework, initially created for running build verification test suite.
The goal of BVT as a test suite is to run sanity checks to make sure build is OK.

#### Installation

Install dependencies:

npm install

Install Allure CLI.

Ubuntu:

sudo apt-add-repository ppa:yandex-qatools/allure-framework
sudo apt-get update
sudo apt-get install allure-commandline

MacOS:

brew tap qatools/formulas
brew install allure-commandline

Export env variable to point at environment against which tests should run:

export BVT_ENV={env_name}

You can either use one of environments listed in `config.js`, or add there your own by the analogy of existing ones.

A list of available environments:

* STAGE
* STAGE-TPG
* STAGE-TD
* TEST
* FEATURE-BRANCH-APPLE
* APPLIANCE-KANGAROOS

**Make sure to specify the variable value in upper case!**

---

#### Run Tests Manually

To run build verification tests:

make test-bvt

**[WIP]** To run API tests:

make test-api

To configure API test run with specific tests you need:


ava -v --concurrency=3 --match='[api.{area-to-test}]*' > results.txt 2>&1


* `{area-to-test}` should be replaced with something you want test, e.g.:
`--match='[api.cart]*'`
You can have multiple `--match` parameters in your run command.

* `--concurrency=3` is a number of concurrent threads in which test files are executed.
I wouldn't recommend increasing this parameter, yet.

---

#### Reporting

To generate report, run:

make report

To open report, run:

allure report open

54 changes: 47 additions & 7 deletions build-tests/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export default {
fullApiSequenceLogging: false,
},
'STAGE-TD': {
apiUrl: 'https://td-prod.foxcommerce.com',
apiUrl: 'https://td-stage.foxcommerce.com',
storefronts: [
{
name: 'TD',
url: 'https://td-prod.foxcommerce.com/',
url: 'https://td-stage.foxcommerce.com/',
categories: TD_CATEGORIES,
},
],
Expand All @@ -51,18 +51,18 @@ export default {
testGiftCardFlow: false,
fullApiSequenceLogging: false,
},
'APPLIANCE-AEMXDP': {
apiUrl: 'https://appliance-10-240-0-51.foxcommerce.com',
'TEST': {
apiUrl: 'https://test.foxcommerce.com',
storefronts: [
{
name: 'TPG',
url: 'https://appliance-10-240-0-51.foxcommerce.com/perfect-gourmet',
url: 'https://test.foxcommerce.com/perfect-gourmet',
categories: TPG_CATEGORIES,
aboutPagePath: 'about',
},
{
name: 'TD',
url: 'https://appliance-10-240-0-51.foxcommerce.com/top-drawer',
url: 'https://test.foxcommerce.com/top-drawer',
categories: TD_CATEGORIES,
},
],
Expand All @@ -71,4 +71,44 @@ export default {
testGiftCardFlow: false,
fullApiSequenceLogging: false,
},
}[process.env['BVT_ENV'] || 'APPLIANCE-AEMXDP'];
'FEATURE-BRANCH-APPLE': {
apiUrl: 'https://feature-branch-apple.foxcommerce.com',
storefronts: [
{
name: 'TPG',
url: 'https://feature-branch-apple.foxcommerce.com/perfect-gourmet',
categories: TPG_CATEGORIES,
aboutPagePath: 'about',
},
{
name: 'TD',
url: 'https://feature-branch-apple.foxcommerce.com/top-drawer',
categories: TD_CATEGORIES,
},
],
stripeKey: 'pk_test_JvTXpI3DrkV6QwdcmZarmlfk',
networkErrorRetries: 4,
testGiftCardFlow: false,
fullApiSequenceLogging: false,
},
'APPLIANCE-KANGAROOS': {
apiUrl: 'https://appliance-10-240-0-7.foxcommerce.com',
storefronts: [
{
name: 'TPG',
url: 'https://appliance-10-240-0-7.foxcommerce.com/perfect-gourmet',
categories: TPG_CATEGORIES,
aboutPagePath: 'about',
},
{
name: 'TD',
url: 'https://appliance-10-240-0-7.foxcommerce.com/top-drawer',
categories: TD_CATEGORIES,
},
],
stripeKey: 'pk_test_JvTXpI3DrkV6QwdcmZarmlfk',
networkErrorRetries: 4,
testGiftCardFlow: false,
fullApiSequenceLogging: false,
},
}[process.env['BVT_ENV']];
5 changes: 3 additions & 2 deletions build-tests/helpers/createCreditCard.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import $ from '../payloads';
import * as step from './steps';

export default async (api, customerId) => {
const creditCardDetails = $.randomCreditCardDetailsPayload(customerId);
const newTokenResponse = await api.dev.creditCardToken(creditCardDetails);
const newTokenResponse = await step.getCreditCardToken(api, creditCardDetails);
const payload = {
token: newTokenResponse.token,
lastFour: newTokenResponse.lastFour,
Expand All @@ -13,5 +14,5 @@ export default async (api, customerId) => {
billingAddress: creditCardDetails.address,
addressIsNew: true,
};
return api.customerCreditCards.add(customerId, payload);
return step.addCustomerCreditCard(api, customerId, payload);
};
34 changes: 18 additions & 16 deletions build-tests/helpers/placeRandomOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ import createCreditCard from './createCreditCard';
import waitFor from './waitFor';
import { AdminApi, CustomerApi } from '../helpers/Api';
import $ from '../payloads';
import * as step from '../helpers/steps';

export default async (t) => {
const adminApi = await AdminApi.loggedIn(t);
export default async () => {
const api = new AdminApi;
await step.loginAsAdmin(api);
const credentials = $.randomUserCredentials();
const newCustomer = await adminApi.customers.create(credentials);
const newCard = await createCreditCard(adminApi, newCustomer.id);
const newCustomer = await step.createNewCustomer(api, credentials);
const newCard = await createCreditCard(api, newCustomer.id);
const productPayload = $.randomProductPayload({ minSkus: 1, maxSkus: 1 });
const newProduct = await adminApi.products.create('default', productPayload);
const newProduct = await step.createNewProduct(api, 'default', productPayload);
const skuCode = newProduct.skus[0].attributes.code.v;
const inventory = await waitFor(500, 10000, () => adminApi.inventories.get(skuCode));
const inventory = await waitFor(500, 10000, () => step.getInventorySkuCode(api, skuCode));
const stockItemId = inventory.summary.find(item => item.type === 'Sellable').stockItem.id;
await adminApi.inventories.increment(stockItemId, { qty: 1, status: 'onHand', type: 'Sellable' });
const customerApi = new CustomerApi(t);
await customerApi.auth.login(credentials.email, credentials.password, $.customerOrg);
await customerApi.cart.get();
await customerApi.cart.addSku(skuCode, 1);
await customerApi.cart.setShippingAddress($.randomCreateAddressPayload());
const shippingMethod = $.randomArrayElement(await customerApi.cart.getShippingMethods());
await customerApi.cart.chooseShippingMethod(shippingMethod.id);
await customerApi.cart.addCreditCard(newCard.id);
const fullOrder = await customerApi.cart.checkout();
await step.incrementInventories(api, stockItemId, { qty: 1, status: 'onHand', type: 'Sellable' });
const customerApi = new CustomerApi;
await step.login(customerApi, credentials.email, credentials.password, $.customerOrg);
await step.getCurrentCart(customerApi);
await step.addSkuToCart(customerApi, skuCode, 1);
await step.setShippingAddress(customerApi, $.randomCreateAddressPayload());
const shippingMethod = $.randomArrayElement(await step.getShippingMethods(customerApi));
await step.chooseShippingMethod(customerApi, shippingMethod.id);
await step.addCreditCard(customerApi, newCard.id);
const fullOrder = await step.checkout(customerApi);
return { fullOrder, newCard, newCustomer };
};
Loading