Skip to content

Commit

Permalink
try to fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 20, 2020
1 parent 59759d7 commit 753f2c4
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function createActionTests({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
objectRemover.add(Spaces.space1.id, response.body.id, 'action');
expect(response.body).to.eql({
id: response.body.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.be.an('object');
const searchResult = await esTestIndexTool.search('action:test.index-record', reference);
expect(searchResult.hits.total.value).to.eql(1);
Expand Down Expand Up @@ -110,7 +110,7 @@ export default function({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
actionId: createdAction.id,
status: 'error',
Expand Down Expand Up @@ -180,7 +180,7 @@ export default function({ getService }: FtrProviderContext) {
},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
const searchResult = await esTestIndexTool.search('action:test.authorization', reference);
expect(searchResult.hits.total.value).to.eql(1);
const indexedRecord = searchResult.hits.hits[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function listActionTypesTests({ getService }: FtrProviderContext)
};
}

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
// Check for values explicitly in order to avoid this test failing each time plugins register
// a new action type
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
actionTypeId: DISABLED_ACTION_TYPE,
});

expect(response.statusCode).to.eql(400);
expect(response.status).to.eql(400);
expect(response.body).to.eql({
statusCode: 400,
error: 'Bad Request',
Expand All @@ -46,7 +46,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
params: {},
});

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
status: 'error',
retry: false,
Expand All @@ -59,7 +59,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
it('should handle get action request with disabled actionType appropriately', async () => {
const response = await supertest.get(`/api/action/${PREWRITTEN_ACTION_ID}`);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
actionTypeId: 'test.not-enabled',
config: {},
Expand All @@ -76,7 +76,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
name: 'an action created before test.not-enabled was disabled (updated)',
});

expect(responseUpdate.statusCode).to.eql(200);
expect(responseUpdate.status).to.eql(200);
expect(responseUpdate.body).to.eql({
actionTypeId: 'test.not-enabled',
config: {},
Expand All @@ -85,7 +85,7 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
});

const response = await supertest.get(`/api/action/${PREWRITTEN_ACTION_ID}`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
actionTypeId: 'test.not-enabled',
config: {},
Expand All @@ -100,10 +100,10 @@ export default function typeNotEnabledTests({ getService }: FtrProviderContext)
response = await supertest
.delete(`/api/action/${PREWRITTEN_ACTION_ID}`)
.set('kbn-xsrf', 'foo');
expect(response.statusCode).to.eql(204);
expect(response.status).to.eql(204);

response = await supertest.get(`/api/action/${PREWRITTEN_ACTION_ID}`);
expect(response.statusCode).to.eql(404);
expect(response.status).to.eql(404);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export default function alertTests({ getService }: FtrProviderContext) {
},
};

const { statusCode, body: createdAlert } = await supertest
const { status, body: createdAlert } = await supertest
.post(`${getUrlPrefix(Spaces.space1.id)}/api/alert`)
.set('kbn-xsrf', 'foo')
.send({
Expand Down Expand Up @@ -363,7 +363,7 @@ export default function alertTests({ getService }: FtrProviderContext) {
// will print the error body, if an error occurred
// if (statusCode !== 200) console.log(createdAlert);

expect(statusCode).to.be(200);
expect(status).to.be(200);

const alertId = createdAlert.id;
objectRemover.add(Spaces.space1.id, alertId, 'alert');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) {
})
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
objectRemover.add(Spaces.space1.id, response.body.id, 'alert');
expect(response.body).to.eql({
id: response.body.id,
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function createAlertTests({ getService }: FtrProviderContext) {
.set('kbn-xsrf', 'foo')
.send(getTestAlertData({ enabled: false }));

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
objectRemover.add(Spaces.space1.id, response.body.id, 'alert');
expect(response.body.scheduledTaskId).to.eql(undefined);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function createFindTests({ getService }: FtrProviderContext) {
)}/api/alert/_find?search=test.noop&search_fields=alertTypeId`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body.page).to.equal(1);
expect(response.body.perPage).to.be.greaterThan(0);
expect(response.body.total).to.be.greaterThan(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function createGetTests({ getService }: FtrProviderContext) {
`${getUrlPrefix(Spaces.space1.id)}/api/alert/${createdAlert.id}`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.eql({
id: createdAlert.id,
name: 'abc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont
`${getUrlPrefix(Spaces.space1.id)}/api/alert/${createdAlert.id}/state`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.key('alertInstances', 'previousStartedAt');
});

Expand Down Expand Up @@ -59,7 +59,7 @@ export default function createGetAlertStateTests({ getService }: FtrProviderCont
`${getUrlPrefix(Spaces.space1.id)}/api/alert/${createdAlert.id}/state`
);

expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
expect(response.body).to.key('alertInstances', 'alertTypeState', 'previousStartedAt');
expect(response.body.alertTypeState.runCount).to.greaterThan(1);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {
describe('list_alert_types', () => {
it('should return 200 with list of alert types', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);
const fixtureAlertType = response.body.find((alertType: any) => alertType.id === 'test.noop');
expect(fixtureAlertType).to.eql({
actionGroups: [{ id: 'default', name: 'Default' }],
Expand All @@ -32,7 +32,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {

it('should return actionVariables with both context and state', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);

const fixtureAlertType = response.body.find(
(alertType: any) => alertType.id === 'test.always-firing'
Expand All @@ -46,7 +46,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {

it('should return actionVariables with just context', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);

const fixtureAlertType = response.body.find(
(alertType: any) => alertType.id === 'test.onlyContextVariables'
Expand All @@ -60,7 +60,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) {

it('should return actionVariables with just state', async () => {
const response = await supertest.get(`${getUrlPrefix(Spaces.space1.id)}/api/alert/types`);
expect(response.statusCode).to.eql(200);
expect(response.status).to.eql(200);

const fixtureAlertType = response.body.find(
(alertType: any) => alertType.id === 'test.onlyStateVariables'
Expand Down
16 changes: 8 additions & 8 deletions x-pack/test/api_integration/apis/apm/agent_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,25 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte
});

it('can find the created config', async () => {
const { statusCode, body } = await searchConfigurations(searchParams);
expect(statusCode).to.equal(200);
const { status, body } = await searchConfigurations(searchParams);
expect(status).to.equal(200);
expect(body._source.service).to.eql({});
expect(body._source.settings).to.eql({ transaction_sample_rate: 0.55 });
});

it('can update the created config', async () => {
await updateConfiguration({ service: {}, settings: { transaction_sample_rate: 0.85 } });

const { statusCode, body } = await searchConfigurations(searchParams);
expect(statusCode).to.equal(200);
const { status, body } = await searchConfigurations(searchParams);
expect(status).to.equal(200);
expect(body._source.service).to.eql({});
expect(body._source.settings).to.eql({ transaction_sample_rate: 0.85 });
});

it('can delete the created config', async () => {
await deleteConfiguration(newConfig);
const { statusCode } = await searchConfigurations(searchParams);
expect(statusCode).to.equal(404);
const { status } = await searchConfigurations(searchParams);
expect(status).to.equal(404);
});
});

Expand Down Expand Up @@ -166,12 +166,12 @@ export default function agentConfigurationTests({ getService }: FtrProviderConte

for (const agentRequest of agentsRequests) {
it(`${agentRequest.service.name} / ${agentRequest.service.environment}`, async () => {
const { statusCode, body } = await searchConfigurations({
const { status, body } = await searchConfigurations({
service: agentRequest.service,
etag: 'abc',
});

expect(statusCode).to.equal(200);
expect(status).to.equal(200);
expect(body._source.settings).to.eql(agentRequest.expectedSettings);
});
}
Expand Down
12 changes: 6 additions & 6 deletions x-pack/test/api_integration/apis/apm/feature_controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ export default function featureControlsTests({ getService }: FtrProviderContext)

async function executeAsAdmin({ method = 'get', url, body }: Endpoint['req'], spaceId?: string) {
const basePath = spaceId ? `/s/${spaceId}` : '';

let request = supertest[method](`${basePath}${url}`);
const fullPath = `${basePath}${url}`;
let request = supertest[method](fullPath);

// json body
if (body) {
Expand All @@ -192,10 +192,10 @@ export default function featureControlsTests({ getService }: FtrProviderContext)

const response = await request.set('kbn-xsrf', 'foo');

const { statusCode, req } = response;
if (statusCode !== 200) {
throw new Error(`Endpoint: ${req.method} ${req.path}
Status code: ${statusCode}
const { status } = response;
if (status !== 200) {
throw new Error(`Endpoint: ${method} ${fullPath}
Status code: ${status}
Response: ${response.body.message}`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?rule_id=rule-1`)
.set('kbn-xsrf', 'true')
.query()
.expect(200);

const bodyToCompare = removeServerGeneratedProperties(body);
Expand All @@ -67,7 +66,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?rule_id=${bodyWithCreatedRule.rule_id}`)
.set('kbn-xsrf', 'true')
.query()
.expect(200);

const bodyToCompare = removeServerGeneratedPropertiesIncludingRuleId(body);
Expand All @@ -86,7 +84,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?id=${bodyWithCreatedRule.id}`)
.set('kbn-xsrf', 'true')
.query()
.expect(200);

const bodyToCompare = removeServerGeneratedPropertiesIncludingRuleId(body);
Expand All @@ -97,7 +94,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?id=fake_id`)
.set('kbn-xsrf', 'true')
.query()
.expect(404);

expect(body).to.eql({
Expand All @@ -110,7 +106,6 @@ export default ({ getService }: FtrProviderContext): void => {
const { body } = await supertest
.delete(`${DETECTION_ENGINE_RULES_URL}?rule_id=fake_id`)
.set('kbn-xsrf', 'true')
.query()
.expect(404);

expect(body).to.eql({
Expand Down
Loading

0 comments on commit 753f2c4

Please sign in to comment.