Skip to content

Commit

Permalink
PR review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
MiriamAparicio committed Feb 14, 2022
1 parent 2bdfb05 commit 2a63a21
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,11 @@ const baseUrl = url.format({
});

const apiRequestsToIntercept = [
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/charts/latency?*',
aliasName: 'latencyRequest',
},
{
endpoint: '/internal/apm/services/opbeans-node/throughput?*',
aliasName: 'throughputRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/groups/main_statistics?*',
aliasName: 'transactionsGroupsMainStadisticsRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/charts/error_rate?*',
aliasName: 'errorRateRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/errors/groups/main_statistics?*',
Expand All @@ -52,33 +38,52 @@ const apiRequestsToIntercept = [
endpoint: '/internal/apm/services/opbeans-node/dependencies?*',
aliasName: 'dependenciesRequest',
},
];

const apiRequestsToInterceptWithComparison = [
{
endpoint:
'/internal/apm/services/opbeans-node/service_overview_instances/main_statistics?*',
aliasName: 'instancesMainStadisticsRequest',
'/internal/apm/services/opbeans-node/transactions/charts/latency?*',
aliasName: 'latencyRequest',
},
{
endpoint: '/internal/apm/services/opbeans-node/throughput?*',
aliasName: 'throughputRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/charts/error_rate?*',
aliasName: 'errorRateRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/transactions/groups/detailed_statistics?*',
aliasName: 'transactionsGroupsDetailedStadisticsRequest',
},
{
endpoint:
'/internal/apm/services/opbeans-node/service_overview_instances/main_statistics?*',
aliasName: 'instancesMainStadisticsRequest',
},

{
endpoint:
'/internal/apm/services/opbeans-node/service_overview_instances/detailed_statistics?*',
aliasName: 'instancesDetailedStadisticsRequest',
},
];

const aliasNames = apiRequestsToIntercept.map(
const aliasNamesNoComparison = apiRequestsToIntercept.map(
({ aliasName }) => `@${aliasName}`
);

describe('Service Overview', () => {
beforeEach(() => {
cy.loginAsReadOnlyUser();
cy.visit(baseUrl);
});
const aliasNamesWithComparison = apiRequestsToInterceptWithComparison.map(
({ aliasName }) => `@${aliasName}`
);

const aliasNames = [...aliasNamesNoComparison, ...aliasNamesWithComparison];

describe('Service Overview', () => {
before(async () => {
await synthtrace.index(
opbeans({
Expand All @@ -92,97 +97,121 @@ describe('Service Overview', () => {
await synthtrace.clean();
});

it('persists transaction type selected when clicking on Transactions tab', () => {
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
);
cy.get('[data-test-subj="headerFilterTransactionType"]').select('Worker');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
cy.contains('Transactions').click();
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
});
describe('renders', () => {
before(() => {
cy.loginAsReadOnlyUser();
cy.visit(baseUrl);
});
it('transaction latency chart', () => {
cy.get('[data-test-subj="latencyChart"]');
});

it('persists transaction type selected when clicking on View Transactions link', () => {
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
);
cy.get('[data-test-subj="headerFilterTransactionType"]').select('Worker');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
it('throughput chart', () => {
cy.get('[data-test-subj="throughput"]');
});

cy.contains('View transactions').click();
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
});
it('transactions group table', () => {
cy.get('[data-test-subj="transactionsGroupTable"]');
});

it('renders transaction latency chart', () => {
cy.get('[data-test-subj="latencyChart"]');
});
it('error table', () => {
cy.get('[data-test-subj="serviceOverviewErrorsTable"]');
});

it('renders throughput chart', () => {
cy.get('[data-test-subj="throughput"]');
});
it('dependencies table', () => {
cy.get('[data-test-subj="dependenciesTable"]');
});

it('renders transactions group table', () => {
cy.get('[data-test-subj="transactionsGroupTable"]');
});
it('instances latency distribution chart', () => {
cy.get('[data-test-subj="instancesLatencyDistribution"]');
});

it('renders error table', () => {
cy.get('[data-test-subj="serviceOverviewErrorsTable"]');
it('instances table', () => {
cy.get('[data-test-subj="serviceOverviewInstancesTable"]');
});
});

it('renders dependencies table', () => {
cy.get('[data-test-subj="dependenciesTable"]');
});
describe('transactions', () => {
beforeEach(() => {
cy.loginAsReadOnlyUser();
cy.visit(baseUrl);
});

it('renders instances latency distribution chart', () => {
cy.get('[data-test-subj="instancesLatencyDistribution"]');
});
it('persists transaction type selected when clicking on Transactions tab', () => {
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
);
cy.get('[data-test-subj="headerFilterTransactionType"]').select('Worker');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
cy.contains('Transactions').click();
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
});

it('persists transaction type selected when clicking on View Transactions link', () => {
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'request'
);
cy.get('[data-test-subj="headerFilterTransactionType"]').select('Worker');
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);

it('renders instances table', () => {
cy.get('[data-test-subj="serviceOverviewInstancesTable"]');
cy.contains('View transactions').click();
cy.get('[data-test-subj="headerFilterTransactionType"]').should(
'have.value',
'Worker'
);
});
});

it('hides dependency tab when RUM service', () => {
cy.intercept('GET', '/internal/apm/services/opbeans-rum/agent?*').as(
'agentRequest'
);
cy.visit(
url.format({
pathname: '/app/apm/services/opbeans-rum/overview',
query: { rangeFrom: start, rangeTo: end },
})
);
cy.contains('Overview');
cy.contains('Transactions');
cy.contains('Error');
cy.contains('Service Map');
// Waits until the agent request is finished to check the tab.
cy.wait('@agentRequest');
cy.get('.euiTabs .euiTab__content').then((elements) => {
elements.map((index, element) => {
expect(element.innerText).to.not.equal('Dependencies');
describe('when RUM service', () => {
before(() => {
cy.loginAsReadOnlyUser();
cy.visit(
url.format({
pathname: '/app/apm/services/opbeans-rum/overview',
query: { rangeFrom: start, rangeTo: end },
})
);
});

it('hides dependency tab when RUM service', () => {
cy.intercept('GET', '/internal/apm/services/opbeans-rum/agent?*').as(
'agentRequest'
);
cy.contains('Overview');
cy.contains('Transactions');
cy.contains('Error');
cy.contains('Service Map');
// Waits until the agent request is finished to check the tab.
cy.wait('@agentRequest');
cy.get('.euiTabs .euiTab__content').then((elements) => {
elements.map((index, element) => {
expect(element.innerText).to.not.equal('Dependencies');
});
});
});
});

describe('Calls APIs', () => {
beforeEach(() => {
cy.loginAsReadOnlyUser();
cy.visit(baseUrl);
apiRequestsToIntercept.map(({ endpoint, aliasName }) => {
cy.intercept('GET', endpoint).as(aliasName);
});
apiRequestsToInterceptWithComparison.map(({ endpoint, aliasName }) => {
cy.intercept('GET', endpoint).as(aliasName);
});
});

it('with the correct environment when changing the environment', () => {
Expand All @@ -197,9 +226,8 @@ describe('Service Overview', () => {
});

it('when clicking the refresh button', () => {
cy.wait(aliasNames, { requestTimeout: 10000 });
cy.contains('Refresh').click();
cy.wait(aliasNames);
cy.wait(aliasNames, { requestTimeout: 10000 });
});

it('when selecting a different time range and clicking the update button', () => {
Expand All @@ -225,7 +253,10 @@ describe('Service Overview', () => {
'have.value',
'week'
);
cy.wait(aliasNames, { requestTimeout: 10000 });
cy.expectAPIsToHaveBeenCalledWith({
apisIntercepted: aliasNamesWithComparison,
value: 'comparisonStart',
});
});
});
});
Loading

0 comments on commit 2a63a21

Please sign in to comment.