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

Removed delete confirmation timeout to avoid flaky failing because deletion to be a little slower on CI #77963

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { useEffect, useState } from 'react';
import { HttpSetup } from 'kibana/public';
import { useAppDependencies } from '../app_context';

Expand All @@ -17,6 +17,7 @@ export const DeleteModalConfirmation = ({
onErrors,
singleTitle,
multipleTitle,
setIsLoadingState,
}: {
idsToDelete: string[];
apiDeleteCall: ({
Expand All @@ -31,10 +32,17 @@ export const DeleteModalConfirmation = ({
onErrors: () => void;
singleTitle: string;
multipleTitle: string;
setIsLoadingState: (isLoading: boolean) => void;
}) => {
const [deleteModalFlyoutVisible, setDeleteModalVisibility] = useState<boolean>(false);

useEffect(() => {
setDeleteModalVisibility(idsToDelete.length > 0);
}, [idsToDelete]);

const { http, toastNotifications } = useAppDependencies();
const numIdsToDelete = idsToDelete.length;
if (!numIdsToDelete) {
if (!deleteModalFlyoutVisible) {
return null;
}
const confirmModalText = i18n.translate(
Expand Down Expand Up @@ -65,12 +73,18 @@ export const DeleteModalConfirmation = ({
buttonColor="danger"
data-test-subj="deleteIdsConfirmation"
title={confirmButtonText}
onCancel={() => onCancel()}
onCancel={() => {
setDeleteModalVisibility(false);
onCancel();
}}
onConfirm={async () => {
setDeleteModalVisibility(false);
setIsLoadingState(true);
const { successes, errors } = await apiDeleteCall({ ids: idsToDelete, http });
setIsLoadingState(false);

const numSuccesses = successes.length;
const numErrors = errors.length;
onDeleted(successes);
if (numSuccesses > 0) {
toastNotifications.addSuccess(
i18n.translate(
Expand All @@ -95,8 +109,9 @@ export const DeleteModalConfirmation = ({
}
)
);
onErrors();
await onErrors();
}
await onDeleted(successes);
}}
cancelButtonText={cancelButtonText}
confirmButtonText={confirmButtonText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ export const ActionsConnectorsList: React.FunctionComponent = () => {
'xpack.triggersActionsUI.sections.actionsConnectorsList.multipleTitle',
{ defaultMessage: 'connectors' }
)}
setIsLoadingState={(isLoading: boolean) => setIsLoadingActionTypes(isLoading)}
/>
<EuiSpacer size="m" />
{/* Render the view based on if there's data or if they can save */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ export const AlertsList: React.FunctionComponent = () => {
<section data-test-subj="alertsList">
<DeleteModalConfirmation
onDeleted={async (deleted: string[]) => {
loadAlertsData();
setSelectedIds([]);
setAlertsToDelete([]);
setSelectedIds([]);
await loadAlertsData();
}}
onErrors={async () => {
// Refresh the alerts from the server, some alerts may have beend deleted
await loadAlertsData();
setAlertsToDelete([]);
}}
onCancel={async () => {
onCancel={() => {
setAlertsToDelete([]);
}}
apiDeleteCall={deleteAlerts}
Expand All @@ -424,6 +424,9 @@ export const AlertsList: React.FunctionComponent = () => {
multipleTitle={i18n.translate('xpack.triggersActionsUI.sections.alertsList.multipleTitle', {
defaultMessage: 'alerts',
})}
setIsLoadingState={(isLoading: boolean) => {
setAlertsState({ ...alertsState, isLoading });
}}
/>
<EuiSpacer size="m" />
{loadedItems.length || isFilterApplied ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
return createdAlert;
}

// FLAKY: https://github.com/elastic/kibana/issues/77401
describe.skip('alerts', function () {
describe('alerts', function () {
before(async () => {
await pageObjects.common.navigateToApp('triggersActions');
await testSubjects.click('alertsTab');
Expand Down Expand Up @@ -385,9 +384,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.click('deleteAll');
await testSubjects.existOrFail('deleteIdsConfirmation');
await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton');
await testSubjects.missingOrFail('deleteIdsConfirmation', { timeout: 5000 });
await testSubjects.missingOrFail('deleteIdsConfirmation');

await pageObjects.common.closeToast();
await retry.try(async () => {
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql('Deleted 10 alerts');
});
Comment on lines -388 to +392
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems much more reliable!
Good change 👍


await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(namePrefix);
Expand Down