Skip to content

Commit

Permalink
feat: finish e2e tests for the experiment list multifilter
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagodallacqua-hpe committed Sep 25, 2024
1 parent 163ce46 commit f2f4cf2
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions webui/react/src/e2e/tests/experimentList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,19 @@ test.describe('Experiment List', () => {
);
});

test('Multi-sort menu', async () => {
test('Multi-sort menu', async ({ newProject, newWorkspace }) => {
const multiSortMenu = projectDetailsPage.f_experimentList.tableActionBar.multiSortMenu;
const secondRow = multiSortMenu.multiSort.rows.nth(1);
const checkTableOrder = async (
firstKey: keyof ExperimentBase,
secondKey: keyof ExperimentBase,
) => {
const experimentList: ExperimentBase[] = JSON.parse(await detExecSync('experiment ls'));

return [
{ [firstKey]: experimentList[0][firstKey], [secondKey]: experimentList[0][secondKey] },
{
[firstKey]: experimentList[experimentList.length - 1][firstKey],
[secondKey]: experimentList[experimentList.length - 1][secondKey],
},
];
const checkTableOrder = async (firstKey: keyof ExperimentBase) => {
const experimentList: ExperimentBase[] = JSON.parse(
await detExecSync(
`project list-experiments --json ${newWorkspace.response.workspace.name} ${newProject.response.project.name}`,
),
);

expect(experimentList[0][firstKey] as number).toBeLessThanOrEqual(
experimentList[experimentList.length - 1][firstKey] as number,
);
};

const sortingScenario = async (
Expand Down Expand Up @@ -333,13 +330,11 @@ test.describe('Experiment List', () => {
};

await sortingScenario('ID', '9 → 0', 'Start time', 'Oldest → Newest', async () => {
const [higher, lower] = await checkTableOrder('id', 'startTime');
expect(higher.id).toBeGreaterThan(lower.id as number);
await checkTableOrder('id');
});

await sortingScenario('Trial count', '0 → 9', 'Searcher', 'A → Z', async () => {
const [first, last] = await checkTableOrder('numTrials', 'searcherType');
expect(first.numTrials).toBeLessThanOrEqual(last.numTrials as number);
await checkTableOrder('numTrials');
});
});

Expand Down

0 comments on commit f2f4cf2

Please sign in to comment.