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
7 changes: 4 additions & 3 deletions e2e_tests/helpers/mongodb.helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MongoClient } from 'mongodb';
import { Timeouts } from './timeouts';

interface MongoConfig {
host?: string;
Expand All @@ -18,7 +19,7 @@ export default class MongoDBHelper {
this.port = config.port || 27_017;
this.url = `mongodb://${config.username}:${encodeURIComponent(config.password)}@${this.host}:${this.port}/?authSource=admin`;
this.client = new MongoClient(this.url, {
connectTimeoutMS: 30_000,
connectTimeoutMS: Timeouts.THIRTY_SECONDS,
directConnection: true,
});
}
Expand Down Expand Up @@ -56,10 +57,10 @@ export default class MongoDBHelper {
} = {},
) => {
const {
chunkMs = 5_000,
chunkMs = Timeouts.FIVE_SECONDS,
collectionName = 'test',
dbName = 'admin',
delayMs = 10_000,
delayMs = Timeouts.TEN_SECONDS,
queryLabel = 'rta-simulated-query',
} = options;
const numDocs = Math.max(1, Math.ceil(delayMs / chunkMs));
Expand Down
1 change: 1 addition & 0 deletions e2e_tests/helpers/timeouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export enum Timeouts {
HALF_SECOND = 500,
ONE_SECOND = 1_000,
TWO_SECONDS = 2_000,
THREE_SECONDS = 3_000,
FOUR_SECONDS = 4_000,
FIVE_SECONDS = 5_000,
TEN_SECONDS = 10_000,
Expand Down
5 changes: 3 additions & 2 deletions e2e_tests/pages/qan/rta/realTimeAnalytics.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import pmmTest from '@fixtures/pmmTest';
import BasePage from '@pages/base.page';
import { expect, type Request } from '@playwright/test';
import apiEndpoints from '@helpers/apiEndpoints';
import { Timeouts } from '@helpers/timeouts';

const realTimeTableTestId = 'realtime-overview-table';

Expand Down Expand Up @@ -120,10 +121,10 @@ export default class RealTimeAnalyticsPage extends BasePage {
};

stopAllSessions = async () => {
await this.buttons.stopAllSessions.waitFor({ state: 'visible', timeout: 3_000 });
await this.buttons.stopAllSessions.waitFor({ state: 'visible', timeout: Timeouts.THREE_SECONDS });
await this.buttons.stopAllSessions.click();
await this.buttons.stopAgentsButton.click();
await this.buttons.stopAgentsButton.waitFor({ state: 'hidden', timeout: 3_000 });
await this.buttons.stopAgentsButton.waitFor({ state: 'hidden', timeout: Timeouts.THREE_SECONDS });
};

verifyRequestInterval = async (
Expand Down
6 changes: 3 additions & 3 deletions e2e_tests/pages/qan/storedMetrics/storedMetrics.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export default class StoredMetricsPage extends BasePage {

verifyQanStoredMetricsHaveData = async () => {
await this.waitUntilQanStoredMetricsLoaded();
await expect(this.elements.noData).toBeHidden({ timeout: 30_000 });
await expect(this.elements.firstRow).toBeVisible({ timeout: 30_000 });
await expect(this.elements.noData).toBeHidden({ timeout: Timeouts.THIRTY_SECONDS });
await expect(this.elements.firstRow).toBeVisible({ timeout: Timeouts.THIRTY_SECONDS });
};

verifyTotalQueryCount = async (expectedQueryCount: number) => {
Expand All @@ -64,7 +64,7 @@ export default class StoredMetricsPage extends BasePage {
await this.waitUntilQanStoredMetricsLoaded();

const noDataLocator = this.elements.noData;
const timeoutInSeconds = timeout / 1_000;
const timeoutInSeconds = timeout / Timeouts.ONE_SECOND;

for (let i = 0; i < timeoutInSeconds; i++) {
// eslint-disable-next-line playwright/no-wait-for-timeout -- TODO: Replace with a better approach
Expand Down
5 changes: 4 additions & 1 deletion e2e_tests/tests/changeTheme.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pmmTest from '@fixtures/pmmTest';
import { expect } from '@playwright/test';
import { Timeouts } from '@helpers/timeouts';

pmmTest.beforeEach(async ({ grafanaHelper, page }) => {
await page.goto('');
Expand Down Expand Up @@ -48,7 +49,9 @@ pmmTest(
const buttonText = await themePage.buttons.changeThemeButton.innerText();
const expectedComboboxValue = buttonText === 'Switch to light mode' ? 'Dark' : 'Light';

await expect(themePage.getThemeCombobox()).toHaveValue(expectedComboboxValue, { timeout: 10_000 });
await expect(themePage.getThemeCombobox()).toHaveValue(expectedComboboxValue, {
timeout: Timeouts.TEN_SECONDS,
});
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/tests/qan/rta/overview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pmmTest(
});

// eslint-disable-next-line playwright/no-wait-for-timeout -- wait for the query to run for some time
await page.waitForTimeout(3_000);
await page.waitForTimeout(Timeouts.THREE_SECONDS);

mongoDbHelper.simulateLongRunningQuery({
delayMs: Timeouts.TWENTY_SECONDS,
Expand Down
5 changes: 3 additions & 2 deletions e2e_tests/tests/welcomePage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pmmTest from '@fixtures/pmmTest';
import { expect } from '@playwright/test';
import { Timeouts } from '@helpers/timeouts';

pmmTest.beforeEach(async ({ grafanaHelper, page }) => {
await page.goto('');
Expand Down Expand Up @@ -73,9 +74,9 @@ pmmTest('PMM-T2134 Verify Update check @new-navigation', async ({ helpPage, mock

/* eslint-disable playwright/no-conditional-expect -- TODO: Refactor test case to avoid conditional expect */
if (c.updateAvailable) {
await expect(helpPage.buttons.updates).toBeVisible({ timeout: 10_000 });
await expect(helpPage.buttons.updates).toBeVisible({ timeout: Timeouts.TEN_SECONDS });
} else {
await expect(helpPage.buttons.updates).toBeHidden({ timeout: 10_000 });
await expect(helpPage.buttons.updates).toBeHidden({ timeout: Timeouts.TEN_SECONDS });
}
/* eslint-enable playwright/no-conditional-expect */
});
Expand Down
Loading