From eb5c988746cc06afb20c309b2224849821a2c2e8 Mon Sep 17 00:00:00 2001 From: Julia Guskova Date: Fri, 11 Aug 2023 11:11:51 +0200 Subject: [PATCH] do unit test instead e2e --- .../rules_list/components/rules_list.test.tsx | 13 ++++- .../rules_list/maintenance_window_banner.ts | 50 ------------------- 2 files changed, 12 insertions(+), 51 deletions(-) delete mode 100644 x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/maintenance_window_banner.ts diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx index 1a1a3eab0cf14..0c2c508b3f719 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx @@ -104,7 +104,11 @@ jest.mock('react-router-dom', () => ({ pathname: '/triggersActions/rules/', }), })); -jest.mock('@kbn/alerts-ui-shared', () => ({ MaintenanceWindowCallout: jest.fn(() => <>) })); +jest.mock('@kbn/alerts-ui-shared', () => ({ + MaintenanceWindowCallout: jest.fn(() => ( +
+ )), +})); jest.mock('../../../lib/capabilities', () => ({ hasAllPrivilege: jest.fn(() => true), @@ -246,6 +250,13 @@ describe('rules_list component empty', () => { expect(await screen.findByTestId('createFirstRuleEmptyPrompt')).toBeInTheDocument(); }); + it('renders MaintenanceWindowCallout mocked component', async () => { + renderWithProviders(); + expect( + await screen.findByTestId('mocked-MaintenanceWindowCallout-component') + ).toBeInTheDocument(); + }); + it('renders Create rule button', async () => { renderWithProviders(); diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/maintenance_window_banner.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/maintenance_window_banner.ts deleted file mode 100644 index fdaf29fea63b0..0000000000000 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/rules_list/maintenance_window_banner.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FtrProviderContext } from '../../../ftr_provider_context'; -import { ObjectRemover } from '../../../lib/object_remover'; -import { generateUniqueKey } from '../../../lib/get_test_data'; -import { createMaintenanceWindow, createObjectRemover } from '../maintenance_windows/utils'; - -export default ({ getPageObjects, getService }: FtrProviderContext) => { - const testSubjects = getService('testSubjects'); - const pageObjects = getPageObjects(['common']); - - let objectRemover: ObjectRemover; - const browser = getService('browser'); - - describe('Maintenance windows banner', () => { - before(async () => { - objectRemover = await createObjectRemover({ getService }); - }); - - after(async () => { - await objectRemover.removeAll(); - }); - - it('should not show a maintenance window banner', async () => { - await pageObjects.common.navigateToApp('triggersActions'); - await testSubjects.click('rulesTab'); - await testSubjects.missingOrFail('maintenanceWindow'); - }); - - it('should show a maintenance window banner', async () => { - await pageObjects.common.navigateToApp('maintenanceWindows'); - const name = generateUniqueKey(); - const createdMaintenanceWindow = await createMaintenanceWindow({ - name, - getService, - }); - objectRemover.add(createdMaintenanceWindow.id, 'rules/maintenance_window', 'alerting', true); - await browser.refresh(); - - await pageObjects.common.navigateToApp('triggersActions'); - await testSubjects.click('rulesTab'); - await testSubjects.existOrFail('maintenanceWindow'); - }); - }); -};