Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pr.codecept.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Agent } = require('https');
const { pageObjects, getChunks } = require('./codeceptConfigHelper');
const bootstrapHook = require('./tests/helper/hooks.js');

require('dotenv').config();

Expand Down Expand Up @@ -137,7 +138,7 @@ exports.config = {
},
},
},
bootstrap: false,
bootstrap: bootstrapHook,
teardown: null,
hooks: [],
gherkin: {},
Expand Down
4 changes: 1 addition & 3 deletions tests/QAN/filters_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ Scenario(
queryAnalyticsPage.filters.selectContainFilter(serviceName);
queryAnalyticsPage.data.waitForNewItemsCount(count);
queryAnalyticsPage.filters.selectFilterInGroup(db2, section);
await within(queryAnalyticsPage.data.root, () => {
I.waitForText('No queries available for this combination of filters', 30);
});
I.waitForText('No queries available for this combination of filters', 30);
},
).retry(2);

Expand Down
6 changes: 5 additions & 1 deletion tests/QAN/timerange_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const assert = require('assert');
Feature('QAN timerange').retry(1);

Before(async ({ I, queryAnalyticsPage, codeceptjsConfig }) => {
I.restartBrowser({ permissions: ['clipboard-read', 'clipboard-write'], origin: codeceptjsConfig.config.helpers.Playwright.url });
await I.usePlaywrightTo('Grant Permissions', async ({ browserContext }) => {
await browserContext.grantPermissions(['clipboard-read', 'clipboard-write'], {
origin: codeceptjsConfig.config.helpers.Playwright.url,
});
});
await I.usePlaywrightTo('Mock BE Responses', async ({ page }) => {
await page.route('**/v1/users/me', (route) => route.fulfill({
status: 200,
Expand Down
2 changes: 1 addition & 1 deletion tests/backup/inventory_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Scenario(

const artifactName = await I.grabTextFrom(backupInventoryPage.elements.artifactName(backupName));

backupInventoryPage.openDeleteBackupModal(backupName);
await backupInventoryPage.openDeleteBackupModal(backupName);
I.seeTextEquals(backupInventoryPage.messages.confirmDeleteText(artifactName), 'h4');
I.seeTextEquals(backupInventoryPage.messages.forceDeleteLabelText, backupInventoryPage.elements.forceDeleteLabel);
I.seeTextEquals(backupInventoryPage.messages.modalHeaderText, backupInventoryPage.modal.header);
Expand Down
2 changes: 1 addition & 1 deletion tests/backup/mysql/inventory_mysql_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Scenario(

const artifactName = await I.grabTextFrom(backupInventoryPage.elements.artifactName(backupName));

backupInventoryPage.openDeleteBackupModal(backupName);
await backupInventoryPage.openDeleteBackupModal(backupName);
I.seeTextEquals(backupInventoryPage.messages.confirmDeleteText(artifactName), 'h4');
I.seeTextEquals(backupInventoryPage.messages.forceDeleteLabelText, backupInventoryPage.elements.forceDeleteLabel);
I.seeTextEquals(backupInventoryPage.messages.modalHeaderText, backupInventoryPage.elements.modalHeader);
Expand Down
9 changes: 7 additions & 2 deletions tests/backup/pages/inventoryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ module.exports = {
I.waitForVisible(this.elements.backupStatusFailureIconByName(backupName), 120);
},

openDeleteBackupModal(backupName) {
async openDeleteBackupModal(backupName) {
I.waitForVisible(this.buttons.actionsMenuByName(backupName), 10);
I.click(this.buttons.actionsMenuByName(backupName));
I.waitForVisible(this.buttons.deleteByName(backupName), 2);

if (!(await I.isElementDisplayed(this.buttons.deleteByName(backupName), 2))) {
I.click(this.buttons.actionsMenuByName(backupName));
}

I.waitForVisible(this.buttons.deleteByName(backupName), 10);
I.click(this.buttons.deleteByName(backupName));
I.waitForVisible(this.elements.forceDeleteLabel, 20);
},
Expand Down
2 changes: 1 addition & 1 deletion tests/backup/pages/scheduledPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
clearRetentionField() {
// clearField method doesn't work for this field
I.usePlaywrightTo('clear field', async ({ page }) => {
await page.fill(I.useDataQA('retention-number-input'), '');
await page.locator(I.useDataQA('retention-number-input')).fill('');
});
},

Expand Down
6 changes: 3 additions & 3 deletions tests/configuration/pages/pmmInventoryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ module.exports = {

updateServiceLabels(serviceParameters) {
I.usePlaywrightTo('clear fields', async ({ page }) => {
await page.fill(I.useDataQA('environment-text-input'), serviceParameters.environment);
await page.fill(I.useDataQA('replication_set-text-input'), serviceParameters.replicationSet);
await page.fill(I.useDataQA('cluster-text-input'), serviceParameters.cluster);
await page.locator(I.useDataQA('environment-text-input')).fill(serviceParameters.environment);
await page.locator(I.useDataQA('replication_set-text-input')).fill(serviceParameters.replicationSet);
await page.locator(I.useDataQA('cluster-text-input')).fill(serviceParameters.cluster);
});

this.saveAndConfirm();
Expand Down
1 change: 0 additions & 1 deletion tests/configuration/permissions_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ Data(ptSummaryRoleCheck).Scenario(
await I.Authorize(username, password);
I.amOnPage(homePage.url);
I.waitForVisible(homePage.fields.checksPanelSelector, 30);
I.waitForVisible(homePage.fields.pmmCustomMenu, 30);
I.waitForVisible(dashboardPage.graphsLocator('Monitored Nodes'), 30);
I.waitForVisible(dashboardPage.graphsLocator('Monitored DB Services'), 30);

Expand Down
16 changes: 7 additions & 9 deletions tests/configuration/verifyPMMSettingsPageElements_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ Scenario('PMM-T84 - Verify Section Tabs and Metrics Section Elements [critical]
I.amOnPage(pmmSettingsPage.url);
await pmmSettingsPage.waitForPmmSettingsPageLoaded();

await within(pmmSettingsPage.fields.tabContent, () => {
I.waitForElement(pmmSettingsPage.fields.metricsResolutionLabel, 30);
I.see('Metrics resolution, sec', pmmSettingsPage.fields.metricsResolutionLabel);
I.seeElement(pmmSettingsPage.fields.metricsResolutionRadio);
I.seeElement(pmmSettingsPage.fields.lowInput);
I.seeElement(pmmSettingsPage.fields.mediumInput);
I.seeElement(pmmSettingsPage.fields.highInput);
});
I.waitForElement(pmmSettingsPage.fields.metricsResolutionLabel, 30);
I.see('Metrics resolution, sec', pmmSettingsPage.fields.metricsResolutionLabel);
I.seeElement(pmmSettingsPage.fields.metricsResolutionRadio);
I.seeElement(pmmSettingsPage.fields.lowInput);
I.seeElement(pmmSettingsPage.fields.mediumInput);
I.seeElement(pmmSettingsPage.fields.highInput);
});

Scenario('PMM-T85 - Verify SSH Key Section Elements @settings @grafana-pr', async ({ I, pmmSettingsPage }) => {
Expand Down Expand Up @@ -105,7 +103,7 @@ Scenario('PMM-T1866 - Verify if public address has an port assigned and followin
I.wait(5);
// clearField and customClearField methods doesn't work for this field
I.usePlaywrightTo('clear field', async ({ page }) => {
await page.fill(I.useDataQA('retention-number-input'), '');
await page.locator(I.useDataQA('retention-number-input')).fill('');
});
I.fillField(pmmSettingsPage.fields.dataRetentionInput, '1');
I.click(pmmSettingsPage.fields.applyButton);
Expand Down
4 changes: 0 additions & 4 deletions tests/dashboards/verifyHomeDashboards_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ Data(panels).Scenario(
// Wait for tab to open
I.wait(2);
I.switchToNextTab();
// need to skip PMM tour modal window due to new tab opening
await dashboardPage.clickUpgradeModal();
await dashboardPage.clickSkipPmmTour();

I.waitForElement(dashboardPage.fields.dashboardTitle(dashboardName), 60);
I.seeInCurrentUrl(expectedDashboard.clearUrl);

Expand Down
2 changes: 1 addition & 1 deletion tests/dashboards/verifyMysqlDashboards_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Scenario.skip(
Scenario(
'PMM-T324 - Verify MySQL - MySQL User Details dashboard @nightly @dashboards',
async ({ I, dashboardPage }) => {
const serviceName = serviceList.find((service) => service.name.includes('ps_pmm'));
const serviceName = serviceList.find((service) => service.name.includes('ps_pmm')).name;
const url = I.buildUrlWithParams(dashboardPage.mysqlUserDetailsDashboard.clearUrl, { service_name: serviceName, from: 'now-5m' });

I.amOnPage(url);
Expand Down
2 changes: 1 addition & 1 deletion tests/dashboards/verifyPostgresqlDashboards_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Before(async ({ I }) => {
Scenario(
'PMM-T2050 - Verify PostgreSQL Instance Summary Dashboard @nightly @dashboards',
async ({ I, dashboardPage }) => {
const { service_name } = await inventoryAPI.getServiceDetailsByStartsWithName('pdpgsql_pmm_');
const { service_name } = await inventoryAPI.apiGetNodeInfoByServiceName(SERVICE_TYPE.POSTGRESQL, 'pdpgsql_pmm_', 'patroni');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With changes made to patroni the service chosen for checking the dashboard was being one of the patronis, and it had no data, so I changed it to exclude patroni and instead pickup the main service (I noticed the existence of another method that had this functionality so I just reused)

This change isn't related to new native, it was just a test bug that I fixed here, I can remove

const url = I.buildUrlWithParams(dashboardPage.postgresqlInstanceSummaryDashboard.url, { service_name, from: 'now-1h' });

I.amOnPage(url);
Expand Down
14 changes: 7 additions & 7 deletions tests/dockerConfiguration/verifySrvDataDirectory_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,23 +164,23 @@ Scenario(
const logs = await I.verifyCommand('docker logs pmm-server-password');

assert.ok(!logs.includes('Configuration warning: unknown environment variable "GF_SECURITY_ADMIN_PASSWORD=newpass".'));

await I.Authorize('admin', 'admin', basePmmUrl);
await I.amOnPage(basePmmUrl + homePage.url);
await I.usePlaywrightTo('Navigate to Dashboard expecting Login redirect', async ({ page }) => {
await page.goto(basePmmUrl + homePage.url);
});
await I.waitForVisible('//h1[text()="Percona Monitoring and Management"]');
await I.unAuthorize();
await I.refreshPage();
await I.waitInUrl(loginPage.url);
await I.amOnPage(basePmmUrl + loginPage.url);
await I.Authorize('admin', 'newpass', basePmmUrl);
await I.wait(1);
await I.refreshPage();
await I.amOnPage(basePmmUrl + homePage.url);
await I.waitForElement(homePage.fields.dashboardHeaderLocator, 60);
await I.verifyCommand('docker exec -t pmm-server-password change-admin-password anotherpass');
await I.unAuthorize();
await I.waitInUrl(loginPage.url);
await I.amOnPage(basePmmUrl + loginPage.url);
await I.Authorize('admin', 'anotherpass', basePmmUrl);
await I.wait(5);
await I.refreshPage();
await I.amOnPage(basePmmUrl + homePage.url);
await I.waitForElement(homePage.fields.dashboardHeaderLocator, 60);
},
);
Expand Down
3 changes: 3 additions & 0 deletions tests/encryption/encryption_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Feature('Encryption');

BeforeSuite(async ({ I }) => {
await I.verifyCommand('docker compose -f docker-compose-encryption.yml up -d');
});

Before(async ({ I }) => {
await I.Authorize();
});

Expand Down
19 changes: 11 additions & 8 deletions tests/helper/grafana_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ class Grafana extends Helper {
}

cookies.forEach((cookie) => {
const urlToParse = baseUrl || config.config.helpers.Playwright.url;
const parsedCookie = {
name: cookie.split('=')[0],
value: cookie.split('=')[1].split(';')[0],
domain: config.config.helpers.Playwright.url.replace(/[^.\d]/g, ''),
domain: new URL(urlToParse).hostname,
path: '/',
};

Expand Down Expand Up @@ -291,29 +292,31 @@ class Grafana extends Helper {

async selectGrafanaDropdownOption(dropdownName, optionText) {
const { Playwright } = this.helpers;
const context = Playwright.context || Playwright.page;
const dropdownLocator = `//label[text()="${dropdownName}"]/ancestor::*[(self::span) or (self::div and @data-testid="data-testid template variable")]//*[contains(@data-testid, "-input")]`;

await Playwright.page.locator(dropdownLocator).first().waitFor({ state: 'attached', timeout: 5000 });
await Playwright.page.locator(dropdownLocator).first().click();
await Playwright.page.waitForTimeout(500);
await context.locator(dropdownLocator).first().waitFor({ state: 'attached', timeout: 5000 });
await context.locator(dropdownLocator).first().click();
await Playwright.wait(0.5);

const optionLocator = Playwright.page.locator('div[role="option"] span');
const optionLocator = context.locator('div[role="option"] span');

for (let i = 0; i < await optionLocator.count(); i++) {
if ((await optionLocator.nth(i).textContent()) === optionText) {
await optionLocator.nth(i).click();
}
}

await Playwright.page.keyboard.press('Escape');
await context.locator('body').press('Escape');
}

async isElementDisplayed(locator, timeoutInSeconds = 60) {
const { Playwright } = this.helpers;
const elementLocator = Playwright.page.locator(locate(locator).toXPath());
const context = Playwright.context || Playwright.page;
const elementLocator = context.locator(locate(locator).toXPath());

for (let i = 0; i < timeoutInSeconds; i++) {
await Playwright.page.waitForTimeout(1000);
await Playwright.wait(1);

if (await elementLocator.first().isVisible()) {
return true;
Expand Down
Loading
Loading