Skip to content

Commit

Permalink
[Cases] Add e2e tests for category (#160149)
Browse files Browse the repository at this point in the history
## Summary

Added functional tests for the category.

Flaky test runner: 
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2444
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2475

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
js-jankisalvi and kibanamachine authored Jun 26, 2023
1 parent 0e67ae3 commit 2c24494
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const useCasesColumns = ({
sortable: true,
render: (category: CaseUI['category']) => {
if (category != null) {
return category;
return <span data-test-subj={`case-table-column-category-${category}`}>{category}</span>;
}
return getEmptyTagValue();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ describe('Category viewer ', () => {
it('renders category', () => {
render(<CategoryViewer category={sampleCategory} />);

expect(screen.getByText(sampleCategory)).toBeInTheDocument();
expect(screen.getByTestId(`category-viewer-${sampleCategory}`)).toHaveTextContent(
sampleCategory
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface CategoryViewerProps {
}

const CategoryViewerComponent: React.FC<CategoryViewerProps> = ({ category }) => (
<EuiText data-test-subj="category-viewer" key={category} size="s">
<EuiText data-test-subj={`category-viewer-${category}`} key={category} size="s">
{category}
</EuiText>
);
Expand Down
10 changes: 10 additions & 0 deletions x-pack/test/functional/services/cases/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface CreateCaseParams {
tag?: string;
severity?: CaseSeverity;
owner?: string;
category?: string;
assignees?: [];
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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`);
},
Expand Down
9 changes: 9 additions & 0 deletions x-pack/test/functional/services/cases/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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');
Expand Down
23 changes: 23 additions & 0 deletions x-pack/test/functional_with_es_ssl/apps/cases/group1/view_case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
10 changes: 10 additions & 0 deletions x-pack/test/functional_with_es_ssl/apps/cases/group2/list_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] });
Expand Down Expand Up @@ -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']}`);
Expand Down

0 comments on commit 2c24494

Please sign in to comment.