Skip to content

Commit

Permalink
feat: happy flow for services from list view to all the three details…
Browse files Browse the repository at this point in the history
… tab rendering the correct tables (#3942)

* feat: complete services flow

* feat: complete all the three tab flows

* feat: address review comments
  • Loading branch information
vikrantgupta25 authored Nov 14, 2023
1 parent f86fc03 commit 2ae75e6
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 31 deletions.
4 changes: 2 additions & 2 deletions frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function DBCall(): JSX.Element {
>
View Traces
</Button>
<Card>
<Card data-testid="database_call_rps">
<GraphContainer>
<Graph
name="database_call_rps"
Expand Down Expand Up @@ -138,7 +138,7 @@ function DBCall(): JSX.Element {
View Traces
</Button>

<Card>
<Card data-testid="database_call_avg_duration">
<GraphContainer>
<Graph
name="database_call_avg_duration"
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/container/MetricsApplication/Tabs/External.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function External(): JSX.Element {
>
View Traces
</Button>
<Card>
<Card data-testid="external_call_error_percentage">
<GraphContainer>
<Graph
headerMenuList={MENU_ITEMS}
Expand Down Expand Up @@ -180,7 +180,7 @@ function External(): JSX.Element {
View Traces
</Button>

<Card>
<Card data-testid="external_call_duration">
<GraphContainer>
<Graph
name="external_call_duration"
Expand Down Expand Up @@ -216,7 +216,7 @@ function External(): JSX.Element {
>
View Traces
</Button>
<Card>
<Card data-testid="external_call_rps_by_address">
<GraphContainer>
<Graph
name="external_call_rps_by_address"
Expand Down Expand Up @@ -251,7 +251,7 @@ function External(): JSX.Element {
View Traces
</Button>

<Card>
<Card data-testid="external_call_duration_by_address">
<GraphContainer>
<Graph
name="external_call_duration_by_address"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function ApDexApplication({
}

return (
<Card>
<Card data-testid="apdex">
<GraphContainer>
<ApDexMetricsApplication
handleGraphClick={handleGraphClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function ServiceOverview({
>
View Traces
</Button>
<Card>
<Card data-testid="service_latency">
<GraphContainer>
<Graph
name="service_latency"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function TopLevelOperation({
topLevelOperationsIsLoading,
}: TopLevelOperationProps): JSX.Element {
return (
<Card>
<Card data-testid={name}>
{topLevelOperationsIsError ? (
<Typography>
{axios.isAxiosError(topLevelOperationsError)
Expand Down
112 changes: 90 additions & 22 deletions frontend/tests/service/servicesLanding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import ROUTES from 'constants/routes';

import servicesSuccessResponse from '../fixtures/api/services/200.json';
import { loginApi } from '../fixtures/common';
import { SERVICE_TABLE_HEADERS } from './utils';

let page: Page;

test.describe('Service Page', () => {
test.describe('Service flow', () => {
test.beforeEach(async ({ baseURL, browser }) => {
const context = await browser.newContext({ storageState: 'tests/auth.json' });
const newPage = await context.newPage();
Expand All @@ -18,7 +19,7 @@ test.describe('Service Page', () => {
page = newPage;
});

test('Services Empty Page', async ({ baseURL }) => {
test('Services empty page', async ({ baseURL }) => {
// visit services page
await page.goto(`${baseURL}${ROUTES.APPLICATION}`);

Expand All @@ -33,13 +34,16 @@ test.describe('Service Page', () => {
await expect(page.getByText('No data')).toBeVisible();
});

test('Services Table Rendered with correct data', async ({ baseURL }) => {
test('Services table and service details page rendered with correct data', async ({
baseURL,
}) => {
// visit services page
await page.goto(`${baseURL}${ROUTES.APPLICATION}`);

// assert the URL of the services page
await expect(page).toHaveURL(`${baseURL}${ROUTES.APPLICATION}`);

// mock the services list call to return non-empty data
await page.route(`**/services`, (route) =>
route.fulfill({
status: 200,
Expand All @@ -55,28 +59,92 @@ test.describe('Service Page', () => {
await expect(breadcrumbServicesText).toEqual('Services');

// expect the services headers to be loaded correctly
const p99Latency = await page
.locator(
`th[aria-label*="this column's title is P99 latency (in ms)"] .ant-table-column-title`,
)
.textContent();
const p99Latency = page.locator(
`th:has-text("${SERVICE_TABLE_HEADERS.P99LATENCY}")`,
);

await expect(p99Latency).toEqual('P99 latency (in ms)');
const errorRate = await page
.locator(
`th[aria-label*="this column's title is Error Rate (% of total)"] .ant-table-column-title`,
)
.textContent();
await expect(p99Latency).toBeVisible();
const errorRate = await page.locator(
`th:has-text("${SERVICE_TABLE_HEADERS.ERROR_RATE}")`,
);

await expect(errorRate).toEqual('Error Rate (% of total)');
const operationsPerSecond = await page
.locator(
`th[aria-label="this column's title is Operations Per Second,this column is sortable"] .ant-table-column-title`,
)
.textContent();
await expect(errorRate).toBeVisible();
const operationsPerSecond = await page.locator(
`th:has-text("${SERVICE_TABLE_HEADERS.OPS_PER_SECOND}")`,
);

await expect(operationsPerSecond).toBeVisible();

await expect(operationsPerSecond).toEqual('Operations Per Second');
// expect services to be listed in the table
await page.locator('a[href="/services/redis"]').isVisible();
const redisService = await page
.locator('a[href="/services/redis"]')
.isVisible();

expect(redisService).toBeTruthy();

// route to a service details page
await page.locator('a[href="/services/redis"]').click();

// wait for the network calls to be settled
await page.waitForLoadState('networkidle');

// render the overview tab
await page.getByRole('tab', { name: 'Overview' }).click();

// check the presence of different graphs on the overview tab
const latencyGraph = await page
.locator('[data-testid="service_latency"]')
.isVisible();

expect(latencyGraph).toBeTruthy();

const rateOps = await page
.locator('[data-testid="operations_per_sec"]')
.isVisible();

expect(rateOps).toBeTruthy();

const errorPercentage = await page
.locator('[data-testid="error_percentage_%"]')
.isVisible();

expect(errorPercentage).toBeTruthy();

// navigate to the DB call metrics and validate the tables
await page.getByRole('tab', { name: 'DB Call Metrics' }).click();

const databaseCallRps = await page
.locator('[data-testid="database_call_rps"]')
.isVisible();
expect(databaseCallRps).toBeTruthy();

const databaseCallsAvgDuration = await page
.locator('[data-testid="database_call_avg_duration"]')
.isVisible();
expect(databaseCallsAvgDuration).toBeTruthy();

// navigate to external metrics and validate the tables

await page.getByRole('tab', { name: 'External Metrics' }).click();

const externalCallErrorPerc = await page
.locator('[data-testid="external_call_error_percentage"]')
.isVisible();
expect(externalCallErrorPerc).toBeTruthy();

const externalCallDuration = await page
.locator('[data-testid="external_call_duration"]')
.isVisible();
expect(externalCallDuration).toBeTruthy();

const externalCallRps = await page
.locator('[data-testid="external_call_rps_by_address"]')
.isVisible();
expect(externalCallRps).toBeTruthy();

const externalCallDurationByAddress = await page
.locator('[data-testid="external_call_duration_by_address"]')
.isVisible();
expect(externalCallDurationByAddress).toBeTruthy();
});
});
6 changes: 6 additions & 0 deletions frontend/tests/service/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const SERVICE_TABLE_HEADERS = {
APPLICATION: 'Applicaton',
P99LATENCY: 'P99 latency (in ms)',
ERROR_RATE: 'Error Rate (% of total)',
OPS_PER_SECOND: 'Operations Per Second',
};

0 comments on commit 2ae75e6

Please sign in to comment.