Skip to content

Commit

Permalink
Remove old commands and fix core tests (#6097)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsobol authored Aug 27, 2021
1 parent 3a0f69f commit 9fa3109
Show file tree
Hide file tree
Showing 24 changed files with 3,093 additions and 2,599 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ jobs:
- name: Build core
run: yarn build:core

- name: Test core
run: yarn test:core --coverage
- name: Test cache
run: yarn test:cache --coverage

- name: Test CLI
run: yarn test:cli --coverage

- name: Test core
run: yarn test:core --coverage

- name: Test middleware
run: yarn test:core --coverage

validate_integrations:
name: Validate ${{ matrix.integration }}
needs: validate_core
Expand Down
1 change: 0 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"baseUrl": "https://lovecrafts-demo.storefrontcloud.io/",
"viewportWidth": 1280,
"viewportHeight": 1024

}

24 changes: 8 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@
"build:core:core": "cd packages/core/core && yarn build",
"build:core:cache": "cd packages/core/cache && yarn build",
"build:core:middleware": "cd packages/core/middleware && yarn build",
"build:ct": "yarn build:core && yarn build:ct:tools && yarn build:ct:theme",
"build:ct": "yarn build:ct:tools && yarn build:ct:theme",
"build:ct:api-client": "cd packages/commercetools/api-client && yarn build",
"build:ct:composables": "cd packages/commercetools/composables && yarn build",
"build:ct:theme": "cd packages/commercetools/theme && yarn build",
"build:ct:tools": "yarn build:core && yarn build:ct:api-client && yarn build:ct:composables",
"build:docs": "cd packages/core/docs && yarn build",
"build:middleware": "cd packages/core/middleware && yarn build",
"build:sp": "yarn build:core && yarn build:sp:tools && yarn build:sp:theme",
"build:sp:tools": "yarn build:core && yarn build:sp:api-client && yarn build:sp:composables",
"build:spr": "yarn build:spr:tools && yarn build:spr:theme",
"build:spr:api-client": "cd packages/spryker/api-client && yarn build",
"build:spr:composables": "cd packages/spryker/composables && yarn build",
"build:spr:theme": "cd packages/spryker/theme && yarn build",
"build:spr:tools": "yarn build:core && yarn build:spr:api-client && yarn build:spr:composables",
"cli": "cd packages/core/cli && yarn cli",
"commit": "cz",
"core:changelog": "cd packages/core/docs/scripts && node changelog",
Expand All @@ -34,15 +27,14 @@
"dev:ct:api-client": "cd packages/commercetools/api-client && yarn dev",
"dev:ct:composables": "cd packages/commercetools/composables && yarn dev",
"dev:docs": "cd packages/core/docs && yarn dev",
"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",
"link-packages": "lerna link --force-local",
"lint": "eslint . --ext .js,.ts,.vue",
"release": "cd scripts && yarn release",
"start:bp": "cd packages/boilerplate/theme && yarn start",
"start:ct": "cd packages/commercetools/theme && yarn start",
"test:cache": "cd packages/core/cache && yarn test",
"test:cli": "cd packages/core/cli && yarn test",
"test:core": "jest -c ./packages/core/jest.config.js",
"test:core": "cd packages/core/core && yarn test",
"test:middleware": "cd packages/core/middleware && yarn test",
"test:ct": "yarn test:ct:api-client && yarn test:ct:composables",
"test:ct:api-client": "cd packages/commercetools/api-client && yarn test",
"test:ct:composables": "cd packages/commercetools/composables && yarn test",
Expand All @@ -61,7 +53,7 @@
"@commitlint/config-lerna-scopes": "^13.1.0",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-replace": "^2.3.3",
"@types/jest": "^24.0.23",
"@types/jest": "^26.0.24",
"@types/node": "^12.12.14",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
Expand All @@ -77,14 +69,14 @@
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "^7.6.0",
"husky": "^4.2.3",
"jest": "^24.9.0",
"jest": "^27.0.6",
"lerna": "^3.15.0",
"lint-staged": "^10.0.7",
"rimraf": "^3.0.2",
"rollup": "^1.25.2",
"rollup-plugin-terser": "^5.1.2",
"rollup-plugin-typescript2": "^0.30.0",
"ts-jest": "^24.2.0",
"ts-jest": "^27.0.3",
"ts-node": "^8.4.1",
"tslib": "^2.1.0",
"typescript": "^4.2.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/commercetools/composables/__tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require('jsdom-global')();
import Vue from 'vue';
import VueCompositionApi from '@vue/composition-api';

Vue.config.productionTip = false;
Vue.config.devtools = false;

Vue.use(VueCompositionApi);
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,9 @@ describe('[commercetools-composables] useStore factoryParams', () => {
it('changes selected store and reloads page', async () => {
const STORES_ID = 'stores id';

const location = {
reload: jest.fn()
};

const _window = jest.spyOn(
global, 'window', 'get'
);

_window.mockImplementation(function () {
return ({ location } as unknown) as Window & typeof globalThis;
Object.defineProperty(window, 'location', {
writable: true,
value: { reload: jest.fn() }
});

const storeService = {
Expand All @@ -71,6 +64,6 @@ describe('[commercetools-composables] useStore factoryParams', () => {

expect(await useStoreFactoryParams.change((context as unknown) as Context, (params as unknown) as UseStoreFactoryChangeParamArguments)).toBe(null);
expect(storeService.changeCurrentStore).toHaveBeenCalledWith(STORES_ID);
expect(location.reload).toHaveBeenCalled();
expect(window.location.reload).toHaveBeenCalled();
});
});
10 changes: 1 addition & 9 deletions packages/commercetools/composables/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@ const baseConfig = require('./../../jest.base.config');

module.exports = {
...baseConfig,
coverageReporters: ['html', 'lcov', 'text'],
rootDir: __dirname,
setupFilesAfterEnv: ['./__tests__/setup.ts'],
watchPathIgnorePatterns: ['/node_modules/'],
coveragePathIgnorePatterns: [
'/node_modules/',
'<rootDir>/src/context.d.ts',

// Ignore mocked composables
'UserBilling',
'UserShipping',

// TODO: https://github.com/DivanteLtd/vue-storefront/issues/5136
'<rootDir>/src/getters/cartGetters.ts',
'<rootDir>/src/getters/checkoutGetters.ts',
'<rootDir>/src/getters/userGetters.ts',
'<rootDir>/src/getters/productGetters.ts'
'UserShipping'
]
};
2 changes: 2 additions & 0 deletions packages/commercetools/composables/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
},
"devDependencies": {
"@vue/test-utils": "^1.0.0-beta.30",
"jsdom": "^16.6.0",
"jsdom-global": "^3.0.2",
"vue-template-compiler": "^2.6.x"
},
"publishConfig": {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/cache/src/composables/useCache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CacheTag, UseCache, SetTagsFn } from '..';
import { useContext } from '@nuxtjs/composition-api';

const useCache = (): UseCache => {
export const useCache = (): UseCache => {
const { req }: any = useContext();

if (!req) {
Expand Down Expand Up @@ -31,5 +31,3 @@ const useCache = (): UseCache => {
setTags
};
};

export default useCache;
2 changes: 1 addition & 1 deletion packages/core/cache/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @packageDocumentation
*/

export { default as useCache } from './composables/useCache';
export { useCache } from './composables/useCache';

export enum CacheTagPrefix {
Product = 'P',
Expand Down
4 changes: 4 additions & 0 deletions packages/core/core/__tests__/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* eslint-disable */
require('jsdom-global')();
import Vue from 'vue';
import VueCompositionApi, { ref } from '@vue/composition-api';

Vue.config.productionTip = false;
Vue.config.devtools = false;

Vue.use(VueCompositionApi);
jest.mock('lodash-es/merge', () => (arg1, arg2) => ({ ...arg1, ...arg2 }));

Expand Down
9 changes: 9 additions & 0 deletions packages/core/core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const baseConfig = require('./../../jest.base.config');

module.exports = {
...baseConfig,
collectCoverage: true,
setupFilesAfterEnv: [
'./__tests__/setup.ts'
]
};
11 changes: 7 additions & 4 deletions packages/core/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@
"scripts": {
"build": "rimraf lib && rollup -c rollup.config.js",
"dev": "rimraf lib && rollup -c rollup.config.js -w",
"test": "jest",
"prepublish": "yarn build"
},
"dependencies": {
"@vue/composition-api": "1.0.0-beta.21",
"vue": "^2.6.11",
"lodash-es": "^4.17.15",
"express": "^4.17.1",
"axios": "0.21.1",
"is-https": "^3.0.2"
"express": "^4.17.1",
"is-https": "^3.0.2",
"lodash-es": "^4.17.15",
"vue": "^2.6.11"
},
"devDependencies": {
"@types/express": "^4.11.1",
"@vue/test-utils": "^1.0.0-beta.30",
"jsdom": "^16.6.0",
"jsdom-global": "^3.0.2",
"vue-template-compiler": "^2.6.x"
},
"files": [
Expand Down
26 changes: 0 additions & 26 deletions packages/core/jest.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions packages/core/middleware/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const baseConfig = require('./../../jest.base.config');

module.exports = {
...baseConfig,
collectCoverage: true,
setupFilesAfterEnv: [
'./__tests__/setup.ts'
]
};
1 change: 1 addition & 0 deletions packages/core/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "rimraf lib && rollup -c",
"test": "jest",
"prepublish": "yarn build"
},
"author": "Vue Storefront",
Expand Down
3 changes: 3 additions & 0 deletions packages/jest.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ module.exports = {
'^.+\\.[jt]s$': 'ts-jest'
},
coverageDirectory: './coverage/',
coverageReporters: ['html', 'lcov', 'text'],
collectCoverageFrom: [
'src/**/*.ts'
],
moduleFileExtensions: ['ts', 'js', 'json'],
watchPathIgnorePatterns: ['**/node_modules'],
testMatch: ['<rootDir>/**/__tests__/**/*spec.[jt]s?(x)']
};
13 changes: 0 additions & 13 deletions scripts/package.json

This file was deleted.

33 changes: 0 additions & 33 deletions scripts/release/constants.ts

This file was deleted.

Loading

0 comments on commit 9fa3109

Please sign in to comment.