From 4a06b8e8a90a081726d88f9ae62833531501ce83 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 23 Jan 2023 15:16:42 +0100 Subject: [PATCH] fix: import date.js and fix e2e --- db/dump/fixtures.sql | 2 +- e2e/helpers/puppeteer.js | 1 + e2e/paths/02-client/14_balance.spec.js | 2 +- front/core/services/date.js | 13 +++++-------- front/salix/index.ejs | 2 +- front/salix/index.js | 2 +- front/salix/services/index.js | 15 --------------- jest-front.js | 15 ++++----------- jest.front.config.js | 1 + 9 files changed, 15 insertions(+), 38 deletions(-) delete mode 100644 front/salix/services/index.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 599a6dac9..6d88d53cb 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2,7 +2,7 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; UPDATE `util`.`config` - SET `environment`= 'test'; + SET `environment`= 'development'; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index abd76b434..3e7643839 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -2,6 +2,7 @@ import Puppeteer from 'puppeteer'; import {extendPage} from './extensions'; import {url as defaultURL} from './config'; +import 'vn-loopback/server/boot/date.js'; export async function getBrowser() { const args = [ diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index 7906fc021..d3de842e3 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Client balance path', () => { +describe('Client balance path', () => { let browser; let page; beforeAll(async() => { diff --git a/front/core/services/date.js b/front/core/services/date.js index 977d77430..3b7193d7b 100644 --- a/front/core/services/date.js +++ b/front/core/services/date.js @@ -1,16 +1,13 @@ -Date.vnUTC = () => { - const env = process.env.NODE_ENV; - if (!env || env === 'development') - return new Date(Date.UTC(2022, 5, 15, 11)); +// try import 'vn-loopback/server/boot/date'; - return new Date(Date.UTC()); +Date.vnUTC = () => { + return new Date(Date.UTC(2022, 5, 15, 11)); }; Date.vnNew = () => { - return new Date(Date.vnUTC()); + return new Date(Date.UTC(2022, 5, 15, 11)); }; Date.vnNow = () => { - return new Date(Date.vnUTC()).getTime(); + return new Date(Date.UTC(2022, 5, 15, 11)).getTime(); }; - diff --git a/front/salix/index.ejs b/front/salix/index.ejs index 1c13c3541..3aed9d9a6 100644 --- a/front/salix/index.ejs +++ b/front/salix/index.ejs @@ -10,7 +10,7 @@ diff --git a/front/salix/index.js b/front/salix/index.js index 5220f36f6..2488ef9b6 100644 --- a/front/salix/index.js +++ b/front/salix/index.js @@ -1,5 +1,5 @@ import './module'; import './routes'; import './components'; -import './services'; import './styles'; +import 'vn-loopback/server/boot/date'; diff --git a/front/salix/services/index.js b/front/salix/services/index.js deleted file mode 100644 index 6d510638f..000000000 --- a/front/salix/services/index.js +++ /dev/null @@ -1,15 +0,0 @@ -Date.vnUTC = () => { - const env = process.env.NODE_ENV; - if (!env || env === 'development') - return new Date(Date.UTC(2000, 0, 1, 11)); - - return new Date(Date.UTC()); -}; - -Date.vnNew = () => { - return new Date(Date.vnUTC()); -}; - -Date.vnNow = () => { - return new Date(Date.vnUTC()).getTime(); -}; diff --git a/jest-front.js b/jest-front.js index 0a2db5ec1..eabda9110 100644 --- a/jest-front.js +++ b/jest-front.js @@ -14,6 +14,10 @@ import './modules/ticket/front/module.js'; import './modules/travel/front/module.js'; import './modules/worker/front/module.js'; import './modules/shelving/front/module.js'; +import 'vn-loopback/server/boot/date'; + +// Set NODE_ENV +process.env.NODE_ENV = 'development'; core.run(vnInterceptor => { vnInterceptor.setApiPath(null); @@ -37,17 +41,6 @@ window.ngModule = function(moduleName, ...args) { if (args.length) fns = fns.concat(args); - Date.vnUTC = () => { - return new Date(Date.UTC(2022, 5, 15, 11)); - }; - - Date.vnNew = () => { - return new Date(Date.UTC(2022, 5, 15, 11)); - }; - - Date.vnNow = () => { - return new Date(Date.UTC(2022, 5, 15, 11)).getTime(); - }; return angular.mock.module(...fns); }; diff --git a/jest.front.config.js b/jest.front.config.js index a03c61d11..3289df8bb 100644 --- a/jest.front.config.js +++ b/jest.front.config.js @@ -1,5 +1,6 @@ // For a detailed explanation regarding each configuration property, visit: // https://jestjs.io/docs/en/configuration.html +/* eslint max-len: ["error", { "code": 150 }]*/ module.exports = { name: 'front end',