chore: Integration tests
parent
e31d1ebca0
commit
2b61463060
|
@ -3,4 +3,4 @@
|
|||
**/build
|
||||
**/config
|
||||
**/scripts
|
||||
**/xsl
|
||||
**/playground
|
||||
|
|
|
@ -4,8 +4,10 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
|
@ -21,9 +23,35 @@ jobs:
|
|||
node-version: ${{ matrix.node }}
|
||||
cache: 'yarn'
|
||||
- name: Install dependencies
|
||||
run: yarn --ignore-scripts --frozen-lockfile
|
||||
run: yarn --frozen-lockfile
|
||||
- name: Run eslint
|
||||
run: yarn run eslint
|
||||
integration:
|
||||
name: 'integration'
|
||||
needs: [lint]
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node: [12, 14, 16]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: 'yarn'
|
||||
- name: Install dependencies plugin
|
||||
run: yarn --frozen-lockfile --unsafe-perm
|
||||
- name: Install dependencies playground
|
||||
run: yarn playground:install --frozen-lockfile --unsafe-perm
|
||||
- name: Run test
|
||||
run: yarn run -s test:integration
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV }}
|
||||
flags: unit
|
||||
verbose: true
|
||||
fail_ci_if_error: true
|
||||
# unit:
|
||||
# name: 'unit'
|
||||
# needs: [lint]
|
||||
|
|
|
@ -23,7 +23,7 @@ git clone git@github.com:YOUR_USERNAME/strapi-plugin-config-sync.git config-sync
|
|||
Go to the plugin and install it's dependencies.
|
||||
|
||||
```bash
|
||||
cd YOUR_STRAPI_PROJECT/src/plugins/config-sync/ && yarn install-local
|
||||
cd YOUR_STRAPI_PROJECT/src/plugins/config-sync/ && yarn plugin:install
|
||||
```
|
||||
|
||||
#### 4. Enable the plugin
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
"eslint": "eslint --max-warnings=0 './**/*.{js,jsx}'",
|
||||
"eslint:fix": "eslint --fix './**/*.{js,jsx}'",
|
||||
"test:unit": "jest --verbose",
|
||||
"install-local": "yarn install && rm -rf node_modules/@strapi/helper-plugin"
|
||||
"test:integration": "cd playground && jest --verbose",
|
||||
"plugin:install": "yarn install && rm -rf node_modules/@strapi/helper-plugin",
|
||||
"playground:install": "cd playground && yarn install",
|
||||
"playground:build": "cd playground && yarn build --clean",
|
||||
"playground:develop": "cd playground && yarn develop"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[{package.json,*.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
|
@ -0,0 +1,2 @@
|
|||
HOST=0.0.0.0
|
||||
PORT=1337
|
|
@ -0,0 +1,3 @@
|
|||
.cache
|
||||
build
|
||||
**/node_modules/**
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"parser": "babel-eslint",
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"browser": false
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true,
|
||||
"jsx": false
|
||||
},
|
||||
"sourceType": "module"
|
||||
},
|
||||
"globals": {
|
||||
"strapi": true
|
||||
},
|
||||
"rules": {
|
||||
"indent": ["error", 2, { "SwitchCase": 1 }],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"no-console": 0,
|
||||
"quotes": ["error", "single"],
|
||||
"semi": ["error", "always"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
############################
|
||||
# OS X
|
||||
############################
|
||||
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
._*
|
||||
|
||||
|
||||
############################
|
||||
# Linux
|
||||
############################
|
||||
|
||||
*~
|
||||
|
||||
|
||||
############################
|
||||
# Windows
|
||||
############################
|
||||
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
Desktop.ini
|
||||
$RECYCLE.BIN/
|
||||
*.cab
|
||||
*.msi
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
|
||||
############################
|
||||
# Packages
|
||||
############################
|
||||
|
||||
*.7z
|
||||
*.csv
|
||||
*.dat
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.seed
|
||||
*.so
|
||||
*.swo
|
||||
*.swp
|
||||
*.swn
|
||||
*.swm
|
||||
*.out
|
||||
*.pid
|
||||
|
||||
|
||||
############################
|
||||
# Logs and databases
|
||||
############################
|
||||
|
||||
.tmp
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
*.sqlite3
|
||||
|
||||
|
||||
############################
|
||||
# Misc.
|
||||
############################
|
||||
|
||||
*#
|
||||
ssl
|
||||
.idea
|
||||
nbproject
|
||||
public/uploads/*
|
||||
!public/uploads/.gitkeep
|
||||
|
||||
############################
|
||||
# Node.js
|
||||
############################
|
||||
|
||||
lib-cov
|
||||
lcov.info
|
||||
pids
|
||||
logs
|
||||
results
|
||||
node_modules
|
||||
.node_history
|
||||
|
||||
############################
|
||||
# Tests
|
||||
############################
|
||||
|
||||
testApp
|
||||
coverage
|
||||
|
||||
############################
|
||||
# Strapi
|
||||
############################
|
||||
|
||||
.env
|
||||
license.txt
|
||||
exports
|
||||
*.cache
|
||||
build
|
||||
.strapi-updater.json
|
|
@ -0,0 +1,3 @@
|
|||
# Strapi application
|
||||
|
||||
A quick description of your strapi application
|
|
@ -0,0 +1,22 @@
|
|||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
jest.setTimeout(20000);
|
||||
|
||||
describe('Test the config-sync CLI', () => {
|
||||
test('Export', async () => {
|
||||
const { stdout } = await exec('yarn cs export -y');
|
||||
expect(stdout).toContain('Finished export');
|
||||
});
|
||||
test('Import', async () => {
|
||||
await exec('rm -rf config/sync/admin-role.strapi-editor.json');
|
||||
const { stdout } = await exec('yarn cs import -y');
|
||||
expect(stdout).toContain('Finished import');
|
||||
});
|
||||
test('Diff', async () => {
|
||||
const { stdout } = await exec('yarn cs diff');
|
||||
expect(stdout).toContain('No differences between DB and sync directory');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
module.exports = ({ env }) => ({
|
||||
auth: {
|
||||
secret: env('ADMIN_JWT_SECRET', 'c27c3833823a12b0761e32b22dc0113a'),
|
||||
},
|
||||
watchIgnoreFiles: [
|
||||
'**/config/sync/**',
|
||||
],
|
||||
});
|
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
rest: {
|
||||
defaultLimit: 25,
|
||||
maxLimit: 100,
|
||||
withCount: true,
|
||||
},
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
const path = require('path');
|
||||
|
||||
module.exports = ({ env }) => ({
|
||||
connection: {
|
||||
client: 'sqlite',
|
||||
connection: {
|
||||
filename: path.join(__dirname, '..', env('DATABASE_FILENAME', '.tmp/data.db')),
|
||||
},
|
||||
useNullAsDefault: true,
|
||||
},
|
||||
});
|
|
@ -0,0 +1,11 @@
|
|||
module.exports = [
|
||||
'strapi::errors',
|
||||
'strapi::security',
|
||||
'strapi::cors',
|
||||
'strapi::poweredBy',
|
||||
'strapi::logger',
|
||||
'strapi::query',
|
||||
'strapi::body',
|
||||
'strapi::favicon',
|
||||
'strapi::public',
|
||||
];
|
|
@ -0,0 +1,10 @@
|
|||
module.exports = ({ env }) => ({
|
||||
'config-sync': {
|
||||
config: {
|
||||
excludedConfig: [
|
||||
'core-store.plugin_users-permissions_grant',
|
||||
'user-role.public',
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = ({ env }) => ({
|
||||
host: env('HOST', '0.0.0.0'),
|
||||
port: env.int('PORT', 1337),
|
||||
});
|
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
|
@ -0,0 +1,7 @@
|
|||
module.exports = {
|
||||
name: 'Integration test',
|
||||
testMatch: ['**/__tests__/?(*.)+(spec|test).js'],
|
||||
transform: {},
|
||||
coverageDirectory: '../coverage/',
|
||||
collectCoverage: true,
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "playground",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"description": "A Strapi application",
|
||||
"scripts": {
|
||||
"develop": "strapi develop",
|
||||
"start": "strapi start",
|
||||
"build": "strapi build",
|
||||
"strapi": "strapi",
|
||||
"cs": "config-sync"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^26.0.1",
|
||||
"jest-cli": "^26.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/plugin-i18n": "4.0.2",
|
||||
"@strapi/plugin-users-permissions": "4.0.2",
|
||||
"@strapi/strapi": "4.0.2",
|
||||
"sqlite3": "5.0.2",
|
||||
"strapi-plugin-config-sync": "boazpoolman/strapi-plugin-config-sync"
|
||||
},
|
||||
"author": {
|
||||
"name": "A Strapi developer"
|
||||
},
|
||||
"strapi": {
|
||||
"uuid": "2e84e366-1e09-43c2-a99f-a0d0acbc2ca5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.x.x <=16.x.x",
|
||||
"npm": ">=6.0.0"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
# To prevent search engines from seeing the site altogether, uncomment the next two lines:
|
||||
# User-Agent: *
|
||||
# Disallow: /
|
|
@ -0,0 +1,35 @@
|
|||
export default {
|
||||
config: {
|
||||
locales: [
|
||||
// 'ar',
|
||||
// 'fr',
|
||||
// 'cs',
|
||||
// 'de',
|
||||
// 'dk',
|
||||
// 'es',
|
||||
// 'he',
|
||||
// 'id',
|
||||
// 'it',
|
||||
// 'ja',
|
||||
// 'ko',
|
||||
// 'ms',
|
||||
// 'nl',
|
||||
// 'no',
|
||||
// 'pl',
|
||||
// 'pt-BR',
|
||||
// 'pt',
|
||||
// 'ru',
|
||||
// 'sk',
|
||||
// 'sv',
|
||||
// 'th',
|
||||
// 'tr',
|
||||
// 'uk',
|
||||
// 'vi',
|
||||
// 'zh-Hans',
|
||||
// 'zh',
|
||||
],
|
||||
},
|
||||
bootstrap(app) {
|
||||
console.log(app);
|
||||
},
|
||||
};
|
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
module.exports = (config, webpack) => {
|
||||
// Note: we provide webpack above so you should not `require` it
|
||||
// Perform customizations to webpack config
|
||||
// Important: return the modified config
|
||||
return config;
|
||||
};
|
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* An asynchronous register function that runs before
|
||||
* your application is initialized.
|
||||
*
|
||||
* This gives you an opportunity to extend code.
|
||||
*/
|
||||
register(/*{ strapi }*/) {},
|
||||
|
||||
/**
|
||||
* An asynchronous bootstrap function that runs before
|
||||
* your application gets started.
|
||||
*
|
||||
* This gives you an opportunity to set up your data model,
|
||||
* run jobs, or perform some special logic.
|
||||
*/
|
||||
bootstrap(/*{ strapi }*/) {},
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -6,15 +6,15 @@ const ConfigType = class ConfigType {
|
|||
constructor({ queryString, configName, uid, jsonFields, relations }) {
|
||||
if (!configName) {
|
||||
strapi.log.error(logMessage('A config type was registered without a config name.'));
|
||||
return;
|
||||
process.exit(0);
|
||||
}
|
||||
if (!queryString) {
|
||||
strapi.log.error(logMessage(`No query string found for the '${configName}' config type.`));
|
||||
return;
|
||||
process.exit(0);
|
||||
}
|
||||
if (!uid) {
|
||||
strapi.log.error(logMessage(`No uid found for the '${configName}' config type.`));
|
||||
return;
|
||||
process.exit(0);
|
||||
}
|
||||
this.queryString = queryString;
|
||||
this.configPrefix = configName;
|
||||
|
|
Loading…
Reference in New Issue