UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

106 lines 4.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LogViewerUiHelper = void 0; const test_1 = require("@playwright/test"); const UiBaseLocators_1 = require("./UiBaseLocators"); class LogViewerUiHelper extends UiBaseLocators_1.UiBaseLocators { searchBtn; searchLogsTxt; selectLogLevelBtn; saveSearchHeartIcon; searchNameTxt; saveSearchBtn; overviewBtn; sortLogByTimestampBtn; firstLogLevelTimestamp; firstLogLevelMessage; firstLogSearchResult; savedSearchesBtn; loadingSpinner; constructor(page) { super(page); this.searchBtn = page.locator('uui-tab').filter({ hasText: 'Search' }).locator('svg'); this.searchLogsTxt = page.getByPlaceholder('Search logs...'); this.selectLogLevelBtn = page.getByLabel('Select log levels'); this.saveSearchHeartIcon = page.getByLabel("Save search"); this.searchNameTxt = page.getByLabel("Search name"); this.saveSearchBtn = page.locator('uui-dialog-layout').getByLabel("Save search"); this.overviewBtn = page.getByRole('tab', { name: 'Overview' }); this.sortLogByTimestampBtn = page.getByLabel('Sort logs'); this.firstLogLevelTimestamp = page.locator('umb-log-viewer-message #timestamp').first(); this.firstLogLevelMessage = page.locator('umb-log-viewer-message #message').first(); this.firstLogSearchResult = page.getByRole('group').locator('#message').first(); this.savedSearchesBtn = page.getByLabel('Saved searches'); this.loadingSpinner = page.locator('#empty uui-loader-circle'); } async clickSearchButton() { await this.click(this.searchBtn); await this.waitForVisible(this.searchLogsTxt); } async clickOverviewButton() { await this.click(this.overviewBtn); } async enterSearchKeyword(keyword) { await this.enterText(this.searchLogsTxt, keyword); } async selectLogLevel(level) { // The force click is necessary. await this.click(this.selectLogLevelBtn, { force: true }); const logLevelLocator = this.page.locator('.log-level-menu-item').getByText(level); // Force click is needed await this.click(logLevelLocator, { force: true }); } async doesLogLevelIndicatorDisplay(level) { return await this.isVisible(this.page.locator('.log-level-button-indicator', { hasText: level })); } async doesLogLevelCountMatch(level, expectedNumber) { await this.hasCount(this.page.locator('umb-log-viewer-message').locator('umb-log-viewer-level-tag', { hasText: level }), expectedNumber); } async saveSearch(searchName) { // The force click is necessary. await this.click(this.saveSearchHeartIcon, { force: true }); await this.enterText(this.searchNameTxt, searchName); await this.click(this.saveSearchBtn); } checkSavedSearch(searchName) { return this.page.locator('#saved-searches').getByLabel(searchName, { exact: true }); } async clickSortLogByTimestampButton() { await this.click(this.sortLogByTimestampBtn); } async doesFirstLogHaveTimestamp(timestamp) { await this.containsText(this.firstLogLevelTimestamp, timestamp); } async clickPageNumber(pageNumber) { await this.click(this.page.getByLabel(`Go to page ${pageNumber}`, { exact: true })); } async doesFirstLogHaveMessage(message) { await this.containsText(this.firstLogLevelMessage, message, 10000); } async clickSavedSearchByName(name) { await this.click(this.page.locator('#saved-searches').getByLabel(name)); } async doesSearchBoxHaveValue(searchValue) { await (0, test_1.expect)(this.page.getByPlaceholder('Search logs...')).toHaveValue(searchValue); } async clickFirstLogSearchResult() { await this.click(this.firstLogSearchResult); } async doesDetailedLogHaveText(text) { await this.isVisible(this.page.locator('details[open] .property-value').getByText(text)); } async clickSavedSearchesButton() { // The force click is necessary. await this.click(this.savedSearchesBtn, { force: true }); } async removeSavedSearchByName(name) { const removedSavedSearchWithNameLocator = this.page.locator('.saved-search-item').filter({ hasText: name }).getByLabel('Delete this search'); // The force click is necessary. await this.click(removedSavedSearchWithNameLocator, { force: true }); } async waitUntilLoadingSpinnerInvisible() { await this.hasCount(this.loadingSpinner, 0); } } exports.LogViewerUiHelper = LogViewerUiHelper; //# sourceMappingURL=LogViewerUiHelper.js.map