Skip to content

Commit

Permalink
[8.17] [APM] Fix inventory plugin link (elastic#201122) (elastic#201874)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.17`:
- [[APM] Fix inventory plugin link
(elastic#201122)](elastic#201122)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cauê
Marcondes","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-26T21:53:48Z","message":"[APM]
Fix inventory plugin link (elastic#201122)\n\ncloses
https://github.com/elastic/kibana/issues/201116\r\n\r\n- Fix Inventory
locator removing `observability` from the url.\r\n- ~~Unify service
inventory E2E tests to run it faster avoiding Kibana\r\nloading page on
every test.~~\r\n- Add test to navigate to the inventory
plugin.","sha":"4bc9a59fcccbe0f58bcb58bbe42fa294dd3f041a","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services","v8.17.0"],"title":"[APM]
Fix inventory plugin
link","number":201122,"url":"https://github.com/elastic/kibana/pull/201122","mergeCommit":{"message":"[APM]
Fix inventory plugin link (elastic#201122)\n\ncloses
https://github.com/elastic/kibana/issues/201116\r\n\r\n- Fix Inventory
locator removing `observability` from the url.\r\n- ~~Unify service
inventory E2E tests to run it faster avoiding Kibana\r\nloading page on
every test.~~\r\n- Add test to navigate to the inventory
plugin.","sha":"4bc9a59fcccbe0f58bcb58bbe42fa294dd3f041a"}},"sourceBranch":"main","suggestedTargetBranches":["8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201122","number":201122,"mergeCommit":{"message":"[APM]
Fix inventory plugin link (elastic#201122)\n\ncloses
https://github.com/elastic/kibana/issues/201116\r\n\r\n- Fix Inventory
locator removing `observability` from the url.\r\n- ~~Unify service
inventory E2E tests to run it faster avoiding Kibana\r\nloading page on
every test.~~\r\n- Add test to navigate to the inventory
plugin.","sha":"4bc9a59fcccbe0f58bcb58bbe42fa294dd3f041a"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cauê Marcondes <[email protected]>
  • Loading branch information
kibanamachine and cauemarcondes authored Nov 26, 2024
1 parent e3cdc2e commit a692b88
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const serviceInventoryHref = url.format({

const mainApiRequestsToIntercept = [
{
method: 'GET',
endpoint: '/internal/apm/services?*',
aliasName: 'servicesRequest',
},
{
method: 'POST',
endpoint: '/internal/apm/services/detailed_statistics?*',
aliasName: 'detailedStatisticsRequest',
},
Expand All @@ -51,8 +53,13 @@ describe.skip('Service inventory', () => {

describe('When navigating to the service inventory', () => {
beforeEach(() => {
mainApiRequestsToIntercept.forEach(({ aliasName, endpoint, method }) =>
cy.intercept(method, endpoint).as(aliasName)
);
cy.loginAsViewerUser();
cy.visitKibana(serviceInventoryHref);
cy.visitKibana(serviceInventoryHref, {
localStorageOptions: [['apm.dismissedEntitiesInventoryCallout', 'false']],
});
});

it('has no detectable a11y violations on load', () => {
Expand Down Expand Up @@ -80,9 +87,8 @@ describe.skip('Service inventory', () => {

describe('Calls APIs', () => {
beforeEach(() => {
cy.intercept('GET', '/internal/apm/services?*').as('servicesRequest');
cy.intercept('POST', '/internal/apm/services/detailed_statistics?*').as(
'detailedStatisticsRequest'
mainApiRequestsToIntercept.forEach(({ aliasName, endpoint, method }) =>
cy.intercept(method, endpoint).as(aliasName)
);

cy.loginAsViewerUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,32 @@ Cypress.Commands.add('loginAsApmReadPrivilegesWithWriteSettingsUser', () => {
Cypress.Commands.add(
'loginAs',
({ username, password }: { username: string; password: string }) => {
// cy.session(username, () => {
const kibanaUrl = Cypress.env('KIBANA_URL');
cy.log(`Logging in as ${username} on ${kibanaUrl}`);
cy.visit('/');
cy.request({
log: true,
method: 'POST',
url: `${kibanaUrl}/internal/security/login`,
body: {
providerType: 'basic',
providerName: 'basic',
currentURL: `${kibanaUrl}/login`,
params: { username, password },
},
headers: {
'kbn-xsrf': 'e2e_test',
cy.session(
username,
() => {
const kibanaUrl = Cypress.env('KIBANA_URL');
cy.log(`Logging in as ${username} on ${kibanaUrl}`);
cy.visit('/');
cy.request({
log: true,
method: 'POST',
url: `${kibanaUrl}/internal/security/login`,
body: {
providerType: 'basic',
providerName: 'basic',
currentURL: `${kibanaUrl}/login`,
params: { username, password },
},
headers: {
'kbn-xsrf': 'e2e_test',
},
});
cy.visit('/');
},
// });
});
cy.visit('/');
{
cacheAcrossSpecs: true,
}
);
}
);

Expand All @@ -87,8 +93,14 @@ Cypress.Commands.add('changeTimeRange', (value: string) => {
cy.contains(value).click();
});

Cypress.Commands.add('visitKibana', (url: string) => {
cy.visit(url);
Cypress.Commands.add('visitKibana', (url, options) => {
cy.visit(url, {
onBeforeLoad(win) {
if (options?.localStorageOptions && options.localStorageOptions.length > 0) {
options.localStorageOptions.forEach(([key, value]) => win.localStorage.setItem(key, value));
}
},
});
cy.getByTestSubj('kbnLoadingMessage').should('exist');
cy.getByTestSubj('kbnLoadingMessage').should('not.exist', {
timeout: 50000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare namespace Cypress {
password: string;
}): Cypress.Chainable<Cypress.Response<any>>;
changeTimeRange(value: string): void;
visitKibana(url: string): void;
visitKibana(url: string, options?: { localStorageOptions?: Array<[string, string]> }): void;
selectAbsoluteTimeRange(start: string, end: string): void;
expectAPIsToHaveBeenCalledWith(params: { apisIntercepted: string[]; value: string }): void;
updateAdvancedSettings(settings: Record<string, unknown>): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function useInventoryRouter(): StatefulInventoryRouter {
navigateToApp('inventory', { path: next, replace: true });
},
link: (path, ...args) => {
return http.basePath.prepend('/app/observability/inventory' + link(path, ...args));
return http.basePath.prepend('/app/inventory' + link(path, ...args));
},
}),
[navigateToApp, http.basePath]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class EntitiesInventoryLocatorDefinition implements LocatorDefinition<Ser

public readonly getLocation = async () => {
return {
app: 'observability',
path: `/inventory`,
app: 'inventory',
path: `/`,
state: {},
};
};
Expand Down

0 comments on commit a692b88

Please sign in to comment.