diff --git a/InfoLogger/lib/JSONFileConnector.js b/InfoLogger/lib/JSONFileConnector.js index 92ccd6b30..34f0cbcd9 100644 --- a/InfoLogger/lib/JSONFileConnector.js +++ b/InfoLogger/lib/JSONFileConnector.js @@ -12,7 +12,7 @@ * or submit itself to any jurisdiction. */ -const logger = (require('@aliceo2/web-ui').LogManager) +const logger = require('@aliceo2/web-ui').LogManager .getLogger(`${process.env.npm_config_log_label ?? 'ilg'}/json`); const fs = require('fs'); const path = require('path'); diff --git a/InfoLogger/lib/ProfileService.js b/InfoLogger/lib/ProfileService.js index f83617bc5..ce0801542 100644 --- a/InfoLogger/lib/ProfileService.js +++ b/InfoLogger/lib/ProfileService.js @@ -12,7 +12,7 @@ * or submit itself to any jurisdiction. */ -const logger = (require('@aliceo2/web-ui').LogManager) +const logger = require('@aliceo2/web-ui').LogManager .getLogger(`${process.env.npm_config_log_label ?? 'ilg'}/profile`); /** diff --git a/InfoLogger/lib/SQLDataSource.js b/InfoLogger/lib/SQLDataSource.js index 7a83f9d67..b5b32cc9e 100644 --- a/InfoLogger/lib/SQLDataSource.js +++ b/InfoLogger/lib/SQLDataSource.js @@ -12,7 +12,7 @@ * or submit itself to any jurisdiction. */ -const logger = (require('@aliceo2/web-ui').LogManager) +const logger = require('@aliceo2/web-ui').LogManager .getLogger(`${process.env.npm_config_log_label ?? 'ilg'}/sql`); module.exports = class SQLDataSource { diff --git a/InfoLogger/lib/StatusService.js b/InfoLogger/lib/StatusService.js index f6c63d34d..271836541 100644 --- a/InfoLogger/lib/StatusService.js +++ b/InfoLogger/lib/StatusService.js @@ -12,7 +12,7 @@ * or submit itself to any jurisdiction. */ -const logger = (require('@aliceo2/web-ui').LogManager) +const logger = require('@aliceo2/web-ui').LogManager .getLogger(`${process.env.npm_config_log_label ?? 'ilg'}/status`); /** diff --git a/InfoLogger/package-lock.json b/InfoLogger/package-lock.json index 76b8664d7..a091a8b03 100644 --- a/InfoLogger/package-lock.json +++ b/InfoLogger/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aliceo2/infologger", - "version": "1.13.1", + "version": "1.13.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@aliceo2/infologger", - "version": "1.13.1", + "version": "1.13.2", "bundleDependencies": [ "@aliceo2/web-ui" ], diff --git a/InfoLogger/package.json b/InfoLogger/package.json index eefa48875..62a431dad 100644 --- a/InfoLogger/package.json +++ b/InfoLogger/package.json @@ -1,6 +1,6 @@ { "name": "@aliceo2/infologger", - "version": "1.13.1", + "version": "1.13.2", "description": "Infologger GUI to query and stream log events", "author": "Vladimir Kosmala", "contributors": [ @@ -22,7 +22,7 @@ "test": "npm run eslint && npm run mocha", "dev": "nodemon --watch index.js --watch lib --watch config.js index.js", "simul": "node test/live-simulator/infoLoggerServer.js", - "eslint": "./node_modules/.bin/eslint --config eslint.config.js lib/ public/ --fix", + "eslint": "./node_modules/.bin/eslint --config eslint.config.js lib/ public/", "mocha": "mocha --exit $(find test -name 'mocha-*.js')", "coverage": "npm run eslint && nyc npm run mocha", "coverage-local": "nyc --reporter=lcov npm run mocha", diff --git a/InfoLogger/test/integration/ilg-query-tests.js b/InfoLogger/test/integration/ilg-query-tests.js index 9826cc648..f8f8aaa35 100644 --- a/InfoLogger/test/integration/ilg-query-tests.js +++ b/InfoLogger/test/integration/ilg-query-tests.js @@ -10,29 +10,29 @@ * In applying this license CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization * or submit itself to any jurisdiction. -*/ + */ + +/* eslint-disable @stylistic/js/max-len */ -/* eslint-disable no-invalid-this */ -/* eslint-disable no-console */ -/* eslint-disable max-len */ const puppeteer = require('puppeteer'); const assert = require('assert'); const config = require('./config-provider'); -let page; -const url = config.url; -const facility = config.facility; -const timestamp = config.timestamp; +let page = undefined; +const { url } = config; +const { facility } = config; +const { timestamp } = config; -describe('InfoLogger - FLP CI Suite Tests ', function() { - let browser; +describe('InfoLogger - FLP CI Suite Tests ', function () { + let browser = undefined; this.timeout(config.timeout); this.slow(3000); before(async () => { // Start browser to test UI - browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: 'new'}); + browser = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: 'new' }); page = await browser.newPage(); + exports.page = page; }); @@ -40,7 +40,7 @@ describe('InfoLogger - FLP CI Suite Tests ', function() { // try many times until backend server is ready for (let i = 0; i < 10; i++) { try { - await page.goto(url, {waitUntil: 'networkidle0'}); + await page.goto(url, { waitUntil: 'networkidle0' }); break; // connection ok, this test passed } catch (e) { if (e.message.includes('net::ERR_CONNECTION_REFUSED')) { @@ -54,7 +54,11 @@ describe('InfoLogger - FLP CI Suite Tests ', function() { it('should have successfully redirected to default page "/?q={"severity":{"in":"I W E F"}}"', async () => { const location = await page.evaluate(() => window.location); - assert.strictEqual(location.search, '?q={%22severity%22:{%22in%22:%22I%20W%20E%20F%22}}', 'Could not load home page of ILG GUI'); + assert.strictEqual( + location.search, + '?q = {% 22severity % 22: {% 22in% 22:% 22I % 20W % 20E % 20F % 22}}', + 'Could not load home page of ILG GUI', + ); }); it(`should successfully type criteria based on "facility" matching ${facility}`, async () => { @@ -64,8 +68,11 @@ describe('InfoLogger - FLP CI Suite Tests ', function() { return window.model.log.filter.criterias.facility; }, facility); - const expFacility = {$exclude: null, $match: facility, exclude: '', match: facility}; - assert.deepStrictEqual(facilityCriteria, expFacility, 'Criteria for "facility" could not be filled successfully in the GUI'); + assert.deepStrictEqual( + facilityCriteria, + { $exclude: null, $match: facility, exclude: '', match: facility }, + 'Criteria for "facility" could not be filled successfully in the GUI', + ); }); it(`should successfully set criteria based on "time" matching ${timestamp}`, async () => { @@ -73,21 +80,37 @@ describe('InfoLogger - FLP CI Suite Tests ', function() { window.model.log.filter.setCriteria('timestamp', 'since', timestamp); return window.model.log.filter.criterias.timestamp; }, timestamp); - assert.deepStrictEqual(timestampCriteria.since, timestamp, 'Criteria for "timestamp" could not be filled successfully in the GUI'); + assert.deepStrictEqual( + timestampCriteria.since, + timestamp, + 'Criteria for "timestamp" could not be filled successfully in the GUI', + ); }); it('should successfully click on Query button and retrieve results', async () => { await page.evaluate(() => document.querySelector('body > div:nth-child(2) > div > header > div > div:nth-child(2) > button').click()); - await page.waitForFunction(`window.model.log.queryResult !== 'Loading'`, {timeout: 1000}) - const result = await page.evaluate(() => window.model.log.queryResult); + await page.waitForFunction(`window.model.log.queryResult !== 'Loading'`, { timeout: 1000 }); + const result = await page.evaluate(() => { + const queryAsRemoteData = window.model.log.queryResult; + return { kind: queryAsRemoteData.kind, payload: queryAsRemoteData.payload }; + }); assert.strictEqual(result.kind, 'Success', `Query action failed due to ${result.payload}`); }); it('should have successfully received filtered data', async () => { - const result = await page.evaluate(() => window.model.log.queryResult); - assert.ok(result.payload.rows.length > 0, 'Queried data is empty'); + const { kind, payload } = await page.evaluate(() => { + const queryAsRemoteData = window.model.log.queryResult; + return { + kind: queryAsRemoteData.kind, + payload: queryAsRemoteData.payload, + }; + }); + assert.ok(kind === 'Success', `Query action failed due to ${payload}`); + assert.ok(payload?.rows?.length > 0, 'Queried data is empty and it should not be'); - const isDataFiltered = result.payload.rows.map((element) => element.facility).every((elFacilty) => elFacilty === facility); + const isDataFiltered = payload.rows + .map((element) => element.facility) + .every((elementFacility) => elementFacility === facility); assert.ok(isDataFiltered, `Data contains other facilities than ${facility}`); }); diff --git a/InfoLogger/test/public/user-actions-mocha.js b/InfoLogger/test/public/user-actions-mocha.js index 2b8e03d42..6a52263a1 100644 --- a/InfoLogger/test/public/user-actions-mocha.js +++ b/InfoLogger/test/public/user-actions-mocha.js @@ -10,19 +10,21 @@ * In applying this license CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization * or submit itself to any jurisdiction. -*/ + */ -/* eslint-disable max-len */ +/* eslint-disable @stylistic/js/max-len */ +/* eslint-disable prefer-destructuring */ const assert = require('assert'); -const {O2TokenService} = require('@aliceo2/web-ui'); +const { O2TokenService } = require('@aliceo2/web-ui'); const test = require('../mocha-index'); describe('User Profile test-suite', async () => { - let baseUrl; - let page; - let tokenService, testToken; + let baseUrl = ''; + let page = undefined; + let tokenService = undefined; + let testToken = undefined; before(async () => { baseUrl = test.helpers.baseUrl; @@ -34,9 +36,9 @@ describe('User Profile test-suite', async () => { describe('User is anonymous', async () => { it('should have a button in action dropdown button to view info about the framework', async () => { const profileMenuItem = await page.evaluate(() => { - const title = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)').title; + const { title } = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)'); const text = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)').innerText; - return {title: title, text: text}; + return { title: title, text: text }; }); assert.strictEqual(profileMenuItem.title, 'Show/Hide details about the framework'); assert.strictEqual(profileMenuItem.text, 'About'); @@ -50,11 +52,11 @@ describe('User Profile test-suite', async () => { describe('User is NOT anonymous', async () => { it('should have a button in action dropdown button to save user profile', async () => { - await page.goto(baseUrl + `?personid=1&username=test&name=Test&access=admin&token=${testToken}`, {waitUntil: 'networkidle0'}); + await page.goto(`${baseUrl}?personid=1&username=test&name=Test&access=admin&token=${testToken}`, { waitUntil: 'networkidle0' }); const profileMenuItem = await page.evaluate(() => { - const title = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(3)').title; + const { title } = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(3)'); const text = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(3)').innerText; - return {title: title, text: text}; + return { title: title, text: text }; }); assert.strictEqual(profileMenuItem.title, 'Save the columns size and visibility as your profile'); assert.strictEqual(profileMenuItem.text, 'Save Profile'); @@ -72,20 +74,25 @@ describe('User Profile test-suite', async () => { it('should have a button in action dropdown button to view info about the framework', async () => { const profileMenuItem = await page.evaluate(() => { - const title = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)').title; - const text = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)').innerText; - return {title: title, text: text}; + const { title } = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)'); + const { innerText } = document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(2)'); + return { title, innerText }; }); assert.strictEqual(profileMenuItem.title, 'Show/Hide details about the framework'); - assert.strictEqual(profileMenuItem.text, 'About'); + assert.strictEqual(profileMenuItem.innerText, 'About'); }); it('should successfully load profile saved for user when accessing the page', async () => { - await page.goto(baseUrl + `?personid=1&username=test&name=Test&access=admin&token=${testToken}`, {waitUntil: 'networkidle0'}); + await page.goto( + `${baseUrl}?personid=1&username=test&name=Test&access=admin&token=${testToken}`, + { waitUntil: 'networkidle0' }, + ); const userProfile = await page.evaluate(() => { window.model.table.colsHeader.date.size = 'cell-xl'; - document.querySelector('body > div:nth-child(2) > div > header:nth-child(2) > table > tbody > tr > td > button').click(); - document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(3)').click(); + document.querySelector('body > div:nth-child(2) > div > header:nth-child(2) > table > tbody > tr > td > button') + .click(); + document.querySelector('body > div:nth-child(2) > div > header > div > div > div > div:nth-child(3)') + .click(); return window.model.userProfile.payload; }); assert.ok(!userProfile.content.colsHeader.date.visible);