Fix skipped alerting UI tests (#55058)

* Fix skipped alerting UI tests

* Fix switch click to use new pageobject function

* Use .click function directly instead of find then click

* Merge state variables into one for alerts and alert types

* Fix flaky tests by fixing react code

* Could this be it?? The one thing missing that caused all this flakiness??

* Cleanup convertAlertsToTableItems function

* Remove I from interface names, fix disabled boolean logic

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Mike Côté 2020-01-24 12:50:22 -05:00 committed by GitHub
parent 06aeb8196f
commit ea3aa9c9b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 145 additions and 199 deletions

View file

@ -31,6 +31,17 @@ import { hasDeleteAlertsCapability, hasSaveAlertsCapability } from '../../../lib
const ENTER_KEY = 13;
interface AlertTypeState {
isLoading: boolean;
isInitialized: boolean;
data: AlertTypeIndex;
}
interface AlertState {
isLoading: boolean;
data: Alert[];
totalItemCount: number;
}
export const AlertsList: React.FunctionComponent = () => {
const {
http,
@ -43,20 +54,24 @@ export const AlertsList: React.FunctionComponent = () => {
const createAlertUiEnabled = injectedMetadata.getInjectedVar('createAlertUiEnabled');
const [actionTypes, setActionTypes] = useState<ActionType[]>([]);
const [alertTypesIndex, setAlertTypesIndex] = useState<AlertTypeIndex | undefined>(undefined);
const [alerts, setAlerts] = useState<Alert[]>([]);
const [data, setData] = useState<AlertTableItem[]>([]);
const [selectedIds, setSelectedIds] = useState<string[]>([]);
const [isLoadingAlertTypes, setIsLoadingAlertTypes] = useState<boolean>(false);
const [isLoadingAlerts, setIsLoadingAlerts] = useState<boolean>(false);
const [isPerformingAction, setIsPerformingAction] = useState<boolean>(false);
const [totalItemCount, setTotalItemCount] = useState<number>(0);
const [page, setPage] = useState<Pagination>({ index: 0, size: 10 });
const [searchText, setSearchText] = useState<string | undefined>();
const [inputText, setInputText] = useState<string | undefined>();
const [typesFilter, setTypesFilter] = useState<string[]>([]);
const [actionTypesFilter, setActionTypesFilter] = useState<string[]>([]);
const [alertFlyoutVisible, setAlertFlyoutVisibility] = useState<boolean>(false);
const [alertTypesState, setAlertTypesState] = useState<AlertTypeState>({
isLoading: false,
isInitialized: false,
data: {},
});
const [alertsState, setAlertsState] = useState<AlertState>({
isLoading: false,
data: [],
totalItemCount: 0,
});
useEffect(() => {
loadAlertsData();
@ -66,13 +81,13 @@ export const AlertsList: React.FunctionComponent = () => {
useEffect(() => {
(async () => {
try {
setIsLoadingAlertTypes(true);
setAlertTypesState({ ...alertTypesState, isLoading: true });
const alertTypes = await loadAlertTypes({ http });
const index: AlertTypeIndex = {};
for (const alertType of alertTypes) {
index[alertType.id] = alertType;
}
setAlertTypesIndex(index);
setAlertTypesState({ isLoading: false, data: index, isInitialized: true });
} catch (e) {
toastNotifications.addDanger({
title: i18n.translate(
@ -80,8 +95,7 @@ export const AlertsList: React.FunctionComponent = () => {
{ defaultMessage: 'Unable to load alert types' }
),
});
} finally {
setIsLoadingAlertTypes(false);
setAlertTypesState({ ...alertTypesState, isLoading: false });
}
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
@ -104,23 +118,8 @@ export const AlertsList: React.FunctionComponent = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
// Avoid flickering before alert types load
if (typeof alertTypesIndex === 'undefined') {
return;
}
const updatedData = alerts.map(alert => ({
...alert,
tagsText: alert.tags.join(', '),
alertType: alertTypesIndex[alert.alertTypeId]
? alertTypesIndex[alert.alertTypeId].name
: alert.alertTypeId,
}));
setData(updatedData);
}, [alerts, alertTypesIndex]);
async function loadAlertsData() {
setIsLoadingAlerts(true);
setAlertsState({ ...alertsState, isLoading: true });
try {
const alertsResponse = await loadAlerts({
http,
@ -129,8 +128,11 @@ export const AlertsList: React.FunctionComponent = () => {
typesFilter,
actionTypesFilter,
});
setAlerts(alertsResponse.data);
setTotalItemCount(alertsResponse.total);
setAlertsState({
isLoading: false,
data: alertsResponse.data,
totalItemCount: alertsResponse.total,
});
} catch (e) {
toastNotifications.addDanger({
title: i18n.translate(
@ -140,8 +142,7 @@ export const AlertsList: React.FunctionComponent = () => {
}
),
});
} finally {
setIsLoadingAlerts(false);
setAlertsState({ ...alertsState, isLoading: false });
}
}
@ -200,7 +201,7 @@ export const AlertsList: React.FunctionComponent = () => {
<TypeFilter
key="type-filter"
onChange={(types: string[]) => setTypesFilter(types)}
options={Object.values(alertTypesIndex || {})
options={Object.values(alertTypesState.data)
.map(alertType => ({
value: alertType.id,
name: alertType.name,
@ -241,7 +242,10 @@ export const AlertsList: React.FunctionComponent = () => {
{selectedIds.length > 0 && canDelete && (
<EuiFlexItem grow={false}>
<BulkActionPopover
selectedItems={pickFromData(data, selectedIds)}
selectedItems={convertAlertsToTableItems(
filterAlertsById(alertsState.data, selectedIds),
alertTypesState.data
)}
onPerformingAction={() => setIsPerformingAction(true)}
onActionPerformed={() => {
loadAlertsData();
@ -282,8 +286,13 @@ export const AlertsList: React.FunctionComponent = () => {
<EuiSpacer size="l" />
<EuiBasicTable
loading={isLoadingAlerts || isLoadingAlertTypes || isPerformingAction}
items={data}
loading={alertsState.isLoading || alertTypesState.isLoading || isPerformingAction}
/* Don't display alerts until we have the alert types initialized */
items={
alertTypesState.isInitialized === false
? []
: convertAlertsToTableItems(alertsState.data, alertTypesState.data)
}
itemId="id"
columns={alertsTableColumns}
rowProps={() => ({
@ -296,7 +305,9 @@ export const AlertsList: React.FunctionComponent = () => {
pagination={{
pageIndex: page.index,
pageSize: page.size,
totalItemCount,
/* Don't display alert count until we have the alert types initialized */
totalItemCount:
alertTypesState.isInitialized === false ? 0 : alertsState.totalItemCount,
}}
selection={
canDelete
@ -318,13 +329,14 @@ export const AlertsList: React.FunctionComponent = () => {
);
};
function pickFromData(data: AlertTableItem[], ids: string[]): AlertTableItem[] {
const result: AlertTableItem[] = [];
for (const id of ids) {
const match = data.find(item => item.id === id);
if (match) {
result.push(match);
}
}
return result;
function filterAlertsById(alerts: Alert[], ids: string[]): Alert[] {
return alerts.filter(alert => ids.includes(alert.id));
}
function convertAlertsToTableItems(alerts: Alert[], alertTypesIndex: AlertTypeIndex) {
return alerts.map(alert => ({
...alert,
tagsText: alert.tags.join(', '),
alertType: alertTypesIndex[alert.alertTypeId]?.name ?? alert.alertTypeId,
}));
}

View file

@ -44,8 +44,6 @@ export const CollapsedItemActions: React.FunctionComponent<ComponentOpts> = ({
const canDelete = hasDeleteAlertsCapability(capabilities.get());
const canSave = hasSaveAlertsCapability(capabilities.get());
const [isEnabled, setIsEnabled] = useState<boolean>(item.enabled);
const [isMuted, setIsMuted] = useState<boolean>(item.muteAll);
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
const button = (
@ -72,14 +70,12 @@ export const CollapsedItemActions: React.FunctionComponent<ComponentOpts> = ({
<EuiSwitch
name="enable"
disabled={!canSave}
checked={isEnabled}
checked={item.enabled}
data-test-subj="enableSwitch"
onChange={async () => {
if (isEnabled) {
setIsEnabled(false);
if (item.enabled) {
await disableAlerts({ http, ids: [item.id] });
} else {
setIsEnabled(true);
await enableAlerts({ http, ids: [item.id] });
}
onAlertChanged();
@ -95,15 +91,13 @@ export const CollapsedItemActions: React.FunctionComponent<ComponentOpts> = ({
<EuiFormRow>
<EuiSwitch
name="mute"
checked={isMuted}
disabled={!canSave || !isEnabled}
checked={item.muteAll}
disabled={!(canSave && item.enabled)}
data-test-subj="muteSwitch"
onChange={async () => {
if (isMuted) {
setIsMuted(false);
if (item.muteAll) {
await unmuteAlerts({ http, ids: [item.id] });
} else {
setIsMuted(true);
await muteAlerts({ http, ids: [item.id] });
}
onAlertChanged();

View file

@ -40,8 +40,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
describe('alerts', function() {
before(async () => {
await pageObjects.common.navigateToApp('triggersActions');
const alertsTab = await testSubjects.find('alertsTab');
await alertsTab.click();
await testSubjects.click('alertsTab');
});
it('should search for alert', async () => {
@ -76,123 +75,100 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
]);
});
// Flaky until https://github.com/elastic/eui/issues/2612 fixed
it.skip('should disable single alert', async () => {
it('should disable single alert', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const enableSwitch = await testSubjects.find('enableSwitch');
await enableSwitch.click();
await pageObjects.triggersActionsUI.toggleSwitch('enableSwitch');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActionsAfterDisable = await testSubjects.find('collapsedItemActions');
await collapsedItemActionsAfterDisable.click();
await testSubjects.click('collapsedItemActions');
const enableSwitchAfterDisable = await testSubjects.find('enableSwitch');
const isChecked = await enableSwitchAfterDisable.getAttribute('aria-checked');
expect(isChecked).to.eql('false');
});
// Flaky until https://github.com/elastic/eui/issues/2612 fixed
it.skip('should re-enable single alert', async () => {
it('should re-enable single alert', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const enableSwitch = await testSubjects.find('enableSwitch');
await enableSwitch.click();
await pageObjects.triggersActionsUI.toggleSwitch('enableSwitch');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActionsAfterDisable = await testSubjects.find('collapsedItemActions');
await collapsedItemActionsAfterDisable.click();
await testSubjects.click('collapsedItemActions');
const enableSwitchAfterDisable = await testSubjects.find('enableSwitch');
await enableSwitchAfterDisable.click();
await pageObjects.triggersActionsUI.toggleSwitch('enableSwitch');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActionsAfterReEnable = await testSubjects.find('collapsedItemActions');
await collapsedItemActionsAfterReEnable.click();
await testSubjects.click('collapsedItemActions');
const enableSwitchAfterReEnable = await testSubjects.find('enableSwitch');
const isChecked = await enableSwitchAfterReEnable.getAttribute('aria-checked');
expect(isChecked).to.eql('true');
});
// Flaky until https://github.com/elastic/eui/issues/2612 fixed
it.skip('should mute single alert', async () => {
it('should mute single alert', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const muteSwitch = await testSubjects.find('muteSwitch');
await muteSwitch.click();
await pageObjects.triggersActionsUI.toggleSwitch('muteSwitch');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActionsAfterMute = await testSubjects.find('collapsedItemActions');
await collapsedItemActionsAfterMute.click();
await testSubjects.click('collapsedItemActions');
const muteSwitchAfterMute = await testSubjects.find('muteSwitch');
const isChecked = await muteSwitchAfterMute.getAttribute('aria-checked');
expect(isChecked).to.eql('true');
});
// Flaky until https://github.com/elastic/eui/issues/2612 fixed
it.skip('should unmute single alert', async () => {
it('should unmute single alert', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const muteSwitch = await testSubjects.find('muteSwitch');
await muteSwitch.click();
await pageObjects.triggersActionsUI.toggleSwitch('muteSwitch');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActionsAfterMute = await testSubjects.find('collapsedItemActions');
await collapsedItemActionsAfterMute.click();
await testSubjects.click('collapsedItemActions');
const muteSwitchAfterMute = await testSubjects.find('muteSwitch');
await muteSwitchAfterMute.click();
await pageObjects.triggersActionsUI.toggleSwitch('muteSwitch');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActionsAfterUnmute = await testSubjects.find('collapsedItemActions');
await collapsedItemActionsAfterUnmute.click();
await testSubjects.click('collapsedItemActions');
const muteSwitchAfterUnmute = await testSubjects.find('muteSwitch');
const isChecked = await muteSwitchAfterUnmute.getAttribute('aria-checked');
expect(isChecked).to.eql('false');
});
// Flaky, will be fixed with https://github.com/elastic/kibana/issues/53956
it.skip('should delete single alert', async () => {
it('should delete single alert', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const deleteBtn = await testSubjects.find('deleteAlert');
await deleteBtn.click();
await testSubjects.click('deleteAlert');
retry.try(async () => {
await retry.try(async () => {
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
@ -200,140 +176,114 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});
});
// Flaky, will be fixed with https://github.com/elastic/kibana/issues/49830
it.skip('should mute all selection', async () => {
it('should mute all selection', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const checkbox = await testSubjects.find(`checkboxSelectRow-${createdAlert.id}`);
await checkbox.click();
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
const bulkActionBtn = await testSubjects.find('bulkAction');
await bulkActionBtn.click();
await testSubjects.click('bulkAction');
const muteAllBtn = await testSubjects.find('muteAll');
await muteAllBtn.click();
await testSubjects.click('muteAll');
// Unmute all button shows after clicking mute all
await testSubjects.existOrFail('unmuteAll');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const muteSwitch = await testSubjects.find('muteSwitch');
const isChecked = await muteSwitch.getAttribute('aria-checked');
expect(isChecked).to.eql('true');
});
// Flaky, will be fixed with https://github.com/elastic/kibana/issues/49830
it.skip('should unmute all selection', async () => {
it('should unmute all selection', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const checkbox = await testSubjects.find(`checkboxSelectRow-${createdAlert.id}`);
await checkbox.click();
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
const bulkActionBtn = await testSubjects.find('bulkAction');
await bulkActionBtn.click();
await testSubjects.click('bulkAction');
const muteAllBtn = await testSubjects.find('muteAll');
await muteAllBtn.click();
await testSubjects.click('muteAll');
const unmuteAllBtn = await testSubjects.find('unmuteAll');
await unmuteAllBtn.click();
await testSubjects.click('unmuteAll');
// Mute all button shows after clicking unmute all
await testSubjects.existOrFail('muteAll');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const muteSwitch = await testSubjects.find('muteSwitch');
const isChecked = await muteSwitch.getAttribute('aria-checked');
expect(isChecked).to.eql('false');
});
// Flaky, will be fixed with https://github.com/elastic/kibana/issues/49830
it.skip('should disable all selection', async () => {
it('should disable all selection', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const checkbox = await testSubjects.find(`checkboxSelectRow-${createdAlert.id}`);
await checkbox.click();
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
const bulkActionBtn = await testSubjects.find('bulkAction');
await bulkActionBtn.click();
await testSubjects.click('bulkAction');
const disableAllBtn = await testSubjects.find('disableAll');
await disableAllBtn.click();
await testSubjects.click('disableAll');
// Enable all button shows after clicking disable all
await testSubjects.existOrFail('enableAll');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const enableSwitch = await testSubjects.find('enableSwitch');
const isChecked = await enableSwitch.getAttribute('aria-checked');
expect(isChecked).to.eql('false');
});
// Flaky, will be fixed with https://github.com/elastic/kibana/issues/49830
it.skip('should enable all selection', async () => {
it('should enable all selection', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const checkbox = await testSubjects.find(`checkboxSelectRow-${createdAlert.id}`);
await checkbox.click();
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
const bulkActionBtn = await testSubjects.find('bulkAction');
await bulkActionBtn.click();
await testSubjects.click('bulkAction');
const disableAllBtn = await testSubjects.find('disableAll');
await disableAllBtn.click();
await testSubjects.click('disableAll');
const enableAllBtn = await testSubjects.find('enableAll');
await enableAllBtn.click();
await testSubjects.click('enableAll');
// Disable all button shows after clicking enable all
await testSubjects.existOrFail('disableAll');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const collapsedItemActions = await testSubjects.find('collapsedItemActions');
await collapsedItemActions.click();
await testSubjects.click('collapsedItemActions');
const enableSwitch = await testSubjects.find('enableSwitch');
const isChecked = await enableSwitch.getAttribute('aria-checked');
expect(isChecked).to.eql('true');
});
// Flaky, will be fixed with https://github.com/elastic/kibana/issues/53956
it.skip('should delete all selection', async () => {
it('should delete all selection', async () => {
const createdAlert = await createAlert();
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const checkbox = await testSubjects.find(`checkboxSelectRow-${createdAlert.id}`);
await checkbox.click();
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
const bulkActionBtn = await testSubjects.find('bulkAction');
await bulkActionBtn.click();
await testSubjects.click('bulkAction');
const deleteAllBtn = await testSubjects.find('deleteAll');
await deleteAllBtn.click();
await testSubjects.click('deleteAll');
retry.try(async () => {
await retry.try(async () => {
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
const searchResults = await pageObjects.triggersActionsUI.getAlertsList();

View file

@ -20,8 +20,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
describe('Connectors', function() {
before(async () => {
await pageObjects.common.navigateToApp('triggersActions');
const alertsTab = await testSubjects.find('connectorsTab');
await alertsTab.click();
await testSubjects.click('connectorsTab');
});
it('should create a connector', async () => {
@ -29,18 +28,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.triggersActionsUI.clickCreateConnectorButton();
const serverLogCard = await testSubjects.find('.server-log-card');
await serverLogCard.click();
await testSubjects.click('.server-log-card');
const nameInput = await testSubjects.find('nameInput');
await nameInput.click();
await nameInput.clearValue();
await nameInput.type(connectorName);
const saveButton = await find.byCssSelector(
'[data-test-subj="saveActionButton"]:not(disabled)'
);
await saveButton.click();
await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)');
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql(`Created '${connectorName}'`);
@ -63,18 +58,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.triggersActionsUI.clickCreateConnectorButton();
const serverLogCard = await testSubjects.find('.server-log-card');
await serverLogCard.click();
await testSubjects.click('.server-log-card');
const nameInput = await testSubjects.find('nameInput');
await nameInput.click();
await nameInput.clearValue();
await nameInput.type(connectorName);
const saveButton = await find.byCssSelector(
'[data-test-subj="saveActionButton"]:not(disabled)'
);
await saveButton.click();
await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)');
await pageObjects.common.closeToast();
@ -83,20 +74,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const searchResultsBeforeEdit = await pageObjects.triggersActionsUI.getConnectorsList();
expect(searchResultsBeforeEdit.length).to.eql(1);
const editConnectorBtn = await find.byCssSelector(
'[data-test-subj="connectorsTableCell-name"] button'
);
await editConnectorBtn.click();
await find.clickByCssSelector('[data-test-subj="connectorsTableCell-name"] button');
const nameInputToUpdate = await testSubjects.find('nameInput');
await nameInputToUpdate.click();
await nameInputToUpdate.clearValue();
await nameInputToUpdate.type(updatedConnectorName);
const saveEditButton = await find.byCssSelector(
'[data-test-subj="saveActionButton"]:not(disabled)'
);
await saveEditButton.click();
await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)');
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql(`Updated '${updatedConnectorName}'`);
@ -117,18 +102,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
async function createConnector(connectorName: string) {
await pageObjects.triggersActionsUI.clickCreateConnectorButton();
const serverLogCard = await testSubjects.find('.server-log-card');
await serverLogCard.click();
await testSubjects.click('.server-log-card');
const nameInput = await testSubjects.find('nameInput');
await nameInput.click();
await nameInput.clearValue();
await nameInput.type(connectorName);
const saveButton = await find.byCssSelector(
'[data-test-subj="saveActionButton"]:not(disabled)'
);
await saveButton.click();
await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)');
await pageObjects.common.closeToast();
}
const connectorName = generateUniqueKey();
@ -141,12 +122,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const searchResultsBeforeDelete = await pageObjects.triggersActionsUI.getConnectorsList();
expect(searchResultsBeforeDelete.length).to.eql(1);
const deleteConnectorBtn = await testSubjects.find('deleteConnector');
await deleteConnectorBtn.click();
await testSubjects.click('deleteConnector');
await testSubjects.existOrFail('deleteConnectorsConfirmation');
await testSubjects.click('deleteConnectorsConfirmation > confirmModalConfirmButton');
await testSubjects.missingOrFail('deleteConnectorsConfirmation');
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql('Deleted 1 connector');
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getConnectorsList();
@ -157,18 +140,14 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
async function createConnector(connectorName: string) {
await pageObjects.triggersActionsUI.clickCreateConnectorButton();
const serverLogCard = await testSubjects.find('.server-log-card');
await serverLogCard.click();
await testSubjects.click('.server-log-card');
const nameInput = await testSubjects.find('nameInput');
await nameInput.click();
await nameInput.clearValue();
await nameInput.type(connectorName);
const saveButton = await find.byCssSelector(
'[data-test-subj="saveActionButton"]:not(disabled)'
);
await saveButton.click();
await find.clickByCssSelector('[data-test-subj="saveActionButton"]:not(disabled)');
await pageObjects.common.closeToast();
}
@ -182,17 +161,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const searchResultsBeforeDelete = await pageObjects.triggersActionsUI.getConnectorsList();
expect(searchResultsBeforeDelete.length).to.eql(1);
const deleteCheckbox = await find.byCssSelector(
'.euiTableRowCellCheckbox .euiCheckbox__input'
);
await deleteCheckbox.click();
await find.clickByCssSelector('.euiTableRowCellCheckbox .euiCheckbox__input');
const bulkDeleteBtn = await testSubjects.find('bulkDelete');
await bulkDeleteBtn.click();
await testSubjects.click('bulkDelete');
await testSubjects.existOrFail('deleteConnectorsConfirmation');
await testSubjects.click('deleteConnectorsConfirmation > confirmModalConfirmButton');
await testSubjects.missingOrFail('deleteConnectorsConfirmation');
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql('Deleted 1 connector');
await pageObjects.triggersActionsUI.searchConnectors(connectorName);
const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getConnectorsList();

View file

@ -4,12 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';
const ENTER_KEY = '\uE007';
export function TriggersActionsPageProvider({ getService }: FtrProviderContext) {
const find = getService('find');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
return {
@ -93,5 +95,15 @@ export function TriggersActionsPageProvider({ getService }: FtrProviderContext)
async changeTabs(tab: 'alertsTab' | 'connectorsTab') {
return await testSubjects.click(tab);
},
async toggleSwitch(testSubject: string) {
const switchBtn = await testSubjects.find(testSubject);
const valueBefore = await switchBtn.getAttribute('aria-checked');
await switchBtn.click();
await retry.try(async () => {
const switchBtnAfter = await testSubjects.find(testSubject);
const valueAfter = await switchBtnAfter.getAttribute('aria-checked');
expect(valueAfter).not.to.eql(valueBefore);
});
},
};
}