diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9a3b375 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,27 @@ +name: Tests + +on: + pull_request: + branches: [main] + push: + branches: [main] + workflow_dispatch: + +jobs: + test: + strategy: + matrix: + version: [20, 18] + platform: [ macos-latest, ubuntu-latest, windows-latest ] + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.version }} + + - name: Run Tests + run: | + npm install + npm run test diff --git a/.gitignore b/.gitignore index e43b0f9..58b805f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +node_modules/ \ No newline at end of file diff --git a/cds-plugin.js b/cds-plugin.js index 1fe38b1..f0490a3 100644 --- a/cds-plugin.js +++ b/cds-plugin.js @@ -1,4 +1,4 @@ -const cds = require('@sap/cds/lib') +const cds = require('@sap/cds') const isChangeTracked = (entity) => ( entity['@changelog'] || entity['@changelog.keys'] diff --git a/package.json b/package.json index 1772893..c91342d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "build": "cds build", "start": "cds run", - "test": "npx jest" + "test": "npx jest --silent" }, "devDependencies": { "@cap-js/sqlite": "*", diff --git a/tests/bookshop/package.json b/tests/bookshop/package.json index 9423d10..9de7f52 100644 --- a/tests/bookshop/package.json +++ b/tests/bookshop/package.json @@ -1,6 +1,6 @@ { - "dependencies": { - "@cap-js/change-tracking": "*" + "devDependencies": { + "@cap-js/sqlite": "*" }, "cds": { "requires": { diff --git a/tests/integration/fiori-draft-disabled.test.js b/tests/integration/fiori-draft-disabled.test.js index ab6d898..1350c7e 100644 --- a/tests/integration/fiori-draft-disabled.test.js +++ b/tests/integration/fiori-draft-disabled.test.js @@ -2,6 +2,12 @@ const cds = require("@sap/cds"); const bookshop = require("path").resolve(__dirname, "./../bookshop"); const { expect, data, POST, PATCH, DELETE } = cds.test(bookshop); +// REVISIT: should be easier to load the plugin and its model +cds.env.plugins["@cap-js/change-tracking"] = { + "impl": require("path").join(__dirname, "../../cds-plugin.js") +} +cds.env.roots.push("../../"); + jest.setTimeout(5 * 60 * 1000); let adminService = null; diff --git a/tests/integration/fiori-draft-enabled.test.js b/tests/integration/fiori-draft-enabled.test.js index 0745f8f..af200a6 100644 --- a/tests/integration/fiori-draft-enabled.test.js +++ b/tests/integration/fiori-draft-enabled.test.js @@ -3,6 +3,12 @@ const bookshop = require("path").resolve(__dirname, "./../bookshop"); const { expect, data, POST, PATCH, DELETE } = cds.test(bookshop); const { RequestSend } = require("../utils/api"); +// REVISIT: should be easier to load the plugin and its model +cds.env.plugins["@cap-js/change-tracking"] = { + "impl": require("path").join(__dirname, "../../cds-plugin.js") +} +cds.env.roots.push("../../"); + jest.setTimeout(5 * 60 * 1000); let adminService = null; diff --git a/tests/integration/service-api.test.js b/tests/integration/service-api.test.js index e51f176..ef0817c 100644 --- a/tests/integration/service-api.test.js +++ b/tests/integration/service-api.test.js @@ -2,6 +2,12 @@ const cds = require("@sap/cds"); const bookshop = require("path").resolve(__dirname, "./../bookshop"); const { expect, data } = cds.test(bookshop); +// REVISIT: should be easier to load the plugin and its model +cds.env.plugins["@cap-js/change-tracking"] = { + "impl": require("path").join(__dirname, "../../cds-plugin.js") +} +cds.env.roots.push("../../"); + jest.setTimeout(5 * 60 * 1000); let adminService = null;