diff --git a/Jenkinsfile b/Jenkinsfile index 03ac84de3..4a1f9ba54 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,13 +62,13 @@ pipeline { } } } - // stage('Backend') { - // steps { - // nodejs('node-v14') { - // sh 'gulp launchBackTest --ci' - // } - // } - // } + stage('Backend') { + steps { + nodejs('node-v14') { + sh 'npm run test:back:ci' + } + } + } } } stage('Build') { diff --git a/README.md b/README.md index 1e3ad5e9e..f73a8551b 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,17 @@ $ gulp docker For client-side unit tests run from project's root. ``` -$ jest +$ npm run test:front ``` For server-side unit tests run from project's root. ``` -$ gulp backTest +$ npm run test:back ``` For end-to-end tests run from project's root. ``` -$ gulp e2e +$ npm run test:e2e ``` ## Visual Studio Code extensions diff --git a/back/methods/account/specs/change-password.spec.js b/back/methods/account/specs/change-password.spec.js index 9f1130df5..17fadb3c6 100644 --- a/back/methods/account/specs/change-password.spec.js +++ b/back/methods/account/specs/change-password.spec.js @@ -1,9 +1,12 @@ -const app = require('vn-loopback/server/server'); +const {models} = require('vn-loopback/server/server'); describe('account changePassword()', () => { it('should throw an error when old password is wrong', async() => { - let req = app.models.Account.changePassword(null, 1, 'wrongOldPass', 'newPass'); + let err; + await models.Account.changePassword(1, 'wrongPassword', 'nightmare.9999') + .catch(error => err = error.sqlMessage); - await expectAsync(req).toBeRejected(); + expect(err).toBeDefined(); + expect(err).toEqual('Invalid password'); }); }); diff --git a/back/methods/collection/spec/newCollection.spec.js b/back/methods/collection/spec/newCollection.spec.js index 88d105b4b..6abe73f8e 100644 --- a/back/methods/collection/spec/newCollection.spec.js +++ b/back/methods/collection/spec/newCollection.spec.js @@ -1,8 +1,8 @@ const app = require('vn-loopback/server/server'); -// #3400 analizar que hacer con rutas de back colletion -xdescribe('newCollection()', () => { - it('return a new collection', async() => { +describe('newCollection()', () => { + it('should return a new collection', async() => { + pending('#3400 analizar que hacer con rutas de back collection'); let ctx = {req: {accessToken: {userId: 1106}}}; let response = await app.models.Collection.newCollection(ctx, 1, 1, 1); diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json new file mode 100644 index 000000000..a1c9ca84f --- /dev/null +++ b/back/nodemonConfig.json @@ -0,0 +1,24 @@ +{ + "verbose": true, + "watch": [ + "back/**/*.js", + "modules/**/*.js" + ], + "ignore": [ + "modules/account/front/**/*", + "modules/claim/front/**/*", + "modules/client/front/**/*", + "modules/entry/front/**/*", + "modules/invoiceIn/front/**/*", + "modules/invoiceOut/front/**/*", + "modules/item/front/**/*", + "modules/monitor/front/**/*", + "modules/order/front/**/*", + "modules/route/front/**/*", + "modules/supplier/front/**/*", + "modules/ticket/front/**/*", + "modules/travel/front/**/*", + "modules/worker/front/**/*", + "modules/zone/front/**/*" + ] +} \ No newline at end of file diff --git a/back/tests.js b/back/tests.js index c715c96bf..809906177 100644 --- a/back/tests.js +++ b/back/tests.js @@ -1,4 +1,5 @@ -require('require-yaml'); +const Docker = require('../db/docker.js'); +let dataSources = require('../loopback/server/datasources.json'); process.on('warning', warning => { console.log(warning.name); @@ -6,34 +7,64 @@ process.on('warning', warning => { console.log(warning.stack); }); -let verbose = false; +async function test() { + let isCI = false; -if (process.argv[2] === '--v') - verbose = true; + if (process.argv[2] === 'ci') + isCI = true; -let Jasmine = require('jasmine'); -let jasmine = new Jasmine(); -let SpecReporter = require('jasmine-spec-reporter').SpecReporter; + const container = new Docker(); -let serviceSpecs = [ - `${__dirname}/**/*[sS]pec.js`, - `${__dirname}/../loopback/**/*[sS]pec.js`, - `${__dirname}/../modules/*/back/**/*.[sS]pec.js` -]; + await container.run(isCI); + dataSources = JSON.parse(JSON.stringify(dataSources)); -jasmine.loadConfig({ - spec_dir: '.', - spec_files: serviceSpecs, - helpers: [] -}); + Object.assign(dataSources.vn, { + host: container.dbConf.host, + port: container.dbConf.port + }); -jasmine.addReporter(new SpecReporter({ - spec: { - // displayStacktrace: 'summary', - displaySuccessful: verbose, - displayFailedSpec: true, - displaySpecDuration: true + const bootOptions = {dataSources}; + const app = require('vn-loopback/server/server'); + app.boot(bootOptions); + + const Jasmine = require('jasmine'); + const jasmine = new Jasmine(); + + const SpecReporter = require('jasmine-spec-reporter').SpecReporter; + jasmine.addReporter(new SpecReporter({ + spec: { + displaySuccessful: isCI, + displayPending: isCI + }, + summary: { + displayPending: false, + } + })); + + if (isCI) { + const JunitReporter = require('jasmine-reporters'); + jasmine.addReporter(new JunitReporter.JUnitXmlReporter()); + + jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; } -})); -jasmine.execute(); + const backSpecs = [ + './back/**/*[sS]pec.js', + './loopback/**/*[sS]pec.js', + './modules/*/back/**/*.[sS]pec.js' + ]; + + jasmine.loadConfig({ + spec_dir: '.', + spec_files: backSpecs, + helpers: [], + }); + + jasmine.exitOnCompletion = false; + await jasmine.execute(); + if (app) await app.disconnect(); + if (container) await container.rm(); + console.log('app disconnected & container removed'); +} + +test(); diff --git a/db/docker.js b/db/docker.js index ea9fe8ed1..34026f85f 100644 --- a/db/docker.js +++ b/db/docker.js @@ -24,7 +24,10 @@ module.exports = class Docker { let d = new Date(); let pad = v => v < 10 ? '0' + v : v; let stamp = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; + + log('Building container image...'); await this.execP(`docker build --build-arg STAMP=${stamp} -t salix-db ./db`); + log('Image built.'); let dockerArgs; @@ -39,6 +42,7 @@ module.exports = class Docker { let runChown = process.platform != 'linux'; + log('Starting container...'); const container = await this.execP(`docker run --env RUN_CHOWN=${runChown} -d ${dockerArgs} salix-db`); this.id = container.stdout.trim(); @@ -158,6 +162,7 @@ module.exports = class Docker { return reject(new Error('Docker exited, please see the docker logs for more info')); let conn = mysql.createConnection(myConf); + conn.on('error', () => {}); conn.connect(err => { conn.destroy(); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 48f483450..29176489c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -983,7 +983,7 @@ export default { }, invoiceInTax: { addTaxButton: 'vn-invoice-in-tax vn-icon-button[vn-tooltip="Add tax"]', - thirdExpence: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.expenseFk"]', + thirdExpense: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.expenseFk"]', thirdTaxableBase: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-input-number[ng-model="invoiceInTax.taxableBase"]', thirdTaxType: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.taxTypeSageFk"]', thirdTransactionType: 'vn-invoice-in-tax vn-horizontal:nth-child(3) > vn-autocomplete[ng-model="invoiceInTax.transactionTypeSageFk"]', diff --git a/e2e/helpers/tests.js b/e2e/helpers/tests.js new file mode 100644 index 000000000..aac9963dd --- /dev/null +++ b/e2e/helpers/tests.js @@ -0,0 +1,87 @@ +require('@babel/register')({presets: ['@babel/env']}); +require('core-js/stable'); +require('regenerator-runtime/runtime'); + +const axios = require('axios'); +const Docker = require('../../db/docker.js'); +const e2eConfig = require('./config.js'); +const log = require('fancy-log'); + +process.on('warning', warning => { + console.log(warning.name); + console.log(warning.message); + console.log(warning.stack); +}); + +async function test() { + if (process.argv[2] === 'show') + process.env.E2E_SHOW = true; + + const container = new Docker('salix-db'); + + await container.run(); + + const Jasmine = require('jasmine'); + const jasmine = new Jasmine(); + + const specFiles = [ + `./e2e/paths/01*/*[sS]pec.js`, + `./e2e/paths/02*/*[sS]pec.js`, + `./e2e/paths/03*/*[sS]pec.js`, + `./e2e/paths/04*/*[sS]pec.js`, + `./e2e/paths/05*/*[sS]pec.js`, + `./e2e/paths/06*/*[sS]pec.js`, + `./e2e/paths/07*/*[sS]pec.js`, + `./e2e/paths/08*/*[sS]pec.js`, + `./e2e/paths/09*/*[sS]pec.js`, + `./e2e/paths/10*/*[sS]pec.js`, + `./e2e/paths/11*/*[sS]pec.js`, + `./e2e/paths/12*/*[sS]pec.js`, + `./e2e/paths/13*/*[sS]pec.js`, + `./e2e/paths/**/*[sS]pec.js` + ]; + + jasmine.loadConfig({ + spec_dir: '.', + spec_files: specFiles, + helpers: [], + random: false, + }); + + await backendStatus(); + + jasmine.jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; + await jasmine.execute(); +} + +async function backendStatus() { + log('Awaiting backend connection...'); + + const milliseconds = 1000; + const maxAttempts = 10; + + return new Promise(resolve => { + let timer; + let attempts = 1; + timer = setInterval(async() => { + try { + attempts++; + const url = `${e2eConfig.url}/api/Applications/status`; + const {data} = await axios.get(url); + + if (data == true) { + clearInterval(timer); + log('Backend connection stablished!'); + resolve(attempts); + } + } catch (error) { + if (error && attempts >= maxAttempts) { + log('Could not connect to backend'); + process.exit(); + } + } + }, milliseconds); + }); +} + +test(); diff --git a/e2e/paths/09-invoice-in/04_tax.spec.js b/e2e/paths/09-invoice-in/04_tax.spec.js index 364a25d7e..b1dbe2008 100644 --- a/e2e/paths/09-invoice-in/04_tax.spec.js +++ b/e2e/paths/09-invoice-in/04_tax.spec.js @@ -19,7 +19,7 @@ describe('InvoiceIn tax path', () => { it('should add a new tax', async() => { await page.waitToClick(selectors.invoiceInTax.addTaxButton); - await page.autocompleteSearch(selectors.invoiceInTax.thirdExpence, '6210000567'); + await page.autocompleteSearch(selectors.invoiceInTax.thirdExpense, '6210000567'); await page.write(selectors.invoiceInTax.thirdTaxableBase, '100'); await page.autocompleteSearch(selectors.invoiceInTax.thirdTaxType, '6'); await page.autocompleteSearch(selectors.invoiceInTax.thirdTransactionType, 'Operaciones exentas'); @@ -37,9 +37,9 @@ describe('InvoiceIn tax path', () => { expect(result).toEqual('Taxable base €1,323.16'); }); - it('should navigate back to the tax section and check the reciently added line contains the expected expense', async() => { + it('should navigate back to tax section, check the reciently added line contains the expected expense', async() => { await page.accessToSection('invoiceIn.card.tax'); - const result = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpence, 'value'); + const result = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpense, 'value'); expect(result).toEqual('6210000567: Alquiler VNH'); }); diff --git a/gulpfile.js b/gulpfile.js index 102a8a0bf..d7e7d8e86 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,8 +3,6 @@ const gulp = require('gulp'); const PluginError = require('plugin-error'); const argv = require('minimist')(process.argv.slice(2)); const log = require('fancy-log'); -const got = require('got'); -const e2eConfig = require('./e2e/helpers/config.js'); const Docker = require('./db/docker.js'); // Configuration @@ -67,187 +65,6 @@ back.description = `Starts backend and database service`; const defaultTask = gulp.parallel(front, back); defaultTask.description = `Starts all application services`; - -// Backend tests - Private method - -async function launchBackTest(done) { - let err; - let dataSources = require('./loopback/server/datasources.json'); - - const container = new Docker(); - await container.run(argv.ci); - - dataSources = JSON.parse(JSON.stringify(dataSources)); - - Object.assign(dataSources.vn, { - host: container.dbConf.host, - port: container.dbConf.port - }); - - let bootOptions = {dataSources}; - - let app = require(`./loopback/server/server`); - - try { - app.boot(bootOptions); - - await new Promise((resolve, reject) => { - const jasmine = require('gulp-jasmine'); - - const options = { - verbose: false, - includeStackTrace: false, - errorOnFail: false, - timeout: 5000, - config: {} - }; - - if (argv.ci) { - const reporters = require('jasmine-reporters'); - options.reporter = new reporters.JUnitXmlReporter(); - } - - let backSpecFiles = [ - 'back/**/*.spec.js', - 'loopback/**/*.spec.js', - 'modules/*/back/**/*.spec.js' - ]; - - gulp.src(backSpecFiles) - .pipe(jasmine(options)) - .on('end', resolve) - .on('error', reject) - .resume(); - }); - } catch (e) { - err = e; - } - await app.disconnect(); - await container.rm(); - done(); - if (err) - throw err; -} -launchBackTest.description = ` - Runs the backend tests once using a random container, can receive --ci arg to save reports on a xml file`; - -// Backend tests - -function backTest(done) { - const nodemon = require('gulp-nodemon'); - - nodemon({ - exec: ['node --tls-min-v1.0 ./node_modules/gulp/bin/gulp.js'], - args: ['launchBackTest'], - watch: backSources, - done: done - }); -} -backTest.description = `Watches for changes in modules to execute backTest task`; - -// End to end tests -function e2eSingleRun() { - require('@babel/register')({presets: ['@babel/env']}); - require('core-js/stable'); - require('regenerator-runtime/runtime'); - - const jasmine = require('gulp-jasmine'); - const SpecReporter = require('jasmine-spec-reporter').SpecReporter; - - if (argv.show || argv.s) - process.env.E2E_SHOW = true; - - const specFiles = [ - `${__dirname}/e2e/paths/01*/*[sS]pec.js`, - `${__dirname}/e2e/paths/02*/*[sS]pec.js`, - `${__dirname}/e2e/paths/03*/*[sS]pec.js`, - `${__dirname}/e2e/paths/04*/*[sS]pec.js`, - `${__dirname}/e2e/paths/05*/*[sS]pec.js`, - `${__dirname}/e2e/paths/06*/*[sS]pec.js`, - `${__dirname}/e2e/paths/07*/*[sS]pec.js`, - `${__dirname}/e2e/paths/08*/*[sS]pec.js`, - `${__dirname}/e2e/paths/09*/*[sS]pec.js`, - `${__dirname}/e2e/paths/10*/*[sS]pec.js`, - `${__dirname}/e2e/paths/11*/*[sS]pec.js`, - `${__dirname}/e2e/paths/12*/*[sS]pec.js`, - `${__dirname}/e2e/paths/13*/*[sS]pec.js`, - `${__dirname}/e2e/paths/**/*[sS]pec.js` - ]; - - return gulp.src(specFiles).pipe(jasmine({ - errorOnFail: false, - timeout: 30000, - config: { - random: false, - // TODO: Waiting for this option to be implemented - // https://github.com/jasmine/jasmine/issues/1533 - stopSpecOnExpectationFailure: false - }, - reporter: [ - new SpecReporter({ - spec: { - displayStacktrace: 'none', - displaySuccessful: true, - displayFailedSpec: true, - displaySpecDuration: true, - }, - summary: { - displayStacktrace: 'raw', - displayPending: false - }, - colors: { - enabled: true, - successful: 'brightGreen', - failed: 'brightRed' - }, - // stacktrace: { - // filter: stacktrace => { - // const lines = stacktrace.split('\n'); - // const filtered = []; - // for (let i = 1; i < lines.length; i++) { - // if (/e2e\/paths/.test(lines[i])) - // filtered.push(lines[i]); - // } - // return filtered.join('\n'); - // } - // } - }) - ] - })); -} - -e2e = gulp.series(docker, async function isBackendReady() { - const attempts = await backendStatus(); - log(`Backend ready after ${attempts} attempt(s)`); - - return attempts; -}, e2eSingleRun); -e2e.description = `Restarts database and runs the e2e tests`; - -async function backendStatus() { - const milliseconds = 250; - return new Promise(resolve => { - let timer; - let attempts = 1; - timer = setInterval(async() => { - try { - const url = `${e2eConfig.url}/api/Applications/status`; - const {body} = await got.get(url); - - if (body == 'true') { - clearInterval(timer); - resolve(attempts); - } else - attempts++; - } catch (error) { - if (error || attempts > 100) // 250ms * 100 => 25s timeout - throw new Error('Could not connect to backend'); - } - }, milliseconds); - }); -} -backendStatus.description = `Performs a simple requests to check the backend status`; - function install() { const install = require('gulp-install'); const print = require('gulp-print'); @@ -431,9 +248,6 @@ module.exports = { back, backOnly, backWatch, - backTest, - launchBackTest, - e2e, i, install, build, @@ -444,6 +258,5 @@ module.exports = { locales, localesRoutes, watch, - docker, - backendStatus, + docker }; diff --git a/jest.front.config.js b/jest.front.config.js index dbea13950..a03c61d11 100644 --- a/jest.front.config.js +++ b/jest.front.config.js @@ -47,5 +47,6 @@ module.exports = { '^.+\\.js?$': 'babel-jest', '^.+\\.html$': 'html-loader-jest' }, + reporters: ['default', 'jest-junit'] }; diff --git a/modules/client/back/methods/client/specs/updatePortfolio.spec.js b/modules/client/back/methods/client/specs/updatePortfolio.spec.js index 4830156fc..f56555c08 100644 --- a/modules/client/back/methods/client/specs/updatePortfolio.spec.js +++ b/modules/client/back/methods/client/specs/updatePortfolio.spec.js @@ -12,11 +12,13 @@ describe('Client updatePortfolio', () => { const expectedResult = 841.63; - await models.Client.rawSql(`UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clientId}; `); + const clientQuery = `UPDATE vn.client SET salesPersonFk = ${salesPersonId} WHERE id = ${clientId}; `; + await models.Client.rawSql(clientQuery); await models.Client.updatePortfolio(); - let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options); + const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `; + const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options); expect(salesPerson.portfolioWeight).toEqual(expectedResult); @@ -26,8 +28,9 @@ describe('Client updatePortfolio', () => { throw e; } }); - // task 3817 - xit('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { + + it('should keep the same portfolioWeight when a salesperson is unassigned of a client', async() => { + pending('task 3817'); const salesPersonId = 19; const tx = await models.Client.beginTransaction({}); @@ -40,7 +43,8 @@ describe('Client updatePortfolio', () => { await models.Client.updatePortfolio(); - let [salesPerson] = await models.Client.rawSql(`SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `, null, options); + const portfolioQuery = `SELECT portfolioWeight FROM bs.salesPerson WHERE workerFk = ${salesPersonId}; `; + const [salesPerson] = await models.Client.rawSql(portfolioQuery, null, options); expect(salesPerson.portfolioWeight).toEqual(expectedResult); diff --git a/modules/client/back/models/specs/address.spec.js b/modules/client/back/models/specs/address.spec.js index 81af6ee28..f0b421d35 100644 --- a/modules/client/back/models/specs/address.spec.js +++ b/modules/client/back/models/specs/address.spec.js @@ -14,7 +14,7 @@ describe('loopback model address', () => { } }; - beforeEach(() => { + beforeAll(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); diff --git a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js index edfdac988..41971a64c 100644 --- a/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js +++ b/modules/entry/back/methods/entry/specs/importBuysPreview.spec.js @@ -1,5 +1,6 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); +const activeCtx = {accessToken: {userId: 9}}; describe('entry importBuysPreview()', () => { const entryId = 1; diff --git a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js index 81686144d..ad4613caf 100644 --- a/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js +++ b/modules/route/back/methods/agency-term/specs/createInvoiceIn.spec.js @@ -1,7 +1,6 @@ const models = require('vn-loopback/server/server').models; -// Include after #3638 export database -xdescribe('AgencyTerm createInvoiceIn()', () => { +describe('AgencyTerm createInvoiceIn()', () => { const rows = [ { routeFk: 2, @@ -17,6 +16,7 @@ xdescribe('AgencyTerm createInvoiceIn()', () => { ]; it('should make an invoiceIn', async() => { + pending('Include after #3638 export database'); const tx = await models.AgencyTerm.beginTransaction({}); const options = {transaction: tx}; @@ -32,8 +32,12 @@ xdescribe('AgencyTerm createInvoiceIn()', () => { await models.AgencyTerm.createInvoiceIn(rows, dms, options); const [newInvoiceIn] = await models.InvoiceIn.rawSql('SELECT MAX(id) id FROM invoiceIn', null, options); - const [newInvoiceInDueDay] = await models.InvoiceInDueDay.rawSql('SELECT MAX(id) id FROM invoiceInDueDay', null, options); - const [newInvoiceInTax] = await models.InvoiceInTax.rawSql('SELECT MAX(id) id FROM invoiceInTax', null, options); + + const dueDayQuery = 'SELECT MAX(id) id FROM invoiceInDueDay'; + const [newInvoiceInDueDay] = await models.InvoiceInDueDay.rawSql(dueDayQuery, null, options); + + const taxQuery = 'SELECT MAX(id) id FROM invoiceInTax'; + const [newInvoiceInTax] = await models.InvoiceInTax.rawSql(taxQuery, null, options); expect(newInvoiceIn.id).toBeGreaterThan(oldInvoiceIn.id); expect(newInvoiceInDueDay.id).toBeGreaterThan(oldInvoiceInDueDay.id); diff --git a/modules/route/back/methods/route/specs/guessPriority.spec.js b/modules/route/back/methods/route/specs/guessPriority.spec.js index 892324acf..902647ba1 100644 --- a/modules/route/back/methods/route/specs/guessPriority.spec.js +++ b/modules/route/back/methods/route/specs/guessPriority.spec.js @@ -1,9 +1,21 @@ const app = require('vn-loopback/server/server'); +const LoopBackContext = require('loopback-context'); describe('route guessPriority()', () => { const targetRouteId = 7; let routeTicketsToRestore; + const activeCtx = { + accessToken: {userId: 9}, + __: () => {} + }; + + beforeAll(() => { + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); + }); + afterAll(async() => { let restoreFixtures = []; routeTicketsToRestore.forEach(ticket => { @@ -12,12 +24,9 @@ describe('route guessPriority()', () => { await Promise.all(restoreFixtures); }); - it('should call guessPriority() and then check the tickets in the target route now have their priorities defined', async() => { + it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => { const ctx = { - req: { - accessToken: {userId: 9}, - __: () => {} - }, + req: activeCtx }; routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}}); diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 04e1c140a..9b629e634 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -28,8 +28,9 @@ describe('ticket setDeleted()', () => { expect(error.message).toEqual('You must delete the claim id %d first'); }); - // test excluded by task #3693 - xit('should delete the ticket, remove the stowaway link and change the stowaway ticket state to "FIXING" and get rid of the itemshelving', async() => { + + it('should delete ticket, remove stowaway and itemshelving then change stowaway state to "FIXING" ', async() => { + pending('test excluded by task #3693'); const tx = await models.Ticket.beginTransaction({}); try { diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js index b4bfecbfb..aa92fa308 100644 --- a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js @@ -1,7 +1,6 @@ const app = require('vn-loopback/server/server'); -// #2687 - Cannot make a data rollback because of the triggers -xdescribe('Travel cloneWithEntries()', () => { +describe('Travel cloneWithEntries()', () => { const models = app.models; const travelId = 5; const currentUserId = 1102; @@ -9,44 +8,45 @@ xdescribe('Travel cloneWithEntries()', () => { let travelBefore; let newTravelId; - afterAll(async() => { - try { - const entries = await models.Entry.find({ - where: { - travelFk: newTravelId - } - }); - const entriesId = entries.map(entry => entry.id); + // afterAll(async() => { + // try { + // const entries = await models.Entry.find({ + // where: { + // travelFk: newTravelId + // } + // }); + // const entriesId = entries.map(entry => entry.id); - // Destroy all entries buys - await models.Buy.destroyAll({ - where: { - entryFk: {inq: entriesId} - } - }); + // // Destroy all entries buys + // await models.Buy.destroyAll({ + // where: { + // entryFk: {inq: entriesId} + // } + // }); - // Destroy travel entries - await models.Entry.destroyAll({ - where: { - travelFk: newTravelId - } - }); + // // Destroy travel entries + // await models.Entry.destroyAll({ + // where: { + // travelFk: newTravelId + // } + // }); - // Destroy new travel - await models.Travel.destroyById(newTravelId); + // // Destroy new travel + // await models.Travel.destroyById(newTravelId); - // Restore original travel shipped & landed - const travel = await models.Travel.findById(travelId); - await travel.updateAttributes({ - shipped: travelBefore.shipped, - landed: travelBefore.landed - }); - } catch (error) { - console.error(error); - } - }); + // // Restore original travel shipped & landed + // const travel = await models.Travel.findById(travelId); + // await travel.updateAttributes({ + // shipped: travelBefore.shipped, + // landed: travelBefore.landed + // }); + // } catch (error) { + // console.error(error); + // } + // }); it(`should clone the travel and the containing entries`, async() => { + pending('#2687 - Cannot make a data rollback because of the triggers'); const warehouseThree = 3; const agencyModeOne = 1; const yesterday = new Date(); diff --git a/package.json b/package.json index 35c27fc0c..52741641a 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "gulp-env": "^0.4.0", "gulp-file": "^0.4.0", "gulp-install": "^1.1.0", - "gulp-jasmine": "^4.0.0", "gulp-merge-json": "^1.3.1", "gulp-nodemon": "^2.5.0", "gulp-print": "^2.0.1", @@ -78,7 +77,7 @@ "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^4.0.0-beta.11", "identity-obj-proxy": "^3.0.0", - "jasmine": "^3.10.0", + "jasmine": "^4.1.0", "jasmine-reporters": "^2.4.0", "jasmine-spec-reporter": "^7.0.0", "jest": "^26.0.1", @@ -88,7 +87,7 @@ "minimist": "^1.2.5", "mysql2": "^1.7.0", "node-sass": "^4.14.1", - "nodemon": "^1.19.4", + "nodemon": "^2.0.16", "plugin-error": "^1.0.1", "raw-loader": "^1.0.0", "regenerator-runtime": "^0.13.7", @@ -102,7 +101,10 @@ }, "scripts": { "dbtest": "nodemon -q db/tests.js -w db/tests", - "test": "jest --watch", + "test:back": "nodemon -q back/tests.js --config back/nodemonConfig.json", + "test:back:ci": "node back/tests.js ci", + "test:e2e": "node e2e/helpers/tests.js", + "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", "docker": "docker build --progress=plain -t salix-db ./db"