Skip to content

Commit d2049a6

Browse files
committed
Added tests
1 parent e6b7ec4 commit d2049a6

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

lib/public/Model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ObservableData } from './utilities/ObservableData.js';
2222
import { debounce, INPUT_DEBOUNCE_TIME } from './utilities/debounce.js';
2323
import { getRoleForDetector } from './utilities/getRoleForDetector.js';
2424
import { userPreferencesStore } from './utilities/userPreferencesStore.js';
25-
import { AboutModel } from './views/About/AboutModel.js';
25+
import { AboutModel } from './views/About/About.js';
2626
import { DataPassesModel } from './views/DataPasses/DataPassesModel.js';
2727
import { EnvironmentModel } from './views/Environments/EnvironmentModel.js';
2828
import { EosReportModel } from './views/EosReport/EosReportModel.js';

test/public/error/error.test.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
const chai = require('chai');
15+
const { defaultBefore, defaultAfter, goToPage } = require('../defaults.js');
16+
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');
17+
18+
const { expect } = chai;
19+
20+
module.exports = () => {
21+
let page;
22+
let browser;
23+
24+
before(async () => {
25+
[page, browser] = await defaultBefore(page, browser);
26+
await page.setViewport({
27+
width: 700,
28+
height: 720,
29+
deviceScaleFactor: 1,
30+
});
31+
await resetDatabaseContent();
32+
});
33+
34+
after(async () => {
35+
[page, browser] = await defaultAfter(page, browser);
36+
});
37+
38+
it('loads the page successfully', async () => {
39+
const response = await goToPage(page, 'error');
40+
41+
// We expect the page to return the correct status code, making sure the server is running properly
42+
expect(response.status()).to.equal(200);
43+
44+
// We expect the page to return the correct title, making sure there isn't another server running on this port
45+
const title = await page.title();
46+
expect(title).to.equal('AliceO2 Bookkeeping');
47+
});
48+
49+
it('shows the error message', async () => {
50+
await goToPage(page, 'error');
51+
52+
const errorTitle = await page.$eval('h2', (el) => el.innerText);
53+
expect(errorTitle).to.equal('Oops! Something went wrong.');
54+
});
55+
56+
it ('shows the default text', async () => {
57+
await goToPage(page, 'error');
58+
59+
const errorCode = await page.$eval('h3', (el) => el.innerText);
60+
expect(errorCode).to.equal('Unknown Error - Something unexpected happened.');
61+
});
62+
63+
it ('shows 404 when page is not found', async () => {
64+
await goToPage(page, 'sdf');
65+
66+
//eslint-disable-next-line no-console
67+
console.log(await page.title());
68+
69+
const errorCode = await page.$eval('.h3', (el) => el.innerText);
70+
expect(errorCode).to.equal('404 - Page not found');
71+
});
72+
};

test/public/error/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
const ErrorSuite = require('./error.test');
14+
15+
module.exports = () => {
16+
describe('Error Page', ErrorSuite);
17+
};

test/public/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const FlpsSuite = require('./flps');
1919
const HomeSuite = require('./home');
2020
const AboutSuite = require('./about');
2121
const EnvsSuite = require('./envs');
22+
const ErrorSuite = require('./error');
2223
const EosReportSuite = require('./eosReport');
2324
const LhcPeriodsSuite = require('./lhcPeriods');
2425
const DataPassesSuite = require('./dataPasses');
@@ -41,4 +42,5 @@ module.exports = () => {
4142
describe('SimulationPasses', SimulationPassesSuite);
4243
describe('QcFlagTypes', QcFlagTypesSuite);
4344
describe('QcFlags', QcFlagsSuite);
45+
describe('Error', ErrorSuite);
4446
};

0 commit comments

Comments
 (0)