Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions InfoLogger/public/logFilter/LogFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

/**
* @typedef Criteria * @type {Array.<Criteria>}

Check warning on line 27 in InfoLogger/public/logFilter/LogFilter.js

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest

Unexpected inline JSDoc tag. Did you mean to use {@type}, \@type, or `@type`?

Check warning on line 27 in InfoLogger/public/logFilter/LogFilter.js

View workflow job for this annotation

GitHub Actions / Tests & coverage on ubuntu-latest

Unexpected inline JSDoc tag. Did you mean to use {@type}, \@type, or `@type`?
*/

/**
Expand Down Expand Up @@ -193,7 +193,7 @@
/**
* Generates a function to filter a log passed as argument to it
* Output of function is boolean.
* @returns {Function.<WebSocketMessage, boolean>} - function to filter logs

Check warning on line 196 in InfoLogger/public/logFilter/LogFilter.js

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest

Prefer a more specific type to `Function`

Check warning on line 196 in InfoLogger/public/logFilter/LogFilter.js

View workflow job for this annotation

GitHub Actions / Tests & coverage on ubuntu-latest

Prefer a more specific type to `Function`
*/
toStringifyFunction() {
/**
Expand Down Expand Up @@ -429,8 +429,8 @@
$in: ['I', 'W', 'E', 'F'],
},
level: {
max: 1,
$max: 1,
max: null,
$max: null,
},
};
this.notify();
Expand Down
31 changes: 15 additions & 16 deletions InfoLogger/test/mocha-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
* 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 no-console */
const puppeteer = require('puppeteer');
const assert = require('assert');
const {spawn} = require('child_process');
const { spawn } = require('child_process');

const config = require('./test-config.js');
const {createServer, closeServer} = require('./live-simulator/infoLoggerServer.js');
const { createServer, closeServer } = require('./live-simulator/infoLoggerServer.js');

// APIs:
// https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md
Expand All @@ -28,16 +28,16 @@ const {createServer, closeServer} = require('./live-simulator/infoLoggerServer.j
// Network and rendering can have delays this can leads to random failures
// if they are tested just after their initialization.

describe('InfoLogger', function() {
describe('InfoLogger', function () {
let browser;
let page;
let subprocess; // web-server runs into a subprocess
let subprocessOutput = '';
let ilgServer;

this.timeout(30000);
this.slow(1000);

const baseUrl = `http://${config.http.hostname}:${config.http.port}/`;

before(async () => {
Expand All @@ -62,26 +62,27 @@ describe('InfoLogger', function() {
ilgServer = createServer();

// Start web-server in background
subprocess = spawn('node', ['index.js', 'test/test-config.js'], {stdio: 'pipe'});
subprocess = spawn('node', ['index.js', 'test/test-config.js'], { stdio: 'pipe' });
subprocess.stdout.on('data', (chunk) => subprocessOutput += chunk.toString());
subprocess.stderr.on('data', (chunk) => subprocessOutput += chunk.toString());
subprocess.on('error', (error) => console.error(`Server failed due to: ${error}`))
subprocess.on('error', (error) => console.error(`Server failed due to: ${error}`));

// Start browser to test UI
browser = await puppeteer.launch({headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});
browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
page = await browser.newPage();
await page.setViewport({ width: 1440, height: 900 }); // 15" screen equivalent

// Export page and configurations for the other mocha files
exports.page = page;
exports.helpers = {baseUrl, jwt: config.jwt};

exports.helpers = { baseUrl, jwt: config.jwt };
});

it('should load first page "/"', async () => {
// try many times until backend server is ready
for (let i = 0; i < 10; i++) {
try {
await page.goto(baseUrl, {waitUntil: 'networkidle0'});
await page.goto(baseUrl, { waitUntil: 'networkidle0' });
break; // connection ok, this test passed
} catch (e) {
if (e.message.includes('net::ERR_CONNECTION_REFUSED')) {
Expand All @@ -93,12 +94,12 @@ describe('InfoLogger', function() {
}
});

it('should have redirected to default page "/?q={"severity":{"in":"I W E F"},"level":{"max":1}}"', async function() {
await page.goto(baseUrl, {waitUntil: 'networkidle0'});
it('should have redirected to default page "/?q={"severity":{"in":"I W E F"}}"', async () => {
await page.goto(baseUrl, { waitUntil: 'networkidle0' });
const location = await page.evaluate(() => window.location);
const search = decodeURIComponent(location.search);

assert.deepStrictEqual(search, '?q={"severity":{"in":"I W E F"},"level":{"max":1}}');
assert.deepStrictEqual(search, '?q={"severity":{"in":"I W E F"}}');
});

require('./public/user-actions-mocha');
Expand All @@ -118,7 +119,5 @@ describe('InfoLogger', function() {
console.log('---------------------------------------------');
subprocess.kill();
closeServer(ilgServer);

});
});

2 changes: 1 addition & 1 deletion InfoLogger/test/public/live-mode-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Live Mode test-suite', async () => {
const location = await page.evaluate(() => window.location);
const search = decodeURIComponent(location.search);

assert.deepStrictEqual(search, '?q={"severity":{"in":"I W E F"},"level":{"max":1}}');
assert.deepStrictEqual(search, '?q={"severity":{"in":"I W E F"}}');
});

it('should successfully enable LIVE mode', async () => {
Expand Down
10 changes: 5 additions & 5 deletions InfoLogger/test/public/log-filter-actions-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Filter actions test-suite', async () => {
});

it('should redirect to default filters and show JSON parse error on malformed q in URI', async () => {
const expectedDefaultParams = '?q={"severity":{"in":"I W E F"},"level":{"max":1}}';
const expectedDefaultParams = '?q={"severity":{"in":"I W E F"}}';

const locationAndNotification = await page.evaluate(() => {
const params = { q: '{"severity":{"in":"W I E F"' };
Expand All @@ -116,8 +116,8 @@ describe('Filter actions test-suite', async () => {

it('should update URI with new encoded "match" criteria', async () => {
/* eslint-disable max-len */
const decodedParams = '?q={"hostname":{"match":"\\"%ald_qdip01%"},"severity":{"in":"I W E F"},"level":{"max":1}}';
const expectedParams = '?q={%22hostname%22:{%22match%22:%22%5C%22%25ald_qdip01%25%22},%22severity%22:{%22in%22:%22I%20W%20E%20F%22},%22level%22:{%22max%22:1}}';
const decodedParams = '?q={"hostname":{"match":"\\"%ald_qdip01%"},"severity":{"in":"I W E F"}}';
const expectedParams = '?q={%22hostname%22:{%22match%22:%22%5C%22%25ald_qdip01%25%22},%22severity%22:{%22in%22:%22I%20W%20E%20F%22}}';
const searchParams = await page.evaluate(() => {
window.model.log.filter.setCriteria('hostname', 'match', '"%ald_qdip01%');
window.model.updateRouteOnModelChange();
Expand All @@ -130,8 +130,8 @@ describe('Filter actions test-suite', async () => {

it('should update URI with new encoded "exclude" criteria', async () => {
/* eslint-disable max-len */
const decodedParams = '?q={"hostname":{"exclude":"\\"%ald_qdip01%"},"severity":{"in":"I W E F"},"level":{"max":1}}';
const expectedParams = '?q={%22hostname%22:{%22exclude%22:%22%5C%22%25ald_qdip01%25%22},%22severity%22:{%22in%22:%22I%20W%20E%20F%22},%22level%22:{%22max%22:1}}';
const decodedParams = '?q={"hostname":{"exclude":"\\"%ald_qdip01%"},"severity":{"in":"I W E F"}}';
const expectedParams = '?q={%22hostname%22:{%22exclude%22:%22%5C%22%25ald_qdip01%25%22},%22severity%22:{%22in%22:%22I%20W%20E%20F%22}}';
const searchParams = await page.evaluate(() => {
window.model.log.filter.resetCriteria();
window.model.log.filter.setCriteria('hostname', 'exclude', '"%ald_qdip01%');
Expand Down
Loading