Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cases] Custom fields feature fix tests #167472

Conversation

js-jankisalvi
Copy link
Contributor

@js-jankisalvi js-jankisalvi commented Sep 28, 2023

Summary

Connected to #160236

This PR fixes tests for custom field mvp feature

Checklist

cnasikas and others added 29 commits September 22, 2023 10:48
@js-jankisalvi js-jankisalvi added the Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) label Sep 28, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@js-jankisalvi js-jankisalvi added the release_note:skip Skip the PR/issue when compiling release notes label Sep 28, 2023
Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Janki for working on this. I left some comments.

@@ -495,31 +495,11 @@ describe('create', () => {
);
});

it('should not throw an error and fill out missing customFields when they are undefined', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this test and the new test you added ("should throw an error when required `customFields are undefined"). For this test, we need to make all fields in the configuration optional.

if (customFieldsConfiguration === undefined) {
throw Boom.badRequest('No custom fields configured.');
if (!Array.isArray(requestCustomFields) || !requestCustomFields.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused about this change. What scenario are we trying to cover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange, this doesn't seem to be my change 😄

Copy link
Member

@cnasikas cnasikas Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that @adcoelho tried to fix some tests in f10dd1b (#167472)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if there is no configuration or no custom fields we should return. The function validates only required custom fields so no configuration means no custom fields are required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed offline and we decided to leave it as it is.

x-pack/test/cases_api_integration/common/lib/mock.ts Outdated Show resolved Hide resolved
@@ -50,7 +50,7 @@ export default ({ getService }: FtrProviderContext): void => {
});

it('should resolve a case with no comments', async () => {
const postedCase = await createCase(supertest, getPostCaseRequest());
const postedCase = await createCase(supertest, postCaseReq);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that because the getPostCaseRequest() has customFields failed. I think we should getPostCaseRequest and not add the customFields in getPostCaseRequest. See my previous comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually here I am not sure what was wrong because the test passed in local and failed in pipeline

@cnasikas cnasikas mentioned this pull request Sep 29, 2023
4 tasks
@cnasikas cnasikas added ci:cloud-deploy Create or update a Cloud deployment ci:project-deploy-security Create a Security Serverless Project labels Sep 29, 2023
@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 29, 2023

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #1 / cases security and spaces enabled: basic Common resolve_case should resolve a case with no comments
  • [job] [logs] FTR Configs #1 / cases security and spaces enabled: basic Common resolve_case should resolve a case with no comments
  • [job] [logs] FTR Configs #21 / cases security and spaces enabled: trial Common resolve_case should resolve a case with no comments
  • [job] [logs] FTR Configs #21 / cases security and spaces enabled: trial Common resolve_case should resolve a case with no comments
  • [job] [logs] Jest Integration Tests #1 / checking migration metadata changes on all registered SO types detecting migration related changes in registered types
  • [job] [logs] Investigations - Security Solution Cypress Tests #4 / Open timeline Open timeline modal "before each" hook for "should display timeline content - description" "before each" hook for "should display timeline content - description"

Metrics [docs]

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/saved-objects-service.html#_mappings

id before after diff
_data_stream_timestamp - 1 +1
_doc_count - 1 +1
_tier - 1 +1
apm-server-schema - 2 +2
apm-service-group - 5 +5
application_usage_daily - 2 +2
config - 2 +2
config-global - 2 +2
coreMigrationVersion - 1 +1
created_at - 1 +1
event_loop_delays_daily - 2 +2
file - 11 +11
file-upload-usage-collection-telemetry - 3 +3
fileShare - 5 +5
guided-onboarding-guide-state - 3 +3
infrastructure-monitoring-log-view - 2 +2
legacy-url-alias - 7 +7
managed - 1 +1
ml-job - 6 +6
ml-module - 11 +11
ml-trained-model - 7 +7
monitoring-telemetry - 2 +2
namespace - 1 +1
namespaces - 1 +1
observability-onboarding-state - 2 +2
originId - 1 +1
references - 4 +4
sample-data-telemetry - 3 +3
slo - 10 +10
space - 3 +3
synthetics-monitor - 32 +32
tag - 4 +4
type - 1 +1
typeMigrationVersion - 1 +1
ui-metric - 2 +2
updated_at - 1 +1
upgrade-assistant-ml-upgrade-operation - 3 +3
upgrade-assistant-reindex-operation - 3 +3
uptime-synthetics-api-key - 2 +2
url - 5 +5
usage-counters - 2 +2
total +159

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @js-jankisalvi

@js-jankisalvi js-jankisalvi merged commit 60cdab5 into elastic:cases-custom-fields-feature-branch Sep 29, 2023
1 check passed
js-jankisalvi added a commit that referenced this pull request Oct 2, 2023
## Summary

This PR implements an MPV for custom fields in Cases. Specifically:

- Users can add, delete, or edit custom fields from the configuration
page
- Users can set custom fields when creating a case
- Users can set custom fields when editing a case
- Only the `Text` custom field type is supported. The `Toggle` is
implemented to test the framework.
- Users with a basic license can enter the configuration page and set
custom fields
- The configuration page header changed to "Settings"
- The "Edit external connection" button changed to "Settings"
- APIs:
    - Users cannot post custom fields with duplicate keys
    - Users cannot change the type of the custom field
    - Users cannot add custom fields that are not configured
    - Required fields should be present
- If some of the custom fields are omitted from the request the backend
will fill them with `null` values
- Limits:
    - Maximum 10 custom fields configured
    - Maximum 50 chars in custom field labels
    - Maximum 160 chars for the value of the `Text` custom field type
    - Users cannot change the type of a custom field
- The key of the custom fields should contain only lowercase letters
(a-z), numbers (0-9), '_', and '-'
    - Required fields needs a value

## Testing
- Cases created before custom fields are working as expected (create
some on `main` before switching to the feature branch)
- Environments without configuration are working as expected (clear ES
data)
- Environments with existing configurations are working as expected
- Try to create cases with custom fields (required & optional) and
delete some of them
- Try to create cases with custom fields (required & optional) and then
configure new custom fields. Existing cases with old custom fields
should work as expected
- User actions are working as expected especially with the combinations
described in the previous two bullets
- Users with a basic license can configure custom fields but cannot
configure connectors
- Users with a gold+ license can configure custom fields and connectors
- Users with read access cannot configure or edit custom fields

Resolves: #160236

PRs:

- #165671
- #166353
- #166439
- #166483
- #166815
- #166940
- #166962
- #166969
- #166975
- #167029
- #167047
- #167105
- #167131
- #167144
- #167166
- #167167
- #167310
- #167386
- #167481
- #167495
- #167398
- #167472

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

## Release notes
Allow users to configure custom fields in Cases. Supported field types:
Text. Coming soon: Multi-text, List, Number, Toggle, Date, IP, Email,
etc.

---------

Co-authored-by: adcoelho <[email protected]>
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Christos Nasikas <[email protected]>
Co-authored-by: Julian Gernun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:cloud-deploy Create or update a Cloud deployment ci:project-deploy-security Create a Security Serverless Project Feature:Cases Cases feature release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants