Skip to content

Commit

Permalink
fix broken e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliidm committed Dec 1, 2021
1 parent ce86fdf commit 8cb282f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export const useRulesStatuses = (rules: Rules): ReturnRulesStatuses => {
rules.map((rule) => ({
id: rule.id,
...ruleStatusesResponse[rule.id],
rule,
}))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type HasReadActionsPrivileges =
[x: string]: boolean;
}>;

export type TableItem = RuleStatus & Rule;
export type TableItem = Rule & Partial<RuleStatus>;
export type TableColumn = EuiBasicTableColumn<TableItem> | EuiTableActionsColumnType<TableItem>;

const extractRuleFromRow = ({ current_status: _, failures, ...rule }: TableItem): Rule => rule;
Expand Down Expand Up @@ -129,7 +129,6 @@ export const getActions = (

export type EnhancedRuleStatus = RuleStatus & {
id: string;
rule: Rule;
};

interface GetColumnsProps {
Expand Down Expand Up @@ -258,7 +257,7 @@ const getActionsColumns = ({
: [];

export const getRulesColumns = (columnsProps: GetColumnsProps): TableColumn[] => {
const cols: TableColumn[] = [
return [
getColumnRuleName(columnsProps),
getColumnTags(),
{
Expand Down Expand Up @@ -339,14 +338,13 @@ export const getRulesColumns = (columnsProps: GetColumnsProps): TableColumn[] =>
truncateText: true,
},
getColumnEnabled(columnsProps),
...getActionsColumns(columnsProps),
];

return [...cols, ...getActionsColumns(columnsProps)];
};

export const getMonitoringColumns = (columnsProps: GetColumnsProps): TableColumn[] => {
const { docLinks } = columnsProps;
const cols: TableColumn[] = [
return [
{ ...getColumnRuleName(columnsProps), width: '28%' },
getColumnTags(),
{
Expand Down Expand Up @@ -445,7 +443,6 @@ export const getMonitoringColumns = (columnsProps: GetColumnsProps): TableColumn
truncateText: true,
},
getColumnEnabled(columnsProps),
...getActionsColumns(columnsProps),
];

return [...cols, ...getActionsColumns(columnsProps)];
};
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,14 @@ export const RulesTables = React.memo<RulesTableProps>(
);

const items = useMemo(() => {
const rulesMap = new Map(rules.map((item) => [item.id, item]));

return rulesStatuses.map(({ rule, ...rest }) => ({
...rest,
...(rulesMap.get(rule.id) ?? rule),
}));
const rulesStatusesMap = new Map(rulesStatuses.map((item) => [item.id, item]));

return rules.map((rule) => {
return {
...rule,
...rulesStatusesMap.get(rule.id),
};
});
}, [rulesStatuses, rules]);

const tableProps =
Expand Down

0 comments on commit 8cb282f

Please sign in to comment.