-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: extracted send request from batch run result block * chore: ts * refactor: batch run * refactor: extracted send request from batch run result block
- Loading branch information
Showing
13 changed files
with
312 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/arex/src/panes/BatchRun/BatchRunResultGroup/ByInterface.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Card } from 'antd'; | ||
import * as React from 'react'; | ||
import { ReactElement } from 'react'; | ||
|
||
import { CollectionNodeType } from '@/constant'; | ||
import { RunResult } from '@/panes/BatchRun/BatchRun'; | ||
import { GroupProps } from '@/panes/BatchRun/BatchRunResultGroup/common'; | ||
|
||
function groupByInterface(blockMap: Map<RunResult, ReactElement>) { | ||
const interfaceMap = new Map<string, RunResult[]>(); | ||
for (const runResult of blockMap.keys()) { | ||
const request = runResult.request; | ||
const parent = request.parentPath[request.parentPath.length - 1]; | ||
if (parent.nodeType !== CollectionNodeType.interface) { | ||
interfaceMap.set(request.id, [runResult]); | ||
} | ||
} | ||
for (const runResult of blockMap.keys()) { | ||
const parent = runResult.request.parentPath[runResult.request.parentPath.length - 1]; | ||
if (parent.nodeType === CollectionNodeType.interface) { | ||
interfaceMap.get(parent.id)?.push(runResult); | ||
} | ||
} | ||
return interfaceMap; | ||
} | ||
|
||
export function ByInterface(props: GroupProps) { | ||
const { blockMap } = props; | ||
// console.log(blockMap); | ||
const interfaceMap = groupByInterface(blockMap); | ||
// console.log(interfaceMap.values()); | ||
return ( | ||
<div style={{ maxHeight: 350, overflowY: 'scroll' }}> | ||
{Array.from(interfaceMap.values()).map((casesOfInterface) => { | ||
const interfaceItem = casesOfInterface[0]; | ||
return ( | ||
<Card | ||
style={{ marginBottom: 8 }} | ||
size='small' | ||
key={interfaceItem.request.id} | ||
title={interfaceItem.request.name} | ||
> | ||
<div style={{ display: 'flex', flexFlow: 'row wrap' }}> | ||
{casesOfInterface.map((runResult) => { | ||
return blockMap.get(runResult); | ||
})} | ||
</div> | ||
</Card> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
76 changes: 76 additions & 0 deletions
76
packages/arex/src/panes/BatchRun/BatchRunResultGroup/ByStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useTranslation } from '@arextest/arex-core'; | ||
import { Card } from 'antd'; | ||
import * as React from 'react'; | ||
import { ReactElement, ReactNode } from 'react'; | ||
|
||
import { RunResult } from '@/panes/BatchRun/BatchRun'; | ||
import { GroupProps } from '@/panes/BatchRun/BatchRunResultGroup/common'; | ||
|
||
const SendAbnormal = 0b1; | ||
const SendNormal = 0b1 << 1; | ||
const TestNormal = 0b1 << 2; | ||
const TestAbnormal = 0b1 << 3; | ||
|
||
const SendAbnormalTestAbnormal = SendAbnormal | TestAbnormal; | ||
const SendAbnormalTestNormal = SendAbnormal | TestNormal; | ||
const SendNormalTestAbnormal = SendNormal | TestAbnormal; | ||
const SendNormalTestNormal = SendNormal | TestNormal; | ||
|
||
function buildStatusMap(blockMap: Map<RunResult, React.ReactElement>) { | ||
const statusMap = new Map<number, React.ReactElement[]>(); | ||
for (const key of blockMap.keys()) { | ||
const { response } = key; | ||
const statusCode = response?.response?.statusCode ?? 0; | ||
const send = statusCode >= 200 && statusCode < 300 ? SendNormal : SendAbnormal; | ||
const test = | ||
// no case or all passed | ||
!response?.testResult?.length || response?.testResult?.every((t) => t.passed) | ||
? TestNormal | ||
: TestAbnormal; | ||
|
||
const status = send | test; | ||
if (status === SendAbnormalTestAbnormal) { | ||
console.log('SendAbnormalTestAbnormal', key); | ||
} | ||
|
||
if (!statusMap.has(status)) { | ||
statusMap.set(status, []); | ||
} | ||
statusMap.get(status)!.push(blockMap.get(key)!); | ||
} | ||
return statusMap; | ||
} | ||
|
||
const GroupCard = (props: { title: string; children?: ReactElement[] }) => { | ||
return ( | ||
<Card | ||
size='small' | ||
title={props.title} | ||
style={{ display: props.children?.length ? '' : 'none', marginBottom: 8 }} | ||
> | ||
<div style={{ display: 'flex', flexFlow: 'row wrap' }}>{props.children}</div> | ||
</Card> | ||
); | ||
}; | ||
|
||
export function ByStatus(props: GroupProps) { | ||
const { t } = useTranslation('page'); | ||
const { blockMap } = props; | ||
const statusMap = buildStatusMap(blockMap); | ||
return ( | ||
<> | ||
<GroupCard title={t('batchRunPage.sendNormalTestAbnormal')}> | ||
{statusMap.get(SendNormalTestAbnormal)} | ||
</GroupCard> | ||
<GroupCard title={t('batchRunPage.sendAbnormalTestNormal')}> | ||
{statusMap.get(SendAbnormalTestNormal)} | ||
</GroupCard> | ||
<GroupCard title={t('batchRunPage.sendAbnormalTestAbnormal')}> | ||
{statusMap.get(SendAbnormalTestAbnormal)} | ||
</GroupCard> | ||
<GroupCard title={t('batchRunPage.sendNormalTestNormal')}> | ||
{statusMap.get(SendNormalTestNormal)} | ||
</GroupCard> | ||
</> | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/arex/src/panes/BatchRun/BatchRunResultGroup/Flat.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as React from 'react'; | ||
|
||
import { GroupProps } from '@/panes/BatchRun/BatchRunResultGroup/common'; | ||
|
||
export function Flat(props: GroupProps) { | ||
const { blockMap } = props; | ||
return ( | ||
<> | ||
<div style={{ display: 'flex', flexFlow: 'row wrap' }}> | ||
{...Array.from(blockMap.values())} | ||
</div> | ||
</> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/arex/src/panes/BatchRun/BatchRunResultGroup/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactElement } from 'react'; | ||
|
||
import { RunResult } from '@/panes/BatchRun/BatchRun'; | ||
|
||
export type GroupProps = { | ||
blockMap: Map<RunResult, ReactElement>; | ||
selectedKey?: string; | ||
}; |
Oops, something went wrong.