Skip to content

Commit

Permalink
[release] Adapt to new RemoteData object for FLP E2E tests (#2562)
Browse files Browse the repository at this point in the history
* Fix lint issues
* Migrate integration tests to use new RemoteData
* Remove usage of automatic fix in eslint
* Patch ILG version
* Fix auto-fixable lint issues
  • Loading branch information
graduta authored Aug 21, 2024
1 parent 08db1f5 commit ee3cd1e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 47 deletions.
2 changes: 1 addition & 1 deletion InfoLogger/lib/JSONFileConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion InfoLogger/lib/ProfileService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

/**
Expand Down
2 changes: 1 addition & 1 deletion InfoLogger/lib/SQLDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion InfoLogger/lib/StatusService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);

/**
Expand Down
4 changes: 2 additions & 2 deletions InfoLogger/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions InfoLogger/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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",
Expand Down
65 changes: 44 additions & 21 deletions InfoLogger/test/integration/ilg-query-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@
* 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;
});

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(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')) {
Expand All @@ -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 () => {
Expand All @@ -64,30 +68,49 @@ 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 () => {
const timestampCriteria = await page.evaluate((timestamp) => {
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}`);
});

Expand Down
43 changes: 25 additions & 18 deletions InfoLogger/test/public/user-actions-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit ee3cd1e

Please sign in to comment.