Skip to content

Commit

Permalink
Fix home frontend tests randomly failing
Browse files Browse the repository at this point in the history
  • Loading branch information
martinboulais committed Jan 13, 2025
1 parent 86f5f39 commit a150075
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/public/views/Home/Overview/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ export const HomePage = ({ home: { logsOverviewModel, runsOverviewModel, lhcFill
h('.flex-row.g2', [
h('.flex-column', [
h('h3', 'Log Entries'),
h('.f6', table(logsOverviewModel.logs, logsActiveColumns, null, { profile: 'home' })),
h('.f6#logs-panel', table(logsOverviewModel.logs, logsActiveColumns, null, { profile: 'home' })),
]),
h('.flex-column', [
h('h3', 'LHC Fills'),
h('.f6', table(lhcFillsOverviewModel.items, lhcFillsActiveColumns, null, { profile: 'home' })),
h('.f6#lhc-fills-panel', table(lhcFillsOverviewModel.items, lhcFillsActiveColumns, null, { profile: 'home' })),
]),
]),
h('.flex-row', [
h('.flex-column', [
h('h3', 'Runs'),
table(runsOverviewModel.items, runsActiveColumns, null, { profile: 'home' }),
h('.f6#runs-panel', table(runsOverviewModel.items, runsActiveColumns, null, { profile: 'home' })),
]),
]),
]));
Expand Down
24 changes: 8 additions & 16 deletions test/public/home/overview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@
*/

const chai = require('chai');
const { defaultBefore, defaultAfter, getFirstRow, goToPage, waitForNavigation } = require('../defaults.js');
const { defaultBefore, defaultAfter, getFirstRow, goToPage, waitForNavigation, pressElement, expectUrlParams } = require('../defaults.js');
const { resetDatabaseContent } = require('../../utilities/resetDatabaseContent.js');

const { expect } = chai;

module.exports = () => {
let page;
let browser;
let url;

let table;
let firstRowId;

before(async () => {
[page, browser, url] = await defaultBefore(page, browser);
[page, browser] = await defaultBefore(page, browser);
await resetDatabaseContent();
});
after(async () => {
Expand All @@ -44,16 +43,13 @@ module.exports = () => {
expect(title).to.equal('AliceO2 Bookkeeping');
});

it('Can find table', async () => {
table = await page.$$('tr');
firstRowId = await getFirstRow(table, page);

// We expect to find a table
expect(firstRowId).to.equal('row119');
it('should successfully display logs table', async () => {
await page.waitForSelector('#logs-panel tr#row119');
});

it('shows correct datatypes in respective columns', async () => {
table = await page.$$('tr');
await page.waitForSelector('#runs-panel');
table = await page.$$('#runs-panel tr');
firstRowId = await getFirstRow(table, page);

// Expectations of header texts being of a certain datatype
Expand Down Expand Up @@ -86,13 +82,9 @@ module.exports = () => {
});

it('can navigate to a detail page via link', async () => {
const firstButton = await page.$('a.btn-redirect');
const parsedFirstRowId = parseInt(firstRowId.slice('btn'.length, firstRowId.length), 10);

// We expect the entry page to have the same id as the id from the log overview
await waitForNavigation(page, () => firstButton.evaluate((link) => link.click()));
await waitForNavigation(page, () => pressElement(page, '#logs-panel a.btn-redirect'));

const redirectedUrl = await page.url();
expect(redirectedUrl).to.equal(`${url}/?page=log-detail&id=${parsedFirstRowId}`);
expectUrlParams(page, { page: 'log-detail', id: 119 });
});
};

0 comments on commit a150075

Please sign in to comment.