newTracesExplorer.spec.ts
newTracesExplorer.spec.ts - Overview
-
Overview This file contains Playwright tests for the New Traces Explorer feature in the frontend application. It tests functionalities such as navigating to the traces explorer, displaying data, switching between views, and saving new views.
-
Detailed Documentation
test.describe('New Traces Explorer', () => { ... });
- Purpose: Defines a test suite for the New Traces Explorer feature.
- Parameters: None
- Returns: None
test.beforeEach(async ({ baseURL, browser }) => { ... });
- Purpose: Sets up the test environment before each test case. It logs in, navigates to the application page, and assigns the page object to the
page
variable. - Parameters:
baseURL
: The base URL of the application (provided by Playwright).browser
: The browser instance (provided by Playwright).
- Returns: None
loginApi(newPage)
- Purpose: Logs in using the API.
- Parameters:
newPage
: The page object (Playwright).
- Returns: None
newPage.goto(\
${baseURL}${ROUTES.APPLICATION}`)`
- Purpose: Navigates to the application route.
- Parameters:
baseURL
: The base URL of the application.ROUTES.APPLICATION
: Application route.
- Returns: None
test('Traces Explorer Tests', async ({}) => { ... });
- Purpose: Defines the main test case for the Traces Explorer.
- Parameters: None
- Returns: None
page.locator(\
li[data-menu-id*="/trace"]`).click();`
- Purpose: Clicks on the trace menu item.
- Parameters: None
- Returns: None
tracesExplorerQueryData(page, queryRangeSuccessResponse);
- Purpose: Mocks the response for query range data.
- Parameters:
page
: The page object (Playwright).queryRangeSuccessResponse
: Mocked data for query range.
- Returns: None
defaultAttributeKeysData(page);
- Purpose: Mocks the response for default attribute keys.
- Parameters:
page
: The page object (Playwright).
- Returns: None
page.locator(\
data-testid=${newExplorerCtaID}`).click();`
- Purpose: Clicks on the New Explorer CTA (Call To Action).
- Parameters: None
- Returns: None
page.getByText('List View').click();
- Purpose: Clicks on the List View option.
- Parameters: None
- Returns: None
page.locator(\
data-testid=${serviceAttributeID}`).textContent();`
- Purpose: Retrieves the text content of the element with the
serviceAttributeID
test ID. - Parameters: None
- Returns: A promise that resolves to the text content (string).
expect(serviceName).toBe('route');
- Purpose: Asserts that the service name is equal to 'route'.
- Parameters:
serviceName
: The service name to assert.
- Returns: None
tracesExplorerQueryData(page, tracesSuccessResponse);
- Purpose: Mocks the response for traces data.
- Parameters:
page
: The page object (Playwright).tracesSuccessResponse
: Mocked data for traces.
- Returns: None
page.locator(\
id=${traceTabID}`).click();`
- Purpose: Clicks on the trace tab.
- Parameters: None
- Returns: None
page.locator(\
data-testid=${traceRowTraceTabID}`).textContent();`
- Purpose: Retrieves the text content of the element with the
traceRowTraceTabID
test ID. - Parameters: None
- Returns: A promise that resolves to the text content (string).
expect(traceID).toBe(tracesSuccessResponse.data.result[0].list[0].data.traceID);
- Purpose: Asserts that the trace ID matches the expected value.
- Parameters:
traceID
: The trace ID to assert.
- Returns: None
tracesExplorerQueryData(page, tracesTableSuccessResponse);
- Purpose: Mocks the response for traces table data.
- Parameters:
page
: The page object (Playwright).tracesTableSuccessResponse
: Mocked data for traces table.
- Returns: None
page.locator(\
id=${tableViewTabID}`).click();`
- Purpose: Clicks on the table view tab.
- Parameters: None
- Returns: None
page.getByText('85784').isVisible();
- Purpose: Checks whether element containing text '85784' is visible or not.
- Parameters: None
- Returns: A promise that resolves to a boolean
page.locator(\
data-testid=${saveNewViewID}`).click();`
- Purpose: Clicks on the Save New View button.
- Parameters: None
- Returns: None
page.locator('id=viewName').type('Playwright');
- Purpose: Types 'Playwright' into the view name input field.
- Parameters: None
- Returns: None
tracesExplorerQueryData(page, queryRangeSuccessResponse);
- Purpose: Mocks the response for query range data.
- Parameters:
page
: The page object (Playwright).queryRangeSuccessResponse
: Mocked data for query range.
- Returns: None
tracesExplorerViewsData(page);
- Purpose: Mocks the response for trace explorer views data.
- Parameters:
page
: The page object (Playwright).
- Returns: None
tracesExplorerViewsPostData(page);
- Purpose: Mocks the response for trace explorer views post data.
- Parameters:
page
: The page object (Playwright).
- Returns: None
page.locator(\
data-testid=${saveNewViewWithNameID}`).click();`
- Purpose: Clicks on the Save New View With Name button.
- Parameters: None
- Returns: None
page.getByText('Playwright').isVisible();
- Purpose: Checks whether the view name 'Playwright' is visible.
- Parameters: None
- Returns: A promise that resolves to a boolean
expect(viewName).toBeTruthy();
- Purpose: Asserts that the view name is visible.
- Parameters:
viewName
: The view name element.
- Returns: None
- Code Examples Not applicable, the code is self-explanatory.
Include in Getting Started: NO