mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Obs AI Assistant] Update test to intercept API request to fix flakiness (#215172)
This commit is contained in:
parent
64743b3a82
commit
bfe2db38e3
2 changed files with 25 additions and 7 deletions
|
@ -9,6 +9,7 @@ import { WebDriver } from 'selenium-webdriver';
|
|||
|
||||
interface ResponseFactory {
|
||||
fail: (reason?: string) => ['Fetch.failRequest', { requestId: string }];
|
||||
continue: () => ['Fetch.continueRequest', { requestId: string }];
|
||||
}
|
||||
|
||||
export async function interceptRequest(
|
||||
|
@ -31,6 +32,7 @@ export async function interceptRequest(
|
|||
'Fetch.failRequest',
|
||||
{ requestId: parsed.params.requestId, errorReason: 'Failed' },
|
||||
],
|
||||
continue: () => ['Fetch.continueRequest', { requestId: parsed.params.requestId }],
|
||||
}),
|
||||
innerResolve
|
||||
)
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import { createConnector, deleteConnectors } from '../../common/connectors';
|
||||
import { deleteConversations } from '../../common/conversations';
|
||||
import { interceptRequest } from '../../common/intercept_request';
|
||||
|
||||
export default function ApiTest({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const observabilityAIAssistantAPIClient = getService('observabilityAIAssistantAPIClient');
|
||||
|
@ -21,6 +22,7 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte
|
|||
const supertest = getService('supertest');
|
||||
const log = getService('log');
|
||||
const retry = getService('retry');
|
||||
const driver = getService('__webdriver__');
|
||||
|
||||
const { header } = getPageObjects(['header', 'security']);
|
||||
const PageObjects = getPageObjects(['common', 'error', 'navigationalSearch', 'security']);
|
||||
|
@ -77,9 +79,16 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte
|
|||
|
||||
describe('when changing access to Shared', () => {
|
||||
before(async () => {
|
||||
await testSubjects.click(ui.pages.conversations.access.sharedOption);
|
||||
await testSubjects.existOrFail(ui.pages.conversations.access.loadingBadge);
|
||||
await testSubjects.missingOrFail(ui.pages.conversations.access.loadingBadge);
|
||||
await interceptRequest(
|
||||
driver.driver,
|
||||
'*observability_ai_assistant\\/conversation\\/*',
|
||||
(responseFactory) => {
|
||||
return responseFactory.continue();
|
||||
},
|
||||
async () => {
|
||||
await testSubjects.click(ui.pages.conversations.access.sharedOption);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should update the badge to "Shared"', async () => {
|
||||
|
@ -104,10 +113,17 @@ export default function ApiTest({ getService, getPageObjects }: FtrProviderConte
|
|||
|
||||
describe('when changing access to Private', () => {
|
||||
before(async () => {
|
||||
await testSubjects.click(ui.pages.conversations.access.shareButton);
|
||||
await testSubjects.click(ui.pages.conversations.access.privateOption);
|
||||
await testSubjects.existOrFail(ui.pages.conversations.access.loadingBadge);
|
||||
await testSubjects.missingOrFail(ui.pages.conversations.access.loadingBadge);
|
||||
await interceptRequest(
|
||||
driver.driver,
|
||||
'*observability_ai_assistant\\/conversation\\/*',
|
||||
(responseFactory) => {
|
||||
return responseFactory.continue();
|
||||
},
|
||||
async () => {
|
||||
await testSubjects.click(ui.pages.conversations.access.shareButton);
|
||||
await testSubjects.click(ui.pages.conversations.access.privateOption);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('should update the badge to "Private"', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue