Skip to content

Commit

Permalink
test: experiment list sort [INFENG-766] (#9675)
Browse files Browse the repository at this point in the history
  • Loading branch information
JComins000 authored Jul 22, 2024
1 parent ca90a63 commit f721751
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
17 changes: 12 additions & 5 deletions webui/react/src/components/MultiSortMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const sortMenuItemsForColumn = (

const DirectionOptions: React.FC<DirectionOptionsProps> = ({ onChange, type, value }) => (
<Select
data-test="direction"
options={optionsByColumnType[type]}
placeholder="Select direction"
value={value}
Expand All @@ -147,6 +148,7 @@ const ColumnOptions: React.FC<ColumnOptionsProps> = ({
}) => (
<Select
autoFocus
data-test="column"
dropdownMatchSelectWidth={300}
loading={Loadable.isNotLoaded(columns)}
options={Loadable.getOrElse([], columns)
Expand All @@ -173,7 +175,7 @@ const MultiSortRow: React.FC<MultiSortRowProps> = ({
Loadable.getOrElse([], columns).find((c) => c.column === sort.column)?.type ||
V1ColumnType.UNSPECIFIED;
return (
<div className={css.sortRow}>
<div className={css.sortRow} data-test-component="multiSortRow">
<div className={css.select}>
<ColumnOptions
bannedSortColumns={bannedSortColumns}
Expand All @@ -191,6 +193,7 @@ const MultiSortRow: React.FC<MultiSortRowProps> = ({
</div>
<div>
<Button
data-test="remove"
icon={<Icon name="close" title={REMOVE_SORT_TITLE} />}
size="small"
type="text"
Expand Down Expand Up @@ -222,9 +225,9 @@ const MultiSort: React.FC<MultiSortProps> = ({ sorts, columns, onChange, bannedS
};

return (
<div className={css.base}>
<div className={css.base} data-test-component="multiSort">
<div>{SORT_MENU_TITLE}</div>
<div className={css.rows}>
<div className={css.rows} data-test="rows">
{sorts.map((sort, idx) => {
const seenColumns = sorts.slice(0, idx).map((s) => s.column);
const columnOptions = Loadable.map(columns, (cols) =>
Expand All @@ -243,10 +246,14 @@ const MultiSort: React.FC<MultiSortProps> = ({ sorts, columns, onChange, bannedS
})}
</div>
<div className={css.actions}>
<Button icon={<Icon decorative name="add" size="tiny" />} type="text" onClick={addRow}>
<Button
data-test="add"
icon={<Icon decorative name="add" size="tiny" />}
type="text"
onClick={addRow}>
{ADD_SORT_TEXT}
</Button>
<Button type="text" onClick={clearAll}>
<Button data-test="reset" type="text" onClick={clearAll}>
{RESET_SORT_TEXT}
</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions webui/react/src/e2e/models/components/MultiSortMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MultiSort extends NamedComponent {
readonly defaultSelector = '[data-test-component="multiSort"]';
readonly add = new BaseComponent({ parent: this, selector: '[data-test="add"]' });
readonly reset = new BaseComponent({ parent: this, selector: '[data-test="reset"]' });
readonly rows = new MultiSortRow({ parent: this, selector: '[data-test="reset"]' });
readonly rows = new MultiSortRow({ parent: this, selector: '[data-test="rows"]' });
}

/**
Expand All @@ -41,7 +41,7 @@ class MultiSort extends NamedComponent {
class MultiSortRow extends NamedComponent {
readonly defaultSelector = '[data-test-component="multiSortRow"]';
readonly column = new ColumnOptions({ parent: this, selector: '[data-test="column"]' });
readonly order = new DirectionOptions({ parent: this, selector: '[data-test="order"]' });
readonly order = new DirectionOptions({ parent: this, selector: '[data-test="direction"]' });
readonly remove = new BaseComponent({ parent: this, selector: '[data-test="remove"]' });
}

Expand Down
22 changes: 19 additions & 3 deletions webui/react/src/e2e/tests/experimentList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test.describe('Experiment List', () => {
});

test.beforeEach(async ({ authedPage }) => {
test.slow();
projectDetailsPage = new ProjectDetails(authedPage);
const grid = projectDetailsPage.f_experimentList.dataGrid;

Expand All @@ -59,14 +60,31 @@ test.describe('Experiment List', () => {
await projectDetailsPage.f_experimentList.tableActionBar.columnPickerMenu.open();
await columnPicker.columnPickerTab.reset.pwLocator.click();
await columnPicker.close();
await waitTableStable();
});
await test.step('Sort Oldest → Newest', async () => {
// reset
const sortContent =
await projectDetailsPage.f_experimentList.tableActionBar.multiSortMenu.open();
await sortContent.multiSort.reset.pwLocator.click();
// the menu doesn't close in local automation, but it works with mouse events
// manually and sometimes on ci. let's just close it manually
await sortContent.close();
await sortContent.open();
// set sort
const firstRow = sortContent.multiSort.rows.nth(0);
await firstRow.column.selectMenuOption('Start time');
await firstRow.order.selectMenuOption('Oldest → Newest');
await sortContent.close();
await waitTableStable();
});
await test.step('Reset Filters', async () => {
const tableFilter =
await projectDetailsPage.f_experimentList.tableActionBar.tableFilter.open();
await tableFilter.filterForm.clearFilters.pwLocator.click();
await tableFilter.close();
await waitTableStable();
});
await waitTableStable();
await grid.setColumnHeight();
await grid.headRow.setColumnDefs();
});
Expand Down Expand Up @@ -100,7 +118,6 @@ test.describe('Experiment List', () => {
});

test('Column Picker Show All and Hide All', async () => {
test.slow();
const columnPicker = projectDetailsPage.f_experimentList.tableActionBar.columnPickerMenu;
const grid = projectDetailsPage.f_experimentList.dataGrid;
let previousTabs = grid.headRow.columnDefs.size;
Expand Down Expand Up @@ -154,7 +171,6 @@ test.describe('Experiment List', () => {
});

test('Table Filter', async () => {
test.slow();
const tableFilter = projectDetailsPage.f_experimentList.tableActionBar.tableFilter;
const totalExperiments = await getCount();

Expand Down

0 comments on commit f721751

Please sign in to comment.