UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

115 lines 5.44 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 (0, test_1.expect)(this.searchBtn).toBeVisible(); await this.searchBtn.click(); await (0, test_1.expect)(this.searchLogsTxt).toBeVisible(); } async clickOverviewButton() { await (0, test_1.expect)(this.overviewBtn).toBeVisible(); await this.overviewBtn.click(); } async enterSearchKeyword(keyword) { await this.searchLogsTxt.clear(); await this.searchLogsTxt.fill(keyword); } async selectLogLevel(level) { await (0, test_1.expect)(this.selectLogLevelBtn).toBeVisible(); // The force click is necessary. await this.selectLogLevelBtn.click({ force: true }); const logLevelLocator = this.page.locator('.log-level-menu-item').getByText(level); await (0, test_1.expect)(logLevelLocator).toBeVisible(); await logLevelLocator.click({ force: true }); } async doesLogLevelIndicatorDisplay(level) { return await (0, test_1.expect)(this.page.locator('.log-level-button-indicator', { hasText: level })).toBeVisible(); } async doesLogLevelCountMatch(level, expectedNumber) { return await (0, test_1.expect)(this.page.locator('umb-log-viewer-message').locator('umb-log-viewer-level-tag', { hasText: level })).toHaveCount(expectedNumber); } async saveSearch(searchName) { await (0, test_1.expect)(this.saveSearchHeartIcon).toBeVisible(); // The force click is necessary. await this.saveSearchHeartIcon.click({ force: true }); await this.searchNameTxt.clear(); await this.searchNameTxt.fill(searchName); await this.saveSearchBtn.click(); } checkSavedSearch(searchName) { return this.page.locator('#saved-searches').getByLabel(searchName, { exact: true }); } async clickSortLogByTimestampButton() { await this.sortLogByTimestampBtn.click(); } async doesFirstLogHaveTimestamp(timestamp) { return await (0, test_1.expect)(this.firstLogLevelTimestamp).toContainText(timestamp); } async clickPageNumber(pageNumber) { await this.page.getByLabel('Go to page ' + pageNumber, { exact: true }).click(); } async doesFirstLogHaveMessage(message) { await (0, test_1.expect)(this.firstLogLevelMessage).toContainText(message, { timeout: 10000 }); } async clickSavedSearchByName(name) { await (0, test_1.expect)(this.page.locator('#saved-searches').getByLabel(name)).toBeVisible(); await this.page.locator('#saved-searches').getByLabel(name).click(); } async doesSearchBoxHaveValue(searchValue) { await (0, test_1.expect)(this.page.getByPlaceholder('Search logs...')).toHaveValue(searchValue); } async clickFirstLogSearchResult() { await this.firstLogSearchResult.click(); } async doesDetailedLogHaveText(text) { await (0, test_1.expect)(this.page.locator('details[open] .property-value').getByText(text)).toBeVisible(); } async clickSavedSearchesButton() { await (0, test_1.expect)(this.savedSearchesBtn).toBeVisible(); // The force click is necessary. await this.savedSearchesBtn.click({ force: true }); } async removeSavedSearchByName(name) { const removedSavedSearchWithNameLocator = this.page.locator('li').filter({ hasText: name }).getByLabel('Remove saved search'); await (0, test_1.expect)(removedSavedSearchWithNameLocator).toBeVisible(); // The force click is necessary. await removedSavedSearchWithNameLocator.click({ force: true }); } async waitUntilLoadingSpinnerInvisible() { await (0, test_1.expect)(this.loadingSpinner).toHaveCount(0); } } exports.LogViewerUiHelper = LogViewerUiHelper; //# sourceMappingURL=LogViewerUiHelper.js.map