Skip to content

Commit

Permalink
Added coverage for b2b shop.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmiseev committed Jan 21, 2025
1 parent 4d2e199 commit e60aa4f
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 16 deletions.
54 changes: 54 additions & 0 deletions docker-compose.b2b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
networks:
k6:
grafana:
spryker_b2b_dev_public:
external: true
spryker_b2b_dev_private:
external: true

services:
influxdb:
image: influxdb:1.8
networks:
- k6
- grafana
ports:
- '8086:8086'
environment:
- INFLUXDB_DB=k6

grafana:
image: grafana/grafana:latest
networks:
- grafana
ports:
- '3000:3000'
environment:
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_BASIC_ENABLED=false
volumes:
- ./dashboards:/var/lib/grafana/dashboards
- ./grafana-dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
- ./grafana-datasource.yaml:/etc/grafana/provisioning/datasources/datasource.yaml

k6:
build:
context: .
dockerfile: Dockerfile
environment:
- K6_OUT=influxdb=http://influxdb:8086/k6
- K6_STATSD_ADDR=nrstatsd:8125
- K6_STATSD_NAMESPACE=spryker_k6_
- K6_HOSTENV=${K6_HOSTENV}
- K6_NO_THRESHOLDS=${K6_NO_THRESHOLDS}
- ENV_REPOSITORY_ID=${ENV_REPOSITORY_ID}
- ENV_REPOSITORY_TYPE=${ENV_REPOSITORY_TYPE}
networks:
- k6
- spryker_b2b_dev_private
- spryker_b2b_dev_public
volumes:
- ./dist:/dist
ports:
- '6565:6565'
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "proprietary",
"main": "index.js",
"scripts": {
"build:one": "webpack --env entryPattern=./src/tests/cart-reorder/SAPI15_cart_reorder_50.test.js",
"build:one": "webpack --env entryPattern=./src/tests/checkout/SAPI7_checkout_1.test.js",
"build:all": "webpack --env entryPattern=./src/tests/**/*.test.js",
"build:S": "webpack --env entryPattern=./src/tests/**/S*.test.js",
"build:M": "webpack --env entryPattern=./src/tests/**/M*.test.js",
Expand All @@ -15,9 +15,9 @@
"build:order-amendment": "webpack --env entryPattern=./src/tests/order-amendment/*.test.js",
"build:product-search": "webpack --env entryPattern=./src/tests/product-search/*.test.js",
"build:dashboard": "webpack --env entryPattern=./src/tests/dashboard/*.test.js",
"docker:up": "docker-compose -f docker-compose.b2b-mp.yml up -d influxdb grafana",
"docker:down": "docker-compose -f docker-compose.b2b-mp.yml down -v --remove-orphans",
"docker:run": "find dist -name '*.test.js' -exec docker-compose -f docker-compose.b2b-mp.yml run --rm k6 run /{} \\;",
"docker:up": "docker-compose -f docker-compose.b2b.yml up -d influxdb grafana",
"docker:down": "docker-compose -f docker-compose.b2b.yml down -v --remove-orphans",
"docker:run": "find dist -name '*.test.js' -exec docker-compose -f docker-compose.b2b.yml run --rm k6 run /{} \\;",
"prettier:check": "prettier . --check",
"prettier:write": "prettier . --write",
"lint": "npx eslint ./src"
Expand Down
9 changes: 5 additions & 4 deletions src/fixtures/checkout.fixture.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AbstractFixture } from './abstract.fixture';
import EnvironmentUtil from '../utils/environment.util';
import exec from 'k6/execution';

const LOCALE_ID = 66;
const LOCALE_NAME = 'en_US';
Expand Down Expand Up @@ -41,7 +42,7 @@ export class CheckoutFixture extends AbstractFixture {
});
}

static iterateData(data, vus = __VU, iterations = __ITER) {
static iterateData(data, vus = exec.vu.idInTest, iterations = exec.vu.iterationInScenario) {
const customerIndex = (vus - 1) % data.length;
const { customerEmail, quoteIds } = data[customerIndex];
const quoteIndex = iterations % quoteIds.length;
Expand Down Expand Up @@ -79,7 +80,7 @@ export class CheckoutFixture extends AbstractFixture {
},
];

if (this.repositoryId === 'b2b-mp') {
if (this.repositoryId === 'b2b-mp' || this.repositoryId === 'b2b') {
const companyPermissions = [
{
type: 'helper',
Expand Down Expand Up @@ -269,12 +270,12 @@ export class CheckoutFixture extends AbstractFixture {
},
];

if (this.repositoryId === 'b2b-mp') {
if (this.repositoryId === 'b2b-mp' || this.repositoryId === 'b2b') {
const companyUser = [
{
type: 'helper',
name: 'haveCompanyUser',
key: 'companyUser',
key: `companyUser${customerKey}`,
arguments: [
{
customer: `#${customerKey}`,
Expand Down
3 changes: 2 additions & 1 deletion src/fixtures/merchant-user.fixture.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AbstractFixture } from './abstract.fixture';
import exec from 'k6/execution';

const DEFAULT_PASSWORD = 'change123';

Expand Down Expand Up @@ -29,7 +30,7 @@ export class MerchantUserFixture extends AbstractFixture {
});
}

static iterateData(data, vus = __VU) {
static iterateData(data, vus = exec.vu.idInTest) {
const merchantUserIndex = (vus - 1) % data.length;

return data[merchantUserIndex];
Expand Down
3 changes: 2 additions & 1 deletion src/fixtures/product.fixture.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AbstractFixture } from './abstract.fixture';
import EnvironmentUtil from '../utils/environment.util';
import exec from 'k6/execution';

const DEFAULT_IMAGE_SMALL = 'https://images.icecat.biz/img/gallery_mediums/30691822_1486.jpg';
const DEFAULT_IMAGE_LARGE = 'https://images.icecat.biz/img/gallery/30691822_1486.jpg';
Expand Down Expand Up @@ -39,7 +40,7 @@ export class ProductFixture extends AbstractFixture {
});
}

static iterateData(data, vus = __VU) {
static iterateData(data, vus = exec.vu.idInTest) {
const productIndex = (vus - 1) % data.length;

return data[productIndex];
Expand Down
5 changes: 5 additions & 0 deletions src/tests/dashboard/M8_view_dashboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { MerchantUserFixture } from '../../fixtures/merchant-user.fixture';
import { browser } from 'k6/browser';
import { DashboardPage } from '../../pages/mp/dashboard.page';
import { LoginPage } from '../../pages/mp/login.page';
import exec from 'k6/execution';

if (EnvironmentUtil.getRepositoryId() === 'b2b') {
exec.test.abort('Merchant Portal is not integrated into b2b demo shop.');
}

const testConfiguration = {
...EnvironmentUtil.getDefaultTestConfiguration(),
Expand Down
6 changes: 3 additions & 3 deletions src/tests/order-amendment/SAPI16_order_amendment_50.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ function getCustomerData(data) {
let customerIndex;

if (isSequentialSetup()) {
customerIndex = __ITER % data.length;
customerIndex = exec.vu.iterationInScenario % data.length;
} else if (isConcurrentSetup()) {
customerIndex = (__VU - 1) % data.length;
customerIndex = (exec.vu.idInTest - 1) % data.length;
}

return data[customerIndex];
}

function getQuoteIndex(quoteIds) {
return isSequentialSetup() ? 0 : __ITER % quoteIds.length;
return isSequentialSetup() ? 0 : exec.vu.iterationInScenario % quoteIds.length;
}

function isConcurrentSetup() {
Expand Down
6 changes: 3 additions & 3 deletions src/tests/order-amendment/SAPI20_order_amendment_70.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ function getCustomerData(data) {
let customerIndex;

if (isSequentialSetup()) {
customerIndex = __ITER % data.length;
customerIndex = exec.vu.iterationInScenario % data.length;
} else if (isConcurrentSetup()) {
customerIndex = (__VU - 1) % data.length;
customerIndex = (exec.vu.idInTest - 1) % data.length;
}

return data[customerIndex];
}

function getQuoteIndex(quoteIds) {
return isSequentialSetup() ? 0 : __ITER % quoteIds.length;
return isSequentialSetup() ? 0 : exec.vu.iterationInScenario % quoteIds.length;
}

function isConcurrentSetup() {
Expand Down

0 comments on commit e60aa4f

Please sign in to comment.