Skip to content

Commit

Permalink
[Fleet] Edit package policy tests (elastic#125068)
Browse files Browse the repository at this point in the history
* edit package policy test

* moved out styled component, added null checks

* added tests for submit
  • Loading branch information
juliaElastic authored Feb 10, 2022
1 parent aad83ed commit f693a23
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 23 deletions.
15 changes: 8 additions & 7 deletions x-pack/plugins/fleet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ Write stories by creating `.stories.tsx` files colocated with the components you

The projects below are dependent on Fleet, most using Fleet API as well. In case of breaking changes in Fleet functionality/API, the project owners have to be notified to make sure they can plan for the necessary changes on their end to avoid unexpected break in functionality.

* [Elastic Agent](https://github.com/elastic/beats/blob/master/x-pack/elastic-agent): uses Fleet API to enroll agents. [See here](https://github.com/elastic/beats/blob/master/x-pack/elastic-agent/pkg/agent/cmd/container.go)
* [Fleet Server](https://github.com/elastic/fleet-server): uses Fleet API to enroll fleet server [See here](https://github.com/elastic/fleet-server/blob/master/cmd/fleet/router.go)
* [elastic-package](https://github.com/elastic/elastic-package): command line tool, uses Fleet with docker compose and Fleet API [See here](https://github.com/elastic/elastic-package/tree/master/internal/kibana)
* [Azure VM extension](https://github.com/elastic/azure-vm-extension): automation tool for Azure VMs, uses Fleet API to enroll agents [See here](https://github.com/elastic/azure-vm-extension/blob/main/src/handler/windows/scripts/enable.ps1)
* [e2e-testing](https://github.com/elastic/e2e-testing): internal project that runs Fleet and tests Fleet API [See here](https://github.com/elastic/e2e-testing/tree/main/internal/kibana)
* [observability-test-environments](https://github.com/elastic/observability-test-environments): internal project, uses Fleet API [See here](https://github.com/elastic/observability-test-environments/blob/master/ansible/tasks-fleet-config.yml)
* [ECK](https://github.com/elastic/cloud-on-k8s): Elastic Cloud on Kubernetes, orchestrates Elastic Stack applications, including Kibana with Fleet (no direct dependency, has examples that include Fleet config) [See here](https://github.com/elastic/cloud-on-k8s/blob/main/docs/orchestrating-elastic-stack-applications/agent-fleet.asciidoc)
* [Elastic Agent](https://github.com/elastic/beats/blob/master/x-pack/elastic-agent): uses Fleet API to enroll agents. [Check here](https://github.com/elastic/beats/blob/master/x-pack/elastic-agent/pkg/agent/cmd/container.go)
* [Fleet Server](https://github.com/elastic/fleet-server): uses Fleet API to enroll fleet server [Check here](https://github.com/elastic/fleet-server/blob/master/cmd/fleet/router.go)
* [elastic-package](https://github.com/elastic/elastic-package): command line tool, uses Fleet with docker compose and Fleet API [Check here](https://github.com/elastic/elastic-package/tree/master/internal/kibana)
* [Azure VM extension](https://github.com/elastic/azure-vm-extension): automation tool for Azure VMs, uses Fleet API to enroll agents [Check here](https://github.com/elastic/azure-vm-extension/blob/main/src/handler/windows/scripts/enable.ps1)
* [e2e-testing](https://github.com/elastic/e2e-testing): internal project that runs Fleet and tests Fleet API [Check here](https://github.com/elastic/e2e-testing/tree/main/internal/kibana)
* [observability-test-environments](https://github.com/elastic/observability-test-environments): internal project, uses Fleet API [Check here](https://github.com/elastic/observability-test-environments/blob/master/ansible/tasks-fleet-config.yml)
* [ECK](https://github.com/elastic/cloud-on-k8s): Elastic Cloud on Kubernetes, orchestrates Elastic Stack applications, including Kibana with Fleet (no direct dependency, has examples that include Fleet config) [Check here](https://github.com/elastic/cloud-on-k8s/blob/main/docs/orchestrating-elastic-stack-applications/agent-fleet.asciidoc)
* [APM Server](https://github.com/elastic/apm-server) APM Server, receives data from Elastic APM agents. Using docker compose for testing. [Check here](https://github.com/elastic/apm-server/pull/7227/files)
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export const PackagePolicyInputConfig: React.FunctionComponent<{
<EuiFlexGroup direction="column" gutterSize="m">
{requiredVars.map((varDef) => {
const { name: varName, type: varType } = varDef;
const { value, frozen } = packagePolicyInput.vars![varName];
if (!packagePolicyInput.vars) return;
const { value, frozen } = packagePolicyInput.vars[varName];
return (
<EuiFlexItem key={varName}>
<PackagePolicyInputVarField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const PackagePolicyInputPanel: React.FunctionComponent<{
packageInputVars={packageInput.vars}
packagePolicyInput={packagePolicyInput}
updatePackagePolicyInput={updatePackagePolicyInput}
inputVarsValidationResults={{ vars: inputValidationResults.vars }}
inputVarsValidationResults={{ vars: inputValidationResults?.vars }}
forceShowErrors={forceShowErrors}
/>
{hasInputStreams ? <ShortenedHorizontalRule margin="m" /> : <EuiSpacer size="l" />}
Expand Down Expand Up @@ -238,7 +238,7 @@ export const PackagePolicyInputPanel: React.FunctionComponent<{
updatePackagePolicyInput(updatedInput);
}}
inputStreamValidationResults={
inputValidationResults.streams![packagePolicyInputStream!.data_stream!.dataset]
inputValidationResults?.streams![packagePolicyInputStream!.data_stream!.dataset]
}
forceShowErrors={forceShowErrors}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
const advancedVarsWithErrorsCount: number = useMemo(
() =>
advancedVars.filter(
({ name: varName }) => inputStreamValidationResults.vars?.[varName]?.length
({ name: varName }) => inputStreamValidationResults?.vars?.[varName]?.length
).length,
[advancedVars, inputStreamValidationResults.vars]
[advancedVars, inputStreamValidationResults?.vars]
);

return (
Expand Down Expand Up @@ -106,7 +106,7 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
<FlexItemWithMaxWidth>
<EuiFlexGroup direction="column" gutterSize="m">
{requiredVars.map((varDef) => {
if (!packagePolicyInputStream.vars) return null;
if (!packagePolicyInputStream?.vars) return null;
const { name: varName, type: varType } = varDef;
const varConfigEntry = packagePolicyInputStream.vars?.[varName];
const value = varConfigEntry?.value;
Expand All @@ -129,7 +129,7 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
},
});
}}
errors={inputStreamValidationResults.vars![varName]}
errors={inputStreamValidationResults?.vars![varName]}
forceShowErrors={forceShowErrors}
/>
</EuiFlexItem>
Expand Down Expand Up @@ -187,7 +187,7 @@ export const PackagePolicyInputStreamConfig: React.FunctionComponent<{
},
});
}}
errors={inputStreamValidationResults.vars![varName]}
errors={inputStreamValidationResults?.vars![varName]}
forceShowErrors={forceShowErrors}
/>
</EuiFlexItem>
Expand Down
Loading

0 comments on commit f693a23

Please sign in to comment.