Skip to content

Commit

Permalink
Merge 21bb99b into d88c525
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsobol authored Mar 8, 2021
2 parents d88c525 + 21bb99b commit 1a50ce7
Show file tree
Hide file tree
Showing 80 changed files with 15,794 additions and 2,881 deletions.
71 changes: 61 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ jobs:
- name: Get cached dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
path: |
~/.cache/Cypress
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
Expand All @@ -46,7 +48,9 @@ jobs:
- name: Get cached dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
path: |
~/.cache/Cypress
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Run linter
Expand All @@ -68,7 +72,9 @@ jobs:
- name: Get cached dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
path: |
~/.cache/Cypress
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Build core
Expand All @@ -94,8 +100,8 @@ jobs:
path-to-lcov: packages/core/cli/coverage/lcov.info
flag-name: core-cli

validate_integrations:
name: Validate ${{ matrix.integration }}
unit_test_integrations:
name: Run unit tests on ${{ matrix.integration }}
needs: validate_core
runs-on: ubuntu-latest
strategy:
Expand All @@ -104,7 +110,6 @@ jobs:
integration:
- boilerplate
- commercetools
# - shopify

steps:
- name: Checkout code
Expand All @@ -118,7 +123,9 @@ jobs:
- name: Get cached dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
path: |
~/.cache/Cypress
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Build core
Expand Down Expand Up @@ -171,13 +178,57 @@ jobs:
parallel: true
flag-name: ${{ matrix.integration }}-composables

finish:
name: Finish
needs: validate_integrations
finish_coveralls:
name: Finish coveralls
needs: unit_test_integrations
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

e2e_test_integrations:
name: Run E2E tests on ${{ matrix.integration }}
env:
NUXT_ENV_E2E: true
needs: validate_core
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
integration:
- bp
- ct

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: '12'

- name: Get cached dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/Cypress
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Build integration
run: yarn build:${{ matrix.integration }}

- name: Cypress run
uses: cypress-io/github-action@v2.8.2
with:
start: yarn start:${{ matrix.integration }}
wait-on: 'http://localhost:3000/'
command: yarn run test:e2e:headless
config-file: packages/core/nuxt-theme-module/theme/tests/e2e/cypress.json
browser: chrome
headless: true
install: false
26 changes: 9 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,37 @@
},
"scripts": {
"build:docs": "cd packages/core/docs && yarn build",
"dev:docs": "cd packages/core/docs && yarn dev",
"build:core": "cd packages/core/core && yarn build",
"build:middleware": "cd packages/core/middleware && yarn build",
"build:spr:api-client": "cd packages/spryker/api-client && yarn build",
"build:spr:composables": "cd packages/spryker/composables && yarn build",
"build:spr:tools": "yarn build:core && yarn build:spr:api-client && yarn build:spr:composables",
"build:spr:theme": "cd packages/spryker/theme && yarn build",
"build:spr": "yarn build:spr:tools && yarn build:spr:theme",
"dev:spr": "cd packages/spryker/theme && yarn dev",
"dev:spr:api-client": "cd packages/spryker/api-client && yarn dev",
"dev:spr:composables": "cd packages/spryker/composables && yarn dev",
"build:changelog": "cd packages/core/docs/scripts && node changelog",
"build:bp:api-client": "cd packages/boilerplate/api-client && yarn build",
"build:bp:composables": "cd packages/boilerplate/composables && yarn build",
"build:bp:tools": "yarn build:core && yarn build:bp:api-client && yarn build:bp:composables",
"build:bp:tools": "yarn build:core && yarn build:middleware && yarn build:bp:api-client && yarn build:bp:composables",
"build:bp:theme": "cd packages/boilerplate/theme && yarn build",
"build:bp": "yarn build:bp:tools && yarn build:bp:theme",
"dev:bp": "cd packages/boilerplate/theme && yarn dev",
"start:bp": "cd packages/boilerplate/theme && yarn start",
"build:ct:api-client": "cd packages/commercetools/api-client && yarn build",
"build:ct:composables": "cd packages/commercetools/composables && yarn build",
"build:ct:tools": "yarn build:core && yarn build:middleware && yarn build:ct:api-client && yarn build:ct:composables",
"build:ct:theme": "cd packages/commercetools/theme && yarn build",
"build:ct": "yarn build:core && yarn build:ct:tools && yarn build:ct:theme",
"build:sp:tools": "yarn build:core && yarn build:sp:api-client && yarn build:sp:composables",
"build:sp": "yarn build:core && yarn build:sp:tools && yarn build:sp:theme",
"dev:ct": "cd packages/commercetools/theme && yarn dev",
"start:ct": "cd packages/commercetools/theme && yarn start",
"test:ct:api-client": "cd packages/commercetools/api-client && yarn test",
"test:ct:composables": "cd packages/commercetools/composables && yarn test",
"test:core": "jest -c ./packages/core/jest.config.js",
"test:ct": "yarn test:ct:api-client && yarn test:ct:composables",
"test:e2e": "./node_modules/.bin/cypress open",
"test:e2e": "cd packages/core/nuxt-theme-module && cypress open --config-file theme/tests/e2e/cypress.json",
"test:e2e:headless": "cd packages/core/nuxt-theme-module && cypress run --headless --config-file theme/tests/e2e/cypress.json",
"test:cli": "cd packages/core/cli && yarn test",
"start:ct": "cd packages/commercetools/theme && yarn start",
"dev:docs": "cd packages/core/docs && yarn dev",
"dev:ct:api-client": "cd packages/commercetools/api-client && yarn dev",
"dev:ct:composables": "cd packages/commercetools/composables && yarn dev",
"dev:ct": "cd packages/commercetools/theme && yarn dev",
"link-packages": "lerna link --force-local",
"lint": "eslint . --ext .js,.ts,.vue",
"release": "cd scripts && yarn release",
"cli": "cd packages/core/cli && yarn cli",
"core:changelog": "cd packages/core/docs/scripts && node changelog"
"cli": "cd packages/core/cli && yarn cli"
},
"devDependencies": {
"@babel/core": "^7.10.5",
Expand Down
75 changes: 63 additions & 12 deletions packages/boilerplate/api-client/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
export type Cart = Record<string, unknown>;
export type Wishlist = Record<string, unknown>;
import { AgnosticCoupon } from '@vue-storefront/core';

export { UseCategory, UseProduct } from '@vue-storefront/core';

export type Category = {
id: number;
name: string;
slug: string;
items: Category[];
}

export type CategoryFilter = Record<string, any>;

export type User = {
firstName?: string;
lastName?: string;
email?: string;
};

export type UserAddress = Record<string, any>;

export type Coupon = AgnosticCoupon;

export type Order = Record<string, any>;

export type OrderItem = Record<string, any>;

export type OrdersResponse = {
data: any[];
total: number;
};

export type OrderSearchParams = Record<string, any>;

export type Product = {
name: string;
};

export type ProductsResponse = {
data: Product[];
total: number;
};

export type CartItem = Product & {
_count: number;
};

export type Cart = {
coupons: AgnosticCoupon[];
items: CartItem[];
};

export type Review = Record<string, any>;

export type Shipping = Record<string, unknown>;

export type ShippingMethod = Record<string, any>;

export type WishlistProduct = Record<string, any>;

export type Wishlist = Record<string, any>;

export type ProductVariant = {
_id: number;
_description: string;
Expand All @@ -11,13 +71,4 @@ export type ProductVariant = {
original: number;
current: number;
};
};
export type Category = {
id: number;
name: string;
slug: string;
items: Category[];
};
export type CategoryFilter = Record<string, unknown>;
export type ShippingMethod = Record<string, unknown>;
export type LineItem = Record<string, unknown>;
}
33 changes: 7 additions & 26 deletions packages/boilerplate/composables/src/getters/cartGetters.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
import { CartGetters, AgnosticPrice, AgnosticTotals, AgnosticCoupon, AgnosticDiscount } from '@vue-storefront/core';
import { Cart, LineItem } from '@vue-storefront/boilerplate-api/src/types';
import { Cart, CartItem } from '@vue-storefront/boilerplate-api';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCartItems = (cart: Cart): LineItem[] => [
{
_id: 1,
_description: 'Some description',
_categoriesRef: [
'1',
'2'
],
name: 'Black jacket',
sku: 'black-jacket',
images: [
'https://s3-eu-west-1.amazonaws.com/commercetools-maximilian/products/081223_1_large.jpg'
],
price: {
original: 12.34,
current: 10.00
},
qty: 1
}
];
export const getCartItems = (cart: Cart): CartItem[] => cart.items;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCartItemName = (product: any): string => product?.name || 'Product\'s name';
Expand All @@ -38,10 +19,10 @@ export const getCartItemPrice = (product: any): AgnosticPrice => {
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCartItemQty = (product: LineItem): number => 1;
export const getCartItemQty = (product: CartItem): number => 1;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCartItemAttributes = (product: LineItem, filterByAttributeName?: Array<string>) => ({ color: 'red' });
export const getCartItemAttributes = (product: CartItem, filterByAttributeName?: Array<string>) => ({ color: 'red' });

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCartItemSku = (product: any): string => product?.sku || 'some-sku';
Expand All @@ -58,17 +39,17 @@ export const getCartTotals = (cart: Cart): AgnosticTotals => {
export const getCartShippingPrice = (cart: Cart): number => 0;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCartTotalItems = (cart: Cart): number => 1;
export const getCartTotalItems = (cart: Cart): number => cart.items.length;

export const getFormattedPrice = (price: number) => String(price);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getCoupons = (cart: Cart): AgnosticCoupon[] => [];
export const getCoupons = (cart: Cart): AgnosticCoupon[] => cart.coupons;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getDiscounts = (cart: Cart): AgnosticDiscount[] => [];

const cartGetters: CartGetters<Cart, LineItem> = {
const cartGetters: CartGetters<Cart, CartItem> = {
getTotals: getCartTotals,
getShippingPrice: getCartShippingPrice,
getItems: getCartItems,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CategoryGetters, AgnosticCategoryTree } from '@vue-storefront/core';
import { Category } from '@vue-storefront/boilerplate-api/src/types';
import { Category } from '@vue-storefront/boilerplate-api';

const itemToTree = (category: Category): AgnosticCategoryTree => {
return {
Expand Down
14 changes: 5 additions & 9 deletions packages/boilerplate/composables/src/getters/checkoutGetters.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { CheckoutGetters} from '@vue-storefront/core';
import { ShippingMethod } from '@vue-storefront/boilerplate-api/src/types';
import { ShippingMethod } from '@vue-storefront/boilerplate-api';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getShippingMethodId = (shippingMethod: ShippingMethod): string => '';
export const getShippingMethodId = (shippingMethod: ShippingMethod): string => shippingMethod.id;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getShippingMethodName = (shippingMethod: ShippingMethod): string => '';
export const getShippingMethodName = (shippingMethod: ShippingMethod): string => shippingMethod.name;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getShippingMethodDescription = (shippingMethod: ShippingMethod): string => '';
export const getShippingMethodDescription = (shippingMethod: ShippingMethod): string => shippingMethod.description;

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getShippingMethodPrice = (shippingMethod: ShippingMethod): number => 0;
export const getShippingMethodPrice = (shippingMethod: ShippingMethod): number => shippingMethod.price;

export const getFormattedPrice = (price: number) => String(price);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */

import { UserOrderGetters } from '@vue-storefront/core';
import { Order, OrderItem } from '../types';
import { Order, OrderItem } from '@vue-storefront/boilerplate-api';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getDate = (order: any): string => order?.date || '123';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
AgnosticPrice,
ProductGetters
} from '@vue-storefront/core';
import { ProductVariant } from '@vue-storefront/boilerplate-api/src/types';
import { ProductVariant } from '@vue-storefront/boilerplate-api';

type ProductVariantFilters = any

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* istanbul ignore file */

import { UserGetters} from '@vue-storefront/core';
import { User } from '../types';
import { User } from '@vue-storefront/boilerplate-api';

export const getUserFirstName = (user: User): string => user?.firstName || '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
AgnosticPrice,
AgnosticTotals
} from '@vue-storefront/core';
import { Wishlist, WishlistProduct } from '../types';
import { Wishlist, WishlistProduct } from '@vue-storefront/boilerplate-api';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const getWishlistItems = (wishlist: Wishlist): WishlistProduct[] => [
Expand Down
Loading

0 comments on commit 1a50ce7

Please sign in to comment.