Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[O2B-1177] Add runs counts for simulation pass overview #1524

Merged
merged 9 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* or submit itself to any jurisdiction.
*/

import { h } from '/js/src/index.js';
import { textFilter } from '../../../components/Filters/common/filters/textFilter.js';
import { absoluteFrontLink } from '../../../components/common/navigation/absoluteFrontLink.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';
Expand All @@ -36,7 +37,14 @@
associatedRuns: {
name: 'Runs',
visible: true,
format: (_, { id }) => frontLink('Runs', 'runs-per-simulation-pass', { simulationPassId: id }),
format: (_, { id, runsCount }) =>
runsCount === 0
? 'No runs'
: frontLink(

Check warning on line 43 in lib/public/views/SimulationPasses/ActiveColumns/simulationPassesActiveColumns.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/SimulationPasses/ActiveColumns/simulationPassesActiveColumns.js#L41-L43

Added lines #L41 - L43 were not covered by tests
h('.f6.badge.bg-gray-light.black', runsCount),
'runs-per-simulation-pass',
{ simulationPassId: id },
),
classes: 'w-10 f6',
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ module.exports = () => {
const dataSizeUnits = new Set(['B', 'KB', 'MB', 'GB', 'TB']);
const tableDataValidators = {
name: (name) => periodNameRegex.test(name),
jiraId: (jiraId) => /[A-Z][A-Z0-9]+-[0-9]+/.test(jiraId),
associatedRuns: (display) => /(No runs)|(\d+)/.test(display),
associatedDataPasses: (display) => 'Anchorage' === display,
pwg: (pwg) => /PWG.+/.test(pwg),
jiraId: (jiraId) => /[A-Z][A-Z0-9]+-[0-9]+/.test(jiraId),
requestedEventsCount: (requestedEventsCount) => !isNaN(requestedEventsCount.replace(/,/g, '')),
generatedEventsCount: (generatedEventsCount) => !isNaN(generatedEventsCount.replace(/,/g, '')),
outputSize: (outpuSize) => {
Expand Down
40 changes: 12 additions & 28 deletions test/public/simulationPasses/overviewPerLhcPeriod.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
testTableSortingByColumn,
pressElement,
expectColumnValues,
validateTableData,
} = require('../defaults');

const { expect } = chai;
Expand Down Expand Up @@ -53,39 +54,22 @@ module.exports = () => {
});

it('shows correct datatypes in respective columns', async () => {
// Expectations of header texts being of a certain datatype
const dataSizeUnits = new Set(['B', 'KB', 'MB', 'GB', 'TB']);
const headerDatatypes = {
name: (name) => periodNameRegex.test(name),
year: (year) => !isNaN(year),
associatedRuns: (display) => /(No runs)|(\d+)/.test(display),
associatedDataPasses: (display) => 'Anchorage' === display,
pwg: (pwg) => /PWG.+/.test(pwg),
requestedEventsCount: (requestedEventsCount) => !isNaN(requestedEventsCount),
generatedEventsCount: (generatedEventsCount) => !isNaN(generatedEventsCount),
outpuSize: (outpuSize) => !isNaN(outpuSize),
jiraId: (jiraId) => /[A-Z]+[A-Z0-9]+-\d+/.test(jiraId),
requestedEventsCount: (requestedEventsCount) => !isNaN(requestedEventsCount.replace(/,/g, '')),
generatedEventsCount: (generatedEventsCount) => !isNaN(generatedEventsCount.replace(/,/g, '')),
outputSize: (outpuSize) => {
const [number, unit] = outpuSize.split(' ');
return !isNaN(number) && dataSizeUnits.has(unit.trim());
},
};

// We find the headers matching the datatype keys
await page.waitForSelector('th');
const headers = await page.$$('th');
const headerIndices = {};
for (const [index, header] of headers.entries()) {
const headerContent = await page.evaluate((element) => element.id, header);
const matchingDatatype = Object.keys(headerDatatypes).find((key) => headerContent === key);
if (matchingDatatype !== undefined) {
headerIndices[index] = matchingDatatype;
}
}

// We expect every value of a header matching a datatype key to actually be of that datatype

// Use the third row because it is where statistics are present
const firstRowCells = await page.$$('tr:nth-of-type(3) td');
for (const [index, cell] of firstRowCells.entries()) {
if (index in headerIndices) {
const cellContent = await page.evaluate((element) => element.innerText, cell);
const expectedDatatype = headerDatatypes[headerIndices[index]](cellContent);
expect(expectedDatatype).to.be.true;
}
}
await validateTableData(page, new Map(Object.entries(headerDatatypes)));
});

it('Should display the correct items counter at the bottom of the page', async () => {
Expand Down
Loading