mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Fix some type issues in x-pack/test (#167343)
## Summary We're breaking #166813 up into smaller PRs in the interest of getting PRs through sooner for type fixes. These are the changes for `x-pack/test`. --------- Co-authored-by: Thomas Watson <watson@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
This commit is contained in:
parent
fb13b2181d
commit
f9c26208b7
17 changed files with 41 additions and 34 deletions
|
@ -26,7 +26,7 @@ export default function createWithCircuitBreakerTests({ getService }: FtrProvide
|
|||
.expect(200);
|
||||
objectRemover.add('space1', createdRule.id, 'rule', 'alerting');
|
||||
|
||||
const { body } = await supertest
|
||||
await supertest
|
||||
.post(`${getUrlPrefix('space1')}/api/alerting/rule`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send(getTestRuleData({ schedule: { interval: '10s' } }))
|
||||
|
@ -41,7 +41,7 @@ export default function createWithCircuitBreakerTests({ getService }: FtrProvide
|
|||
.expect(200);
|
||||
objectRemover.add('space1', createdRule.id, 'rule', 'alerting');
|
||||
|
||||
const { body } = await supertest
|
||||
await supertest
|
||||
.post(`${getUrlPrefix('space2')}/api/alerting/rule`)
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.send(getTestRuleData({ schedule: { interval: '10s' } }))
|
||||
|
|
|
@ -17,7 +17,6 @@ export default function createRuleSuggestionValuesTests({ getService }: FtrProvi
|
|||
describe('alerts/suggestions/values', async () => {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const supertest = getService('supertest');
|
||||
const supertestWithoutAuth = getService('supertestWithoutAuth');
|
||||
|
||||
before(async () => {
|
||||
await esArchiver.load('x-pack/test/functional/es_archives/observability/alerts');
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
IngestPutPipelineRequest,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
interface Pipeline {
|
||||
export interface Pipeline {
|
||||
name: string;
|
||||
description?: string;
|
||||
onFailureProcessors?: IngestProcessorContainer[];
|
||||
|
@ -21,7 +21,7 @@ interface Pipeline {
|
|||
metadata?: Metadata;
|
||||
}
|
||||
|
||||
interface IngestPutPipelineInternalRequest extends Omit<IngestPutPipelineRequest, 'id'> {
|
||||
export interface IngestPutPipelineInternalRequest extends Omit<IngestPutPipelineRequest, 'id'> {
|
||||
name: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@ import expect from '@kbn/expect';
|
|||
import {
|
||||
AuthStackByField,
|
||||
Direction,
|
||||
UserAuthenticationsRequestOptions,
|
||||
UserAuthenticationsStrategyResponse,
|
||||
UsersQueries,
|
||||
} from '@kbn/security-solution-plugin/common/search_strategy';
|
||||
import type { UserAuthenticationsRequestOptions } from '@kbn/security-solution-plugin/common/api/search_strategy';
|
||||
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ interface BetterTestOptions {
|
|||
body?: any;
|
||||
}
|
||||
|
||||
interface BetterTestResponse<T> {
|
||||
export interface BetterTestResponse<T> {
|
||||
status: number;
|
||||
body: T;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ export class BetterTestError extends Error {
|
|||
const req = res.req as any;
|
||||
super(
|
||||
`Unhandled BetterTestError:
|
||||
Status: "${res.status}"
|
||||
Status: "${res.status}"
|
||||
Path: "${req.method} ${req.path}"
|
||||
Body: ${JSON.stringify(res.body)}`
|
||||
);
|
||||
|
|
|
@ -153,7 +153,7 @@ export function RegistryProvider({ getService }: FtrProviderContext) {
|
|||
await supertest
|
||||
.get('/api/ml/saved_objects/sync')
|
||||
.set('kbn-xsrf', 'foo')
|
||||
.auth(ApmUsername.editorUser, kbnTestConfig.getUrlParts().password);
|
||||
.auth(ApmUsername.editorUser, kbnTestConfig.getUrlParts().password!);
|
||||
}
|
||||
if (condition.archives.length) {
|
||||
log('Loaded all archives');
|
||||
|
|
|
@ -61,7 +61,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
expect(status).to.be(200);
|
||||
expect(body.validIndices.length).to.be.greaterThan(0);
|
||||
expect(body.validIndices?.length).to.be.greaterThan(0);
|
||||
expect(body.invalidIndices).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
expect(status).to.be(200);
|
||||
expect(body.validIndices.length).to.be.greaterThan(0);
|
||||
expect(body.validIndices?.length).to.be.greaterThan(0);
|
||||
expect(body.invalidIndices).to.eql([
|
||||
{
|
||||
isValid: false,
|
||||
|
@ -158,10 +158,10 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
expect(status).to.be(200);
|
||||
expect(body.validIndices.length).to.be.greaterThan(0);
|
||||
expect(body.invalidIndices.length).to.be(1);
|
||||
expect(body.validIndices?.length).to.be.greaterThan(0);
|
||||
expect(body.invalidIndices?.length).to.be(1);
|
||||
|
||||
expect(omit(body.invalidIndices[0], 'index')).to.eql({
|
||||
expect(omit(body.invalidIndices?.[0], 'index')).to.eql({
|
||||
isValid: false,
|
||||
fieldMappings: { isValid: true },
|
||||
ingestPipeline: { isValid: false },
|
||||
|
@ -187,9 +187,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
expect(status).to.be(200);
|
||||
expect(body.validIndices.length).to.be.greaterThan(0);
|
||||
expect(body.invalidIndices.length).to.be(1);
|
||||
expect(omit(body.invalidIndices[0], 'index')).to.eql({
|
||||
expect(body.validIndices?.length).to.be.greaterThan(0);
|
||||
expect(body.invalidIndices?.length).to.be(1);
|
||||
expect(omit(body.invalidIndices?.[0], 'index')).to.eql({
|
||||
isValid: false,
|
||||
fieldMappings: { isValid: true },
|
||||
ingestPipeline: { isValid: false, id: 'logs-default-pipeline' },
|
||||
|
|
|
@ -22,6 +22,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
// We intentionally make some fields start with a capital letter to test that the query bar is case-insensitive/case-sensitive
|
||||
const data = [
|
||||
{
|
||||
'@timestamp': '1695819664234',
|
||||
resource: { id: chance.guid(), name: `kubelet`, sub_type: 'lower case sub type' },
|
||||
result: { evaluation: chance.integer() % 2 === 0 ? 'passed' : 'failed' },
|
||||
rule: {
|
||||
|
@ -38,6 +39,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
cluster_id: 'Upper case cluster id',
|
||||
},
|
||||
{
|
||||
'@timestamp': '1695819673242',
|
||||
resource: { id: chance.guid(), name: `Pod`, sub_type: 'Upper case sub type' },
|
||||
result: { evaluation: chance.integer() % 2 === 0 ? 'passed' : 'failed' },
|
||||
rule: {
|
||||
|
@ -54,6 +56,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
cluster_id: 'Another Upper case cluster id',
|
||||
},
|
||||
{
|
||||
'@timestamp': '1695819676242',
|
||||
resource: { id: chance.guid(), name: `process`, sub_type: 'another lower case type' },
|
||||
result: { evaluation: 'passed' },
|
||||
rule: {
|
||||
|
@ -70,6 +73,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
cluster_id: 'lower case cluster id',
|
||||
},
|
||||
{
|
||||
'@timestamp': '1695819680202',
|
||||
resource: { id: chance.guid(), name: `process`, sub_type: 'Upper case type again' },
|
||||
result: { evaluation: 'failed' },
|
||||
rule: {
|
||||
|
|
|
@ -152,7 +152,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const ips = signalsOpen.hits.hits.map((hit) => hit._source?.ip).sort();
|
||||
expect(ips.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(ips.flat(10)).to.eql([]);
|
||||
});
|
||||
|
||||
it('should filter a CIDR range of "127.0.0.1/30"', async () => {
|
||||
|
@ -347,7 +347,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const ips = signalsOpen.hits.hits.map((hit) => hit._source?.ip).sort();
|
||||
expect(ips.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(ips.flat(10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -409,7 +409,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const ips = signalsOpen.hits.hits.map((hit) => hit._source?.ip).sort();
|
||||
expect(ips.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(ips.flat(10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -514,7 +514,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const ips = signalsOpen.hits.hits.map((hit) => hit._source?.ip).sort();
|
||||
expect(ips.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(ips.flat(10)).to.eql([]);
|
||||
});
|
||||
|
||||
it('will return 2 results if we have a list which contains the CIDR ranges of "127.0.0.1/32, 127.0.0.2/31, 127.0.0.4/30"', async () => {
|
||||
|
|
|
@ -152,7 +152,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const hits = signalsOpen.hits.hits.map((hit) => hit._source?.text).sort();
|
||||
expect(hits.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(hits.flat(10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -280,7 +280,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const hits = signalsOpen.hits.hits.map((hit) => hit._source?.text).sort();
|
||||
expect(hits.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(hits.flat(10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -342,7 +342,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const hits = signalsOpen.hits.hits.map((hit) => hit._source?.text).sort();
|
||||
expect(hits.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(hits.flat(10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -522,7 +522,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await waitForSignalsToBePresent(supertest, log, 1, [id]);
|
||||
const signalsOpen = await getSignalsById(supertest, log, id);
|
||||
const hits = signalsOpen.hits.hits.map((hit) => hit._source?.text).sort();
|
||||
expect(hits.flat(Number.MAX_SAFE_INTEGER)).to.eql([]);
|
||||
expect(hits.flat(10)).to.eql([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import type { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const PageObjects = getPageObjects(['maps']);
|
||||
|
|
|
@ -357,7 +357,7 @@ export default function (providerContext: FtrProviderContext) {
|
|||
'https://some.source.proxy:3232'
|
||||
);
|
||||
|
||||
const res = await supertest
|
||||
await supertest
|
||||
.put(`/api/fleet/agent_download_sources/${downloadSourceId}`)
|
||||
.set('kbn-xsrf', 'xxxx')
|
||||
.send({
|
||||
|
|
|
@ -126,7 +126,11 @@ export default function (providerContext: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
async function waitForAgents(expectedAgentCount: number, attempts: number, _attemptsMade = 0) {
|
||||
async function waitForAgents(
|
||||
expectedAgentCount: number,
|
||||
attempts: number,
|
||||
_attemptsMade = 0
|
||||
): Promise<any> {
|
||||
const { body: apiResponse } = await supertest
|
||||
.get(`/api/fleet/agents?showInactive=true`)
|
||||
.set('kbn-xsrf', 'xxxx')
|
||||
|
|
|
@ -13,7 +13,7 @@ const ACTION_TEST_SUBJ = `embeddablePanelAction-${ACTION_ID}`;
|
|||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const drilldowns = getService('dashboardDrilldownsManage');
|
||||
const { dashboard, discover, common, timePicker } = getPageObjects([
|
||||
const { dashboard, discover, timePicker } = getPageObjects([
|
||||
'dashboard',
|
||||
'discover',
|
||||
'common',
|
||||
|
@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
describe('Explore underlying data - chart action', () => {
|
||||
describe('value click action', () => {
|
||||
it('action exists in chart click popup menu', async () => {
|
||||
await PageObjects.dashboard.navigateToApp();
|
||||
await dashboard.navigateToApp();
|
||||
await dashboard.preserveCrossAppState();
|
||||
await dashboard.loadSavedDashboard(drilldowns.DASHBOARD_WITH_PIE_CHART_NAME);
|
||||
await pieChart.clickOnPieSlice('160,000');
|
||||
|
@ -60,7 +60,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
let originalTimeRangeDurationHours: number | undefined;
|
||||
|
||||
it('action exists in chart brush popup menu', async () => {
|
||||
await PageObjects.dashboard.navigateToApp();
|
||||
await dashboard.navigateToApp();
|
||||
await dashboard.preserveCrossAppState();
|
||||
await dashboard.loadSavedDashboard(drilldowns.DASHBOARD_WITH_AREA_CHART_NAME);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { TRANSFORM_STATE } from '@kbn/transform-plugin/common/constants';
|
||||
import type { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
|
||||
|
||||
import type { FtrProviderContext } from '../../../../ftr_provider_context';
|
||||
import {
|
||||
|
|
|
@ -239,7 +239,6 @@ class TagAssignmentFlyout extends FtrService {
|
|||
*/
|
||||
export class TagManagementPageObject extends FtrService {
|
||||
private readonly testSubjects = this.ctx.getService('testSubjects');
|
||||
private readonly find = this.ctx.getService('find');
|
||||
private readonly browser = this.ctx.getService('browser');
|
||||
private readonly retry = this.ctx.getService('retry');
|
||||
private readonly header = this.ctx.getPageObject('header');
|
||||
|
|
|
@ -1504,9 +1504,8 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
|
|||
|
||||
async deleteIngestPipeline(modelId: string, usePrefix: boolean = true) {
|
||||
log.debug(`Deleting ingest pipeline for trained model with id "${modelId}"`);
|
||||
const { body, status } = await esSupertest.delete(
|
||||
`/_ingest/pipeline/${usePrefix ? 'pipeline_' : ''}${modelId}`
|
||||
);
|
||||
// const { body, status } =
|
||||
await esSupertest.delete(`/_ingest/pipeline/${usePrefix ? 'pipeline_' : ''}${modelId}`);
|
||||
// @todo
|
||||
// this.assertResponseStatusCode(200, status, body);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue