1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 12:49:43 +02:00

Add test libs, update dependencies

This commit is contained in:
Maksim Eltyshev 2020-08-20 15:35:46 +05:00
parent cd6d929cbf
commit 16acd1b49c
24 changed files with 1692 additions and 159 deletions

737
client/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,8 @@
},
"eslintConfig": {
"env": {
"browser": true
"browser": true,
"jest": true
},
"parser": "babel-eslint",
"plugins": [
@ -35,6 +36,15 @@
"prettier/react"
],
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"src/setupTests.js",
"**/*.test.js"
]
}
],
"prettier/prettier": [
"error",
{
@ -49,25 +59,25 @@
"classnames": "^2.2.6",
"connected-react-router": "^6.8.0",
"date-fns": "^2.15.0",
"dequal": "^1.0.1",
"dequal": "^2.0.2",
"history": "^4.10.1",
"i18next": "^19.6.3",
"i18next-browser-languagedetector": "^5.0.1",
"i18next": "^19.7.0",
"i18next-browser-languagedetector": "^6.0.1",
"initials": "^3.1.1",
"lodash": "^4.17.19",
"lodash": "^4.17.20",
"node-sass": "^4.14.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-beautiful-dnd": "^13.0.0",
"react-datepicker": "^3.1.3",
"react-dom": "^16.13.1",
"react-dropzone": "^11.0.2",
"react-dropzone": "^11.0.3",
"react-i18next": "^11.7.0",
"react-input-mask": "^2.0.4",
"react-markdown": "^4.3.1",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.2",
"react-scripts": "3.4.3",
"react-textarea-autosize": "^8.2.0",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
@ -75,20 +85,25 @@
"redux-saga": "^1.1.3",
"reselect": "^4.0.0",
"sails.io.js": "^1.2.1",
"semantic-ui-react": "^1.1.1",
"semantic-ui-react": "^1.2.1",
"socket.io-client": "^2.3.0",
"validator": "^13.1.1",
"whatwg-fetch": "^3.4.0"
},
"devDependencies": {
"chai": "^4.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.3",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"prettier": "2.0.5"
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"jest-enzyme": "^7.1.2",
"prettier": "2.0.5",
"react-test-renderer": "^16.13.1"
}
}

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import React, { useCallback, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import React, { useCallback, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import upperFirst from 'lodash/upperFirst';
import camelCase from 'lodash/camelCase';
import React, { useCallback, useEffect, useRef } from 'react';

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import React, { useCallback, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';

View file

@ -1,4 +1,4 @@
import dequal from 'dequal';
import { dequal } from 'dequal';
import pickBy from 'lodash/pickBy';
import React, { useCallback, useMemo, useRef } from 'react';
import PropTypes from 'prop-types';

6
client/src/setupTests.js Normal file
View file

@ -0,0 +1,6 @@
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import 'jest-enzyme';
configure({ adapter: new Adapter() });

View file

@ -0,0 +1,11 @@
import { isLocalId } from './local-id';
describe('isLocalId', () => {
test('is valid', () => {
expect(isLocalId('local:1234567890')).toBeTruthy();
});
test('is invalid', () => {
expect(isLocalId('1234567890')).toBeFalsy();
});
});

View file

@ -13,6 +13,7 @@
"client:build": "npm run build --prefix client",
"client:lint": "npm run lint --prefix client",
"client:start": "npm start --prefix client",
"client:test": "npm test --prefix client",
"lint": "npm run server:lint && npm run client:lint",
"postinstall": "npm i --prefix server && npm i --prefix client",
"server:console": "npm run console --prefix server",
@ -22,7 +23,9 @@
"server:lint": "npm run lint --prefix server",
"server:start": "npm start --prefix server",
"server:start:prod": "npm run start:prod --prefix server",
"start": "concurrently -n server,client \"npm run server:start\" \"npm run client:start\""
"server:test": "npm test --prefix server",
"start": "concurrently -n server,client \"npm run server:start\" \"npm run client:start\"",
"test": "npm run server:test && npm run client:test"
},
"husky": {
"hooks": {

View file

@ -15,18 +15,23 @@ module.exports.blueprints = {
* Automatically expose implicit routes for every action in your app?
*
*/
// actions: false,
/**
*
* Automatically expose RESTful routes for your models?
*
*/
// rest: true,
/**
*
* Automatically expose CRUD "shortcut" routes to GET requests?
* (These are enabled by default in development only.)
*
*/
// shortcuts: true,
shortcuts: false,
};

View file

@ -20,8 +20,6 @@
*/
const url = require('url');
const path = require('path');
const sails = require('sails');
module.exports = {
/**
@ -50,9 +48,8 @@ module.exports = {
*/
default: {
adapter: 'sails-postgresql',
url: process.env.DATABASE_URL,
// adapter: 'sails-mysql',
// url: 'mysql://user:password@host:port/database',
/**
*
* More adapter-specific options
@ -64,7 +61,6 @@ module.exports = {
* https://sailsjs.com/config/datastores
*
*/
// ssl: true,
},
},
@ -80,9 +76,7 @@ module.exports = {
* https://sailsjs.com/docs/concepts/models-and-orm/model-settings#?migrate
*
*/
migrate: 'safe',
// migrate: 'safe',
/**
*
* If, in production, this app has access to physical-layer CASCADE
@ -92,7 +86,6 @@ module.exports = {
* choose to keep this enabled.)
*
*/
// cascadeOnDestroy: false,
},
@ -107,7 +100,7 @@ module.exports = {
*/
blueprints: {
shortcuts: false,
// shortcuts: false,
},
/**
@ -199,8 +192,6 @@ module.exports = {
// secure: true,
maxAge: 24 * 60 * 60 * 1000, // 24 hours
},
secret: process.env.SECRET_KEY,
},
/**
@ -327,15 +318,7 @@ module.exports = {
*/
custom: {
baseUrl: process.env.BASE_URL,
userAvatarsPath: path.join(sails.config.paths.public, 'user-avatars'),
userAvatarsUrl: `${process.env.BASE_URL}/user-avatars`,
projectBackgroundImagesPath: path.join(sails.config.paths.public, 'project-background-images'),
projectBackgroundImagesUrl: `${process.env.BASE_URL}/project-background-images`,
attachmentsPath: path.join(sails.config.paths.public, 'attachments'),
attachmentsUrl: `${process.env.BASE_URL}/attachments`,
// baseUrl: 'https://example.com',
// internalEmailAddress: 'support@example.com',
},
};

70
server/config/env/test.js vendored Normal file
View file

@ -0,0 +1,70 @@
/**
* Test environment settings
* (sails.config.*)
*
* What you see below is a quick outline of the built-in settings you need
* to configure your Sails app for test. The configuration in this file
* is only used in your test environment, i.e. when you lift your app using:
*
* ```
* NODE_ENV=test node app
* ```
*
* > If you're using git as a version control solution for your Sails app,
* > this file WILL BE COMMITTED to your repository by default, unless you add
* > it to your .gitignore file. If your repository will be publicly viewable,
* > don't add private/sensitive data (like API secrets / db passwords) to this file!
*
* For more best practices and tips, see:
* https://sailsjs.com/docs/concepts/deployment
*/
module.exports = {
/**
*
* Tell Sails what database(s) it should use in test.
*
* (https://sailsjs.com/config/datastores)
*
*/
datastores: {
/**
*
* Configure your default test database.
*
* 1. Choose an adapter:
* https://sailsjs.com/plugins/databases
*
* 2. Install it as a dependency of your Sails app.
* (For example: npm install sails-mysql --save)
*
* 3. Then set it here (`adapter`), along with a connection URL (`url`)
* and any other, adapter-specific customizations.
* (See https://sailsjs.com/config/datastores for help.)
*
*/
default: {
adapter: 'sails-disk',
/**
*
* More adapter-specific options
*
* > For example, for some hosted PostgreSQL providers (like Heroku), the
* > extra `ssl: true` option is mandatory and must be provided.
*
* More info:
* https://sailsjs.com/config/datastores
*
*/
inMemoryOnly: true,
},
},
log: {
level: 'warn',
},
};

View file

@ -18,7 +18,7 @@ module.exports.session = {
*
*/
secret: '8b5b32787a446caa57c0a5abbb4ed6fe',
secret: process.env.SECRET_KEY,
/**
*

879
server/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,14 +4,13 @@
"main": "app.js",
"scripts": {
"console": "dotenv sails console",
"custom-tests": "echo \"(No other custom tests yet.)\" && echo",
"db:init": "node db/init.js",
"db:migrate": "knex migrate:latest --cwd db",
"db:seed": "knex seed:run --cwd db",
"lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
"start": "nodemon",
"start:prod": "node app.js --prod",
"test": "npm run lint && npm run custom-tests && echo 'Done.'"
"test": "mocha test/lifecycle.test.js test/integration/**/*.test.js"
},
"eslintConfig": {
"plugins": [
@ -44,8 +43,8 @@
"dotenv-cli": "^3.2.0",
"filenamify": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"knex": "^0.21.4",
"lodash": "^4.17.19",
"knex": "^0.21.5",
"lodash": "^4.17.20",
"moment": "^2.27.0",
"rimraf": "^3.0.2",
"sails": "^1.2.4",
@ -58,13 +57,16 @@
"validator": "^13.1.1"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^3.1.4",
"mocha": "^8.1.1",
"nodemon": "^2.0.4",
"prettier": "2.0.5"
"prettier": "2.0.5",
"supertest": "^4.0.2"
},
"engines": {
"node": "^12.10"

0
server/test/fixtures/.gitkeep vendored Normal file
View file

View file

View file

@ -0,0 +1,19 @@
const { expect } = require('chai');
describe('User (model)', () => {
before(async () => {
await User.create({
email: 'test@test.test',
password: 'test',
name: 'test',
});
});
describe('#find()', () => {
it('should return 1 user', async () => {
const users = await User.find();
expect(users).to.have.lengthOf(1);
});
});
});

View file

@ -0,0 +1,23 @@
const dotenv = require('dotenv');
const sails = require('sails');
const rc = require('sails/accessible/rc');
process.env.NODE_ENV = 'test';
before(function beforeCallback(done) {
this.timeout(5000);
dotenv.config();
sails.lift(rc('sails'), (error) => {
if (error) {
return done(error);
}
return done();
});
});
after(function afterCallback(done) {
sails.lower(done);
});

0
server/test/mocha.opts Normal file
View file