@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
109 lines • 4.87 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogViewerUiHelper = void 0;
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.isVisible(this.searchLogsTxt);
}
async clickOverviewButton() {
await this.click(this.overviewBtn);
}
async enterSearchKeyword(keyword) {
await this.enterText(this.searchLogsTxt, keyword);
}
async selectLogLevel(level) {
await this.isVisible(this.selectLogLevelBtn);
// The force click is necessary.
await this.selectLogLevelBtn.click({ force: true });
const logLevelLocator = this.page.locator('.log-level-menu-item').getByText(level);
await this.isVisible(logLevelLocator);
await logLevelLocator.click({ force: true });
}
async doesLogLevelIndicatorDisplay(level) {
return await this.isVisible(this.page.locator('.log-level-button-indicator', { hasText: level }));
}
async doesLogLevelCountMatch(level, expectedNumber) {
return await this.hasCount(this.page.locator('umb-log-viewer-message').locator('umb-log-viewer-level-tag', { hasText: level }), expectedNumber);
}
async saveSearch(searchName) {
await this.isVisible(this.saveSearchHeartIcon);
// The force click is necessary.
await this.saveSearchHeartIcon.click({ force: true });
await this.enterText(this.searchNameTxt, 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 this.containsText(this.firstLogLevelTimestamp, timestamp);
}
async clickPageNumber(pageNumber) {
await this.page.getByLabel('Go to page ' + pageNumber, { exact: true }).click();
}
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 this.hasValue(this.page.getByPlaceholder('Search logs...'), searchValue);
}
async clickFirstLogSearchResult() {
await this.firstLogSearchResult.click();
}
async doesDetailedLogHaveText(text) {
await this.isVisible(this.page.locator('details[open] .property-value').getByText(text));
}
async clickSavedSearchesButton() {
await this.isVisible(this.savedSearchesBtn);
// 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 this.isVisible(removedSavedSearchWithNameLocator);
// The force click is necessary.
await removedSavedSearchWithNameLocator.click({ force: true });
}
async waitUntilLoadingSpinnerInvisible() {
await this.hasCount(this.loadingSpinner, 0);
}
}
exports.LogViewerUiHelper = LogViewerUiHelper;
//# sourceMappingURL=LogViewerUiHelper.js.map