diff --git a/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx b/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx index 8b37c52a48166..d5d8493e13ecf 100644 --- a/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx +++ b/x-pack/plugins/cases/public/components/all_cases/use_cases_columns.tsx @@ -240,7 +240,7 @@ export const useCasesColumns = ({ sortable: true, render: (category: CaseUI['category']) => { if (category != null) { - return category; + return {category}; } return getEmptyTagValue(); }, diff --git a/x-pack/plugins/cases/public/components/category/category_viewer_component.test.tsx b/x-pack/plugins/cases/public/components/category/category_viewer_component.test.tsx index 9d93ddd3eae92..a685e1af4fa71 100644 --- a/x-pack/plugins/cases/public/components/category/category_viewer_component.test.tsx +++ b/x-pack/plugins/cases/public/components/category/category_viewer_component.test.tsx @@ -16,6 +16,8 @@ describe('Category viewer ', () => { it('renders category', () => { render(); - expect(screen.getByText(sampleCategory)).toBeInTheDocument(); + expect(screen.getByTestId(`category-viewer-${sampleCategory}`)).toHaveTextContent( + sampleCategory + ); }); }); diff --git a/x-pack/plugins/cases/public/components/category/category_viewer_component.tsx b/x-pack/plugins/cases/public/components/category/category_viewer_component.tsx index d366e1546aba3..5df870d11423e 100644 --- a/x-pack/plugins/cases/public/components/category/category_viewer_component.tsx +++ b/x-pack/plugins/cases/public/components/category/category_viewer_component.tsx @@ -13,7 +13,7 @@ interface CategoryViewerProps { } const CategoryViewerComponent: React.FC = ({ category }) => ( - + {category} ); diff --git a/x-pack/test/functional/services/cases/create.ts b/x-pack/test/functional/services/cases/create.ts index a1fd58d817e66..05c8be53fd227 100644 --- a/x-pack/test/functional/services/cases/create.ts +++ b/x-pack/test/functional/services/cases/create.ts @@ -16,6 +16,7 @@ export interface CreateCaseParams { tag?: string; severity?: CaseSeverity; owner?: string; + category?: string; assignees?: []; } @@ -54,12 +55,17 @@ export function CasesCreateViewServiceProvider( description = 'desc' + uuidv4(), tag = 'tagme', severity = CaseSeverity.LOW, + category, owner, }: CreateCaseParams) { await this.setTitle(title); await this.setDescription(description); await this.setTags(tag); + if (category) { + await this.setCategory(category); + } + if (severity !== CaseSeverity.LOW) { await this.setSeverity(severity); } @@ -85,6 +91,10 @@ export function CasesCreateViewServiceProvider( await comboBox.setCustom('caseTags', tag); }, + async setCategory(category: string) { + await comboBox.setCustom('categories-list', category); + }, + async setSolution(owner: string) { await testSubjects.click(`${owner}RadioButton`); }, diff --git a/x-pack/test/functional/services/cases/list.ts b/x-pack/test/functional/services/cases/list.ts index 492a25f1fa151..de03d2a236e14 100644 --- a/x-pack/test/functional/services/cases/list.ts +++ b/x-pack/test/functional/services/cases/list.ts @@ -142,6 +142,15 @@ export function CasesTableServiceProvider( await testSubjects.click(`options-filter-popover-item-${tag}`); }, + async filterByCategory(category: string) { + await common.clickAndValidate( + 'options-filter-popover-button-Categories', + `options-filter-popover-item-${category}` + ); + + await testSubjects.click(`options-filter-popover-item-${category}`); + }, + async filterByStatus(status: CaseStatuses) { await common.clickAndValidate('case-status-filter', `case-status-filter-${status}`); diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group1/create_case_form.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group1/create_case_form.ts index fe8ed483db24a..df6fc1fa58e5d 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group1/create_case_form.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group1/create_case_form.ts @@ -40,6 +40,7 @@ export default ({ getService, getPageObject }: FtrProviderContext) => { description: 'test description', tag: 'tagme', severity: CaseSeverity.HIGH, + category: 'new', }); await testSubjects.existOrFail('case-view-title', { @@ -57,6 +58,9 @@ export default ({ getService, getPageObject }: FtrProviderContext) => { // validate tag exists await testSubjects.existOrFail('tag-tagme'); + // validate category exists + await testSubjects.existOrFail('category-viewer-new'); + // validate no connector added const button = await find.byCssSelector('[data-test-subj*="case-callout"] button'); expect(await button.getVisibleText()).equal('Add connector'); diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group1/view_case.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group1/view_case.ts index dd584a51fa979..35b0ba829dcf9 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group1/view_case.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group1/view_case.ts @@ -63,6 +63,29 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { expect(await newComment.getVisibleText()).equal('Test comment from automation'); }); + it('adds a category to a case', async () => { + const category = uuidv4(); + await testSubjects.click('category-edit-button'); + await comboBox.setCustom('comboBoxInput', category); + await testSubjects.click('edit-category-submit'); + + // validate category was added + await testSubjects.existOrFail('category-viewer-' + category); + + // validate user action + await find.byCssSelector('[data-test-subj*="category-update-action"]'); + }); + + it('deletes a category from a case', async () => { + await find.byCssSelector('[data-test-subj*="category-viewer-"]'); + + await testSubjects.click('category-remove-button'); + + await testSubjects.existOrFail('no-categories'); + // validate user action + await find.byCssSelector('[data-test-subj*="category-delete-action"]'); + }); + it('adds a tag to a case', async () => { const tag = uuidv4(); await testSubjects.click('tag-list-edit-button'); diff --git a/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts b/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts index 1fee6d5e1b0fe..f19d488b4dc25 100644 --- a/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts +++ b/x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts @@ -293,6 +293,7 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { const case1 = await cases.api.createCase({ title: caseTitle, tags: ['one'], + category: 'foobar', description: 'lots of information about an incident', }); const case2 = await cases.api.createCase({ title: 'test2', tags: ['two'] }); @@ -428,6 +429,15 @@ export default ({ getPageObject, getService }: FtrProviderContext) => { expect(await tags.getVisibleText()).to.be('one'); }); + it('filters cases by category', async () => { + await cases.casesTable.filterByCategory('foobar'); + await cases.casesTable.refreshTable(); + await cases.casesTable.validateCasesTableHasNthRows(1); + const row = await cases.casesTable.getCaseByIndex(0); + const category = await row.findByTestSubject('case-table-column-category-foobar'); + expect(await category.getVisibleText()).to.be('foobar'); + }); + it('filters cases by status', async () => { await cases.casesTable.changeStatus(CaseStatuses['in-progress'], 0); await testSubjects.existOrFail(`case-status-badge-${CaseStatuses['in-progress']}`);