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

[8.17] [Obs AI Assistant] fix flaky test and add back test in settings (#213196) #213320

Merged
merged 1 commit into from
Mar 6, 2025
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 @@ -67,6 +67,8 @@ const pages = {
'management-settings-editField-observability:aiAssistantSearchConnectorIndexPattern',
saveButton: 'observabilityAiAssistantManagementBottomBarActionsButton',
aiAssistantCard: 'aiAssistantSelectionPageObservabilityCard',
resetToDefaultLink:
'management-settings-resetField-observability:aiAssistantSearchConnectorIndexPattern',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
import { createAndLoginUserWithCustomRole, deleteAndLogoutUser } from './helpers';
import { interceptRequest } from '../../common/intercept_request';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const browser = getService('browser');
const PageObjects = getPageObjects(['common', 'error', 'navigationalSearch', 'security']);
const ui = getService('observabilityAIAssistantUI');
const testSubjects = getService('testSubjects');
const retry = getService('retry');
const toasts = getService('toasts');
const driver = getService('__webdriver__');

// Failing: See https://github.com/elastic/kibana/issues/191707
describe.skip('ai assistant management privileges', () => {
describe('ai assistant management privileges', () => {
describe('all privileges', () => {
before(async () => {
await createAndLoginUserWithCustomRole(getPageObjects, getService, {
Expand Down Expand Up @@ -59,22 +61,68 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await testSubjects.existOrFail(ui.pages.settings.settingsPage);
});
it('allows updating of an advanced setting', async () => {
const testSearchConnectorIndexPattern = 'my-logs-index-pattern';
await PageObjects.common.navigateToUrl('obsAIAssistantManagement', '', {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
shouldUseHashForSubUrl: false,
});
const testSearchConnectorIndexPattern = 'my-search-index-pattern';
const searchConnectorIndexPatternInput = await testSubjects.find(
ui.pages.settings.searchConnectorIndexPatternInput
);
// make sure the input is empty (default value)
await searchConnectorIndexPatternInput.clearValue();
await searchConnectorIndexPatternInput.type(testSearchConnectorIndexPattern);
const saveButton = await testSubjects.find(ui.pages.settings.saveButton);
await saveButton.click();
await browser.refresh();
const searchConnectorIndexPatternInputValue =
await searchConnectorIndexPatternInput.getAttribute('value');
expect(searchConnectorIndexPatternInputValue).to.be(testSearchConnectorIndexPattern);
// reset the value
await searchConnectorIndexPatternInput.clearValue();
await searchConnectorIndexPatternInput.type('logs-*');
// wait for page to refrsh
await testSubjects.missingOrFail(ui.pages.settings.searchConnectorIndexPatternInput, {
timeout: 2000,
});
// wait for the new page to fully load
await testSubjects.existOrFail(ui.pages.settings.searchConnectorIndexPatternInput, {
timeout: 2000,
});
expect(await searchConnectorIndexPatternInput.getAttribute('value')).to.be(
testSearchConnectorIndexPattern
);
// reset the value back to default
const resetToDefaultLink = await testSubjects.find(ui.pages.settings.resetToDefaultLink);
await resetToDefaultLink.click();

expect(await searchConnectorIndexPatternInput.getAttribute('value')).to.be('');
await saveButton.click();
await testSubjects.missingOrFail(ui.pages.settings.searchConnectorIndexPatternInput, {
timeout: 2000,
});
// wait for the new page to fully load
await testSubjects.existOrFail(ui.pages.settings.searchConnectorIndexPatternInput, {
timeout: 2000,
});
expect(await searchConnectorIndexPatternInput.getAttribute('value')).to.be('');
});
it('displays failure toast on failed request', async () => {
const searchConnectorIndexPatternInput = await testSubjects.find(
ui.pages.settings.searchConnectorIndexPatternInput
);
await searchConnectorIndexPatternInput.clearValue();
await searchConnectorIndexPatternInput.type('test');

await interceptRequest(
driver.driver,
'*kibana\\/settings*',
(responseFactory) => {
return responseFactory.fail();
},
async () => {
await testSubjects.click(ui.pages.settings.saveButton);
}
);

await retry.waitFor('Error saving settings toast', async () => {
const count = await toasts.getCount();
return count > 0;
});
});
});
describe('with advancedSettings read privilege', () => {
Expand Down