Skip to content

Commit

Permalink
test: add basic pull, diff and push tests (#43)
Browse files Browse the repository at this point in the history
* feat: add directus instance starter

* feat: working test bed with sample tests

* feat: add directus sync client

* chore: run format and lint

* chore: run format and lint

* test: empty pull

* test: empty pull

* test: test empty pull mutations

* chore: run prettier

* feat: add test for empty instance

* feat: add first pull test with data

* feat: test pull of collections

dashboards, flows, folders, operations, panels, permissions and roles

* feat: test pull of collections

presets, settings, translation and webhook

* fix: file import

* refactor: rename test basic

* refactor: rename test basic

* test: add 'Pull 2 times from an instance' tests

* refactor: create utils folder

* refactor: rename directus client test

* test: add pull and push without changes

* refactor: rename empty.spec.ts

* test: add "preserve ids" and "pull flush and push"

* test: fix some random failing tests

* fix: revert package-lock.json

* fix: remove unsupported node version from CI

* fix: copy env file before tests

* test: trigger cli programmatically

* test: remove unstable helpers test

* chore: add comment about debugging

* fix: eslint config

* ci: build before tests

* ci: increase jest timeout for ci

* ci: limit number of workers

* test: migration from a server to another

* fix: dependency issue on darwin-arm64

* fix: move dependency to dev

* fix: remove @nx/nx-darwin-arm64

* feat: use jasmine and run sequentially (#49)

* feat: allow import of directus-sync

* feat: first working test on one process

* chore: move directus instance to e2e

* feat: tests working individually

* chore: run prettier

* chore: cleanup cli package and remove e2e tests

* chore: cleanup api package

* chore: cleanup e2e deps

* chore: eslint config

* feat: avoid multiple server at once

* chore: prettier

* feat(e2e): working test suite (sequentially)

* chore(e2e): run prettier

* test(e2e): fix pullAndPushWithoutChanges

* build(e2e): fix ci

* build(e2e): fix ci

* chore: run prettier

* fix: x64 dependencies

* fix: x64 dependencies

* fix: change ts config per test env

* fix(e2e): append logs to file

* feat(e2e): add pushOnEmptyInstance

* feat(e2e): add pushOnEmptyInstance
  • Loading branch information
EdouardDem committed Apr 23, 2024
1 parent 50330c2 commit 02a357c
Show file tree
Hide file tree
Showing 115 changed files with 38,614 additions and 16,847 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env node */
module.exports = {
ignorePatterns: ['dist/', 'node_modules/', '*.js', '*.cjs', '*.mjs'],
ignorePatterns: ['dist/', 'node_modules/', 'directus/', '*.js', '*.cjs', '*.mjs'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked',
Expand All @@ -17,7 +17,9 @@ module.exports = {
root: true,
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -20,5 +20,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
- run: npm run test
# Build before testing. Tests needs the api package to be built
- run: npm run build
- run: npm run bootstrap
- run: npm run test
34,555 changes: 22,789 additions & 11,766 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lerna": "lerna",
"clean": "lerna clean",
"build": "lerna run build",
"bootstrap": "lerna run bootstrap",
"test": "lerna run test",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md,gql,mjs}\"",
"lint": "eslint --fix .",
Expand Down
8 changes: 8 additions & 0 deletions packages/api/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.spec.json',
},
],
},
};
1 change: 0 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"http-errors": "^2.0.0",
"jest": "^29.7.0",
"pino": "^8.19.0",
"sqlite3": "^5.1.7",
"ts-jest": "^29.1.2",
"typescript": "^5.4.2",
"zod": "^3.22.4"
Expand Down
6 changes: 6 additions & 0 deletions packages/api/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": ["jest", "node"]
}
}
1 change: 1 addition & 0 deletions packages/cli/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test/
.env
.gitignore
example.env
test.env
jest.config.js
tsconfig.json
directus-sync.config.*
3 changes: 2 additions & 1 deletion packages/cli/bin/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#! /usr/bin/env node
require('../dist');
const { run } = require('../dist');
void run();
3 changes: 2 additions & 1 deletion packages/cli/example.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DIRECTUS_URL=http://localhost:8055
DIRECTUS_TOKEN=xxxxxxxxxxxxx
DIRECTUS_ADMIN_EMAIL=admin@example.com
DIRECTUS_ADMIN_PASSWORD=password
8 changes: 8 additions & 0 deletions packages/cli/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.spec.json',
},
],
},
};
Loading

0 comments on commit 02a357c

Please sign in to comment.