Skip to content

[APM] Update api tests to accomodate changes in API response#16

Merged
sorenlouv merged 4 commits intoadd-apm-debug-mode-settingfrom
update-api-tests
Mar 25, 2021
Merged

[APM] Update api tests to accomodate changes in API response#16
sorenlouv merged 4 commits intoadd-apm-debug-mode-settingfrom
update-api-tests

Conversation

@sorenlouv
Copy link
Copy Markdown
Owner

@sorenlouv sorenlouv commented Mar 25, 2021

This is required by: elastic#95146.

in elastic#95146 all APM api's were updated to return objects. This PR updates the API tests accordingly.

Additionally it adds a type safe client (apmApiSupertest) which is based on the same types as the api client in APM.

cc @dgieselaar @smith @shahzad31


import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
import supertestAsPromised from 'supertest-as-promised';
import supertest from 'supertest';
Copy link
Copy Markdown
Owner Author

@sorenlouv sorenlouv Mar 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supertest-as-promised is deprecated since 2016: WhoopInc/supertest-as-promised@ab56510

fyi: @spalger perhaps the dep should be removed from kibana entirely?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's planned elastic#95267

Copy link
Copy Markdown
Owner Author

@sorenlouv sorenlouv Mar 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, what a coincidence that I notice that the day after Tyler created that issue :D Great!

@sorenlouv sorenlouv changed the title [APM] Update api tests to accomodate changes in https://github.com/elastic/kibana/pull/95146 [APM] Update api tests to accomodate changes in API response Mar 25, 2021
);
try {
await createCustomLink(customLink);
expect(true).to.be(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions with expect.to.throwException. It looks much better:

expect(async () => {
  await createCustomLink(customLink);
}).to.throwException((e) => {
  expect(e.res.status).to.be(403);
  expectSnapshot(e.res.body.message).toMatchInline(
    `"To create custom links, you must be subscribed to an Elastic Gold license or above. With it, you'll have the ability to create custom links to improve your workflow when analyzing your services."`
  );
});

Unfortunately I couldn't make it work with promises. I'll merge this PR but will look into alternative options.

Copy link
Copy Markdown

@smith smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice! Thank you.

@sorenlouv sorenlouv merged this pull request into add-apm-debug-mode-setting Mar 25, 2021
@sorenlouv sorenlouv deleted the update-api-tests branch March 25, 2021 19:41
sorenlouv pushed a commit that referenced this pull request Jun 1, 2022
* [Unified search] Create unified search plugin

* add unified_search into USES_STYLED_COMPONENTS

* fix JEST group 4

* update limits for data plugin

* fix: remove unifiedSearch plugin from x-pack/plugins/file_upload

* feat: updated .github/CODEOWNERS and set @elastic/kibana-app-services as a code owner

* apply PR comments

* [CI] Auto-commit changed files from 'node scripts/build_plugin_list_docs'

* feat: moved filter bar, apply filters folders and apply filter action from Data plugin to unified search plugin

* fix Checks

* fix Checks

* fix Linting and Default CI Group #16

* fix Checks

* fix Checks

* fix Linting (with types)

* fix show FILTER_BAR

* fix Jest Tests

* feat replece indexPatternsContranct in setIndexPatterns to DataViewsContract

* feat: removed unnecessary interface in unified search

* fix Checks

* fix Checks

* fix Jest Tests, Checks

* fix Checks

* resolve comments

Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
sorenlouv pushed a commit that referenced this pull request Oct 5, 2023
elastic#167877)

Revert of elastic#164574

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Xavier Mouligneau <xavier.mouligneau@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants