Skip to content

Commit

Permalink
Fix tests and type checks
Browse files Browse the repository at this point in the history
  • Loading branch information
adhityamamallan committed Nov 25, 2024
1 parent c10c160 commit e93a7fa
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type TableConfig } from '@/components/table/table.types';
import { type DomainWorkflow } from '@/views/domain-page/domain-page.types';
import WorkflowStatusTag from '@/views/shared/workflow-status-tag/workflow-status-tag';

const domainWorkflowsTableConfig = [
const domainWorkflowsTableConfig: TableConfig<DomainWorkflow> = [
{
name: 'Workflow ID',
id: 'WorkflowID',
Expand Down Expand Up @@ -55,6 +55,6 @@ const domainWorkflowsTableConfig = [
width: '12.5%',
sortable: true,
},
] as const satisfies TableConfig<DomainWorkflow>;
];

export default domainWorkflowsTableConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -152,54 +152,51 @@ function setup({
let currentEventIndex = 0;
const user = userEvent.setup();

const { debug } = render(
<DomainWorkflowsTable domain="mock-domain" cluster="mock-cluster" />,
{
endpointsMocks: [
{
path: '/api/domains/:domain/:cluster/workflows',
httpMethod: 'GET',
mockOnce: false,
httpResolver: async () => {
const index = currentEventIndex;
currentEventIndex++;

switch (errorCase) {
case 'no-workflows':
return HttpResponse.json({
workflows: [],
nextPage: undefined,
});
case 'initial-fetch-error':
render(<DomainWorkflowsTable domain="mock-domain" cluster="mock-cluster" />, {
endpointsMocks: [
{
path: '/api/domains/:domain/:cluster/workflows',
httpMethod: 'GET',
mockOnce: false,
httpResolver: async () => {
const index = currentEventIndex;
currentEventIndex++;

switch (errorCase) {
case 'no-workflows':
return HttpResponse.json({
workflows: [],
nextPage: undefined,
});
case 'initial-fetch-error':
return HttpResponse.json(
{ message: 'Request failed' },
{ status: 500 }
);
case 'subsequent-fetch-error':
if (index === 0) {
return HttpResponse.json(pages[0]);
} else if (index === 1) {
return HttpResponse.json(
{ message: 'Request failed' },
{ status: 500 }
);
case 'subsequent-fetch-error':
if (index === 0) {
return HttpResponse.json(pages[0]);
} else if (index === 1) {
return HttpResponse.json(
{ message: 'Request failed' },
{ status: 500 }
);
} else {
return HttpResponse.json(pages[1]);
}
default:
if (index === 0) {
return HttpResponse.json(pages[0]);
} else {
return HttpResponse.json(pages[1]);
}
}
},
} else {
return HttpResponse.json(pages[1]);
}
default:
if (index === 0) {
return HttpResponse.json(pages[0]);
} else {
return HttpResponse.json(pages[1]);
}
}
},
] as MSWMocksHandlersProps['endpointsMocks'],
}
);
},
] as MSWMocksHandlersProps['endpointsMocks'],
});

return { user, debug };
return { user };
}

// TODO @adhitya.mamallan - Explore using fakerjs.dev for cases like this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default function DomainWorkflowsTable({ domain, cluster }: Props) {
...columnConfig,
sortable: false,
})),
onSort: () => {},
}
: {
columns: domainWorkflowsTableConfig,
Expand Down

0 comments on commit e93a7fa

Please sign in to comment.