diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 930b15a9..f7017350 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,7 +10,7 @@ on: branches: [ main ] jobs: - build: + ci: runs-on: ubuntu-latest @@ -35,6 +35,26 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} - - run: DEBUG='none' npm run docker:test + - name: Create local config for tests + run: | + echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/local.js env: SOURCE_URL: ${{ secrets.SOURCE_URL }} + + - name: Start docker compose services + run: docker compose up -d + + - name: Show docker compose logs + run: docker compose logs --no-color --timestamps || true + + - name: Run setup + run: npm run setup + env: + SOURCE_URL: ${{ secrets.SOURCE_URL }} + DEBUG: 'none' + + - name: Run tests + run: npm run test:deprecated + env: + SOURCE_URL: ${{ secrets.SOURCE_URL }} + DEBUG: 'none' diff --git a/README.md b/README.md index 94c265d0..614e406d 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ $ npm run docker:test Turn off the docker container ```bash -$ docker-compose stop -$ docker-compose rm -f +$ docker compose stop +$ docker compose rm -f ``` Exec into the docker container diff --git a/docker-compose.yml b/docker-compose.yml index 0a4ffbae..3920923f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,11 @@ ############## Commands ########################## -### docker-compose up -d -### docker-compose logs -f +### docker compose up -d +### docker compose logs -f ### docker container list ############## Docs ############################## # https://hub.docker.com/_/couchdb -version: "3.7" services: couchdb: build: diff --git a/package.json b/package.json index 7b5747bb..5661e50d 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ }, "scripts": { "docker:build": "docker build -t fielddb-auth .", - "docker:test": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose up -d && docker compose logs && npm run setup && npm run test:deprecated", + "docker:test": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated", "docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && docker compose logs && npm run setup && npm run test:deprecated", "coverage": "NODE_ENV=test BUNYAN_LOG_LEVEL=FATAL NODE_TLS_REJECT_UNAUTHORIZED=0 nyc npm test", "coveralls": "cat ./coverage/lcov.info | coveralls", diff --git a/test/integration/install.js b/test/integration/install.js index cc06a65a..772fc8da 100644 --- a/test/integration/install.js +++ b/test/integration/install.js @@ -160,7 +160,7 @@ describe('install', () => { }); describe('new_testing_corpus', () => { - it.only('should replicate new_testing_corpus', () => { + it('should replicate new_testing_corpus', () => { const dbnameToReplicate = 'new_testing_corpus'; return supertest(destination) @@ -192,11 +192,45 @@ describe('install', () => { }) .then((res) => { debug('res.body new_testing_corpus design doc for data', res.body); - // FIXME: this design doc throws an error in CouchDB 3.x - // expect(res.body).to.deep.equal({ - // rows: [], - // }, JSON.stringify(res.body)); - expect(res.body.reason).to.equal('missing', JSON.stringify(res.body)); + expect(res.body).to.deep.equal({ + rows: [], + }, JSON.stringify(res.body)); + }); + }); + + it('should replicate the prototype couchapp', () => { + const dbnameToReplicate = 'prototype'; + + return supertest(destination) + .post('/_replicate') + .set('cookie', adminSessionCookie) + .set('Accept', 'application/json') + .send({ + source: `${source}/${dbnameToReplicate}`, + target: { + url: `${destination}/${dbnameToReplicate}`, + }, + create_target: true, + }) + .then((res) => { + debug('res.body prototype', res.body); + expect(res.body.ok).to.equal(true); + + return supertest(destination) + .get('/_all_dbs') + .set('Accept', 'application/json'); + }) + .then((res) => { + debug('res.body prototype after', res.body); + expect(res.body).includes(dbnameToReplicate); + + return supertest(destination) + .get(`/${dbnameToReplicate}/_design/prototype`) + .set('Accept', 'application/json'); + }) + .then((res) => { + debug('res.body prototype couchapp', res.body); + expect(res.body.couchapp.name).to.equal(' Prototype (has the most features of the apps)', JSON.stringify(res.body)); }); }); }); diff --git a/test/routes/deprecated-spec.js b/test/routes/deprecated-spec.js index 16467655..d9eb651e 100644 --- a/test/routes/deprecated-spec.js +++ b/test/routes/deprecated-spec.js @@ -33,7 +33,7 @@ describe('/ deprecated', () => { * - remove body because the body contains date created timestamps * - update username to equal the recorded username */ - it.only('should register a new user', () => { + it('should register a new user', () => { debug('username', testUsername); return supertest(authWebService) .post('/register') @@ -257,7 +257,7 @@ describe('/ deprecated', () => { describe('/login', () => { before(function () { - this.timeout(40000); + this.timeout(140000); return supertest(authWebService) .post('/register')