Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vogievetsky committed Apr 22, 2024
1 parent 04c1c67 commit 77366fe
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('TableColumnSelector', () => {
it('matches snapshot', () => {
const tableColumn = (
<TableColumnSelector
columns={['a', 'b', 'c']}
columns={['a', 'b', { text: 'c', label: 'c-label' }]}
onChange={() => {}}
tableColumnsHidden={['b']}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ import { MenuCheckbox } from '../menu-checkbox/menu-checkbox';

import './table-column-selector.scss';

export type TableColumnSelectorColumn = string | { text: string; label: string };

function getColumnName(c: TableColumnSelectorColumn) {
return typeof c === 'string' ? c : c.text;
}

interface TableColumnSelectorProps {
columns: string[];
onChange: (column: string) => void;
columns: TableColumnSelectorColumn[];
onChange: (columnName: string) => void;
onClose?: (added: number) => void;
tableColumnsHidden: string[];
}
Expand All @@ -38,23 +44,28 @@ export const TableColumnSelector = React.memo(function TableColumnSelector(
const { columns, onChange, onClose, tableColumnsHidden } = props;
const [added, setAdded] = useState(0);

const isColumnShown = (column: string) => !tableColumnsHidden.includes(column);
const isColumnShown = (column: TableColumnSelectorColumn) =>
!tableColumnsHidden.includes(getColumnName(column));

const checkboxes = (
<Menu className="table-column-selector-menu">
{columns.map(column => (
<MenuCheckbox
text={column}
key={column}
checked={isColumnShown(column)}
onChange={() => {
if (!isColumnShown(column)) {
setAdded(added + 1);
}
onChange(column);
}}
/>
))}
{columns.map(column => {
const columnName = getColumnName(column);
return (
<MenuCheckbox
text={columnName}
label={typeof column === 'string' ? undefined : column.label}
key={columnName}
checked={isColumnShown(column)}
onChange={() => {
if (!isColumnShown(column)) {
setAdded(added + 1);
}
onChange(columnName);
}}
/>
);
})}
</Menu>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`TimedButton matches snapshot 1`] = `
<Blueprint4.MenuItem
active={false}
disabled={false}
icon="selection"
icon="tick-circle"
multiline={false}
onClick={[Function]}
popoverProps={{}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ exports[`SupervisorTableActionDialog matches snapshot 1`] = `
<span
class="bp4-button-text"
>
Statistics
Task stats
</span>
</button>
<button
Expand Down Expand Up @@ -144,7 +144,7 @@ exports[`SupervisorTableActionDialog matches snapshot 1`] = `
<span
class="bp4-button-text"
>
Payload
Spec
</span>
</button>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,23 +656,23 @@ exports[`SupervisorStatisticsTable matches snapshot on some data 1`] = `
{
"Cell": [Function],
"Header": "1m",
"accessor": [Function],
"accessor": "summary.movingAverages.buildSegments.1m",
"className": "padded",
"id": "1m",
"width": 200,
},
{
"Cell": [Function],
"Header": "5m",
"accessor": [Function],
"accessor": "summary.movingAverages.buildSegments.5m",
"className": "padded",
"id": "5m",
"width": 200,
},
{
"Cell": [Function],
"Header": "15m",
"accessor": [Function],
"accessor": "summary.movingAverages.buildSegments.15m",
"className": "padded",
"id": "15m",
"width": 200,
Expand All @@ -687,18 +687,21 @@ exports[`SupervisorStatisticsTable matches snapshot on some data 1`] = `
"buildSegments": {
"15m": {
"processed": 5.544749689510444,
"processedBytes": 20,
"processedWithError": 0,
"thrownAway": 0,
"unparseable": 0,
},
"1m": {
"processed": 4.593670088770785,
"processedBytes": 30,
"processedWithError": 0,
"thrownAway": 0,
"unparseable": 0,
},
"5m": {
"processed": 3.5455993615040584,
"processedBytes": 10,
"processedWithError": 0,
"thrownAway": 0,
"unparseable": 0,
Expand All @@ -708,6 +711,7 @@ exports[`SupervisorStatisticsTable matches snapshot on some data 1`] = `
"totals": {
"buildSegments": {
"processed": 7516,
"processedBytes": 60,
"processedWithError": 0,
"thrownAway": 0,
"unparseable": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,26 @@ exports[`TaskTableActionDialog matches snapshot 1`] = `
>
<span
aria-hidden="true"
class="bp4-icon bp4-icon-align-left"
icon="align-left"
class="bp4-icon bp4-icon-comparison"
icon="comparison"
>
<svg
data-icon="align-left"
data-icon="comparison"
height="20"
role="img"
viewBox="0 0 20 20"
width="20"
>
<path
d="M1 7h10c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0-4h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 14H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM1 15h6c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"
d="M6 8H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm13-6h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 3h-5V3h5v2zM6 14H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM6 2H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm4-2c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm9 14h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-5v-2h5v2zm0-9h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm0 3h-5V9h5v2z"
fill-rule="evenodd"
/>
</svg>
</span>
<span
class="bp4-button-text"
>
Payload
Reports
</span>
</button>
<button
Expand All @@ -125,26 +125,26 @@ exports[`TaskTableActionDialog matches snapshot 1`] = `
>
<span
aria-hidden="true"
class="bp4-icon bp4-icon-comparison"
icon="comparison"
class="bp4-icon bp4-icon-align-left"
icon="align-left"
>
<svg
data-icon="comparison"
data-icon="align-left"
height="20"
role="img"
viewBox="0 0 20 20"
width="20"
>
<path
d="M6 8H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm13-6h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm0 3h-5V3h5v2zM6 14H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zM6 2H1c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm4-2c-.55 0-1 .45-1 1v18c0 .55.45 1 1 1s1-.45 1-1V1c0-.55-.45-1-1-1zm9 14h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-2c0-.55-.45-1-1-1zm0 3h-5v-2h5v2zm0-9h-5c-.55 0-1 .45-1 1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1zm0 3h-5V9h5v2z"
d="M1 7h10c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm0-4h18c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1zm14 14H1c-.55 0-1 .45-1 1s.45 1 1 1h14c.55 0 1-.45 1-1s-.45-1-1-1zm4-8H1c-.55 0-1 .45-1 1s.45 1 1 1h18c.55 0 1-.45 1-1s-.45-1-1-1zM1 15h6c.55 0 1-.45 1-1s-.45-1-1-1H1c-.55 0-1 .45-1 1s.45 1 1 1z"
fill-rule="evenodd"
/>
</svg>
</span>
<span
class="bp4-button-text"
>
Reports
Spec
</span>
</button>
<button
Expand Down Expand Up @@ -172,7 +172,7 @@ exports[`TaskTableActionDialog matches snapshot 1`] = `
<span
class="bp4-button-text"
>
Logs
Log
</span>
</button>
</div>
Expand Down
Loading

0 comments on commit 77366fe

Please sign in to comment.