-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Display raw values for primitive types * Add FactValue tests and detail stories * Fix factories using transient params * Fix props in CheckResultDetail test
- Loading branch information
1 parent
3846aa9
commit ae3589b
Showing
7 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
assets/js/components/ExecutionResults/CheckResultDetail/CheckResultDetail.stories.jsx
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,49 @@ | ||
import React from 'react'; | ||
import { | ||
addPassingExpectExpectation, | ||
addPassingExpectSameExpectation, | ||
emptyCheckResultFactory, | ||
hostFactory, | ||
checksExecutionCompletedFactory, | ||
checkResultFactory, | ||
addCriticalExpectExpectation, | ||
} from '@lib/test-utils/factories'; | ||
|
||
import CheckResultDetail from './CheckResultDetail'; | ||
|
||
const clusterHosts = hostFactory.buildList(2); | ||
const [{ id: target1 }, { id: target2 }] = clusterHosts; | ||
const targetType = 'host'; | ||
|
||
let checkResult = emptyCheckResultFactory.build({ | ||
targets: [target1, target2], | ||
}); | ||
|
||
const { check_id: checkID } = checkResult; | ||
|
||
checkResult = addPassingExpectExpectation(checkResult); | ||
checkResult = addPassingExpectExpectation(checkResult); | ||
checkResult = addCriticalExpectExpectation(checkResult); | ||
checkResult = addCriticalExpectExpectation(checkResult); | ||
checkResult = addCriticalExpectExpectation(checkResult); | ||
checkResult = addPassingExpectSameExpectation(checkResult, 'expectation_name'); | ||
|
||
const executionData = checksExecutionCompletedFactory.build({ | ||
check_results: [checkResultFactory.build(), checkResult], | ||
}); | ||
|
||
export default { | ||
title: 'CheckResultDetail', | ||
component: CheckResultDetail, | ||
args: { | ||
checkID, | ||
targetID: target1, | ||
targetType, | ||
executionData, | ||
expectations: [], | ||
}, | ||
}; | ||
|
||
export function Default(args) { | ||
return <CheckResultDetail {...args} />; | ||
} |
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
13 changes: 13 additions & 0 deletions
13
assets/js/components/ExecutionResults/CheckResultDetail/FactValue.jsx
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,13 @@ | ||
import React from 'react'; | ||
|
||
import ObjectTree from '@components/ObjectTree'; | ||
|
||
function FactValue({ className, data }) { | ||
return typeof data === 'object' ? ( | ||
<ObjectTree className={className} data={data} /> | ||
) : ( | ||
<span className={className}>{data}</span> | ||
); | ||
} | ||
|
||
export default FactValue; |
26 changes: 26 additions & 0 deletions
26
assets/js/components/ExecutionResults/CheckResultDetail/FactValue.test.jsx
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,26 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { faker } from '@faker-js/faker'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import { randomObjectFactory } from '@lib/test-utils/factories'; | ||
|
||
import FactValue from './FactValue'; | ||
|
||
describe('FactValue component', () => { | ||
it('should render just a scalar value', () => { | ||
const plainString = faker.hacker.noun(); | ||
|
||
render(<FactValue data={plainString} />); | ||
|
||
expect(screen.getByText(plainString)).toBeVisible(); | ||
}); | ||
|
||
it('should render just an object tree', () => { | ||
const data = randomObjectFactory.build(); | ||
|
||
render(<FactValue data={data} />); | ||
|
||
expect(screen.getAllByLabelText('property tree')).toHaveLength(1); | ||
}); | ||
}); |
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