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
4 changes: 2 additions & 2 deletions e2etests/pages/base-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ export abstract class BasePage {
* @returns {Promise<void>} A promise that resolves when the filter is applied.
*/
async selectFilterByText(filter: string, filterOption: string): Promise<void> {
const filterLocator = this.filtersBox.getByRole('button', { name: new RegExp(`^${filter}`) });
const filterLocator = this.filtersBox.getByRole('button', { name: new RegExp(`^${filter}`) }).first();
await this.selectFilter(filterLocator, filterOption);
}

Expand Down Expand Up @@ -995,7 +995,7 @@ export abstract class BasePage {
if (!(await filter.isVisible())) await this.showMoreFiltersBtn.click();
await filter.click();

await this.filterPopover.getByLabel(filterOption).click();
await this.filterPopover.getByLabel(filterOption).first().click();
await this.filterApplyButton.click();
}
}
Expand Down
1 change: 0 additions & 1 deletion e2etests/pages/resources-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export class ResourcesPage extends BasePage {
await this.waitForCanvas();
await this.resetFilters();
await this.waitForPageLoad();
await this.firstResourceItemInTable.waitFor({ timeout: 15000 });
}

/**
Expand Down
2 changes: 1 addition & 1 deletion e2etests/setup/global-teardown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ async function globalTeardown() {
if (subPoolIds.length > 1) {
const marketplaceDevId = await getDatasourceIdByNameViaOpsAPI(restAPIRequest, dataSourceName);
debugLog('Orphaned Sub-pools found for Marketplace (Dev), proceeding to disconnect data source, delete sub-pools and reconnect data source to clean them up');
await disconnectDataSource(restAPIRequest, token, marketplaceDevId);
await deleteSubPoolsByName(restAPIRequest, token, dataSourceName);
await disconnectDataSource(restAPIRequest, token, marketplaceDevId);
await connectDataSource(restAPIRequest, token, dataSourceName);
}

Expand Down
5 changes: 3 additions & 2 deletions e2etests/tests/cloud-accounts-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { getCurrentUTCTimestamp, getTimestampWithVariance } from '../utils/date-range-utils';

test.describe('Cloud Accounts Tests', { tag: ['@ui', '@cloud-accounts'] }, () => {
test.fixme(process.env.CI === '1', 'Tests are unstable in CI environment due to external dependencies and may cause data corruption. Run locally for now.');
test.fixme();
test.describe.configure({ mode: 'serial' });
test.use({ restoreSession: true });

Expand Down Expand Up @@ -177,6 +177,7 @@ test.describe('Cloud Accounts Tests', { tag: ['@ui', '@cloud-accounts'] }, () =>
});

test.describe('Mocked Cloud Accounts Tests', { tag: ['@ui', '@cloud-accounts'] }, () => {
test.fixme(); //'Skipping due to these tests possibly corrupting data due to orphaned sub-pools when disconnecting accounts'
test.describe.configure({ mode: 'serial' });

const apiInterceptions: InterceptionEntry[] = [
Expand Down Expand Up @@ -259,7 +260,7 @@ test.describe(
{ tag: ['@ui', '@cloud-accounts', '@events'] },
() => {
test.describe.configure({ mode: 'serial' });
test.fixme(process.env.CI === '1', 'Tests are unstable in CI environment due to external dependencies and may cause data corruption. Run locally for now.');
test.fixme(); //'Skipping due to these tests possibly corrupting data due to orphaned sub-pools when disconnecting accounts'
test.use({ restoreSession: true });

test('[232954] Verify that disconnecting and creating a cloud account is recorded in the events log', async ({
Expand Down
6 changes: 4 additions & 2 deletions e2etests/tests/expenses-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ test.describe('[MPT-12859] Expenses Page Pool Breakdown Tests', { tag: ['@ui', '
await test.step('Load expenses data', async () => {
const [expensesResponse] = await Promise.all([
expensesPage.page.waitForResponse(
resp => resp.url().includes('/pools_expenses/') && resp.url().includes('filter_by=pool') && resp.request().method() === 'GET'
resp => resp.url().includes('/pools_expenses/') && resp.url().includes('filter_by=pool') && resp.request().method() === 'GET',
{ timeout: 20000 }
),
expensesPage.page.reload(),
]);
Expand Down Expand Up @@ -463,7 +464,8 @@ test.describe('[MPT-12859] Expenses Page Owner Breakdown Tests', { tag: ['@ui',
await test.step('Load expenses data', async () => {
const [expensesResponse] = await Promise.all([
expensesPage.page.waitForResponse(
resp => resp.url().includes('/pools_expenses/') && resp.url().includes('filter_by=employee') && resp.request().method() === 'GET'
resp => resp.url().includes('/pools_expenses/') && resp.url().includes('filter_by=employee') && resp.request().method() === 'GET',
{ timeout: 20000 }
),
expensesPage.page.reload(),
]);
Expand Down
2 changes: 1 addition & 1 deletion e2etests/tests/perspective-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test.describe('[MPT-18579] Perspective Tests', { tag: ['@ui', '@resources', '@pe
await resourcesPage.navigateToResourcesPageAndResetFilters();

const filter = 'Region';
const filterOption = 'West Europe';
const filterOption = 'East US';
const categorizeBy = 'Resource type';
const groupByTag = 'costcenter';
const perspectiveName = `Test Perspective ${new Date().getTime()}`;
Expand Down
21 changes: 12 additions & 9 deletions e2etests/utils/api-requests/interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ export async function interceptRESTRequest<T>(page: Page, pattern: RegExp, mock:
}

/**
* Intercepts GraphQL requests matching the provided operation name
* Intercepts GraphQL requests matching the provided operation name.
* Matches on the request URL (e.g. `api?op=<operationName>`) so that each
* operation gets its own route handler, replacing the previous single `/api`
* endpoint that was shared by all operations.
*/
async function interceptGraphQLRequest(
page: Page,
urlPattern: RegExp,
operationName: string,
mock: any,
onIntercepted: () => void,
variableMatch?: Record<string, any>
) {
await page.route(urlPattern, async route => {
const requestUrl = new RegExp(`[?&]op=${operationName}(?:&|$)`);

await page.route(requestUrl, async route => {
const postData = route.request().postData();
if (!postData) return route.fallback();

Expand All @@ -50,12 +54,12 @@ async function interceptGraphQLRequest(
debugLog(`\n=== GraphQL Request Interceptor ===`);
debugLog(`Expected operation: ${operationName}`);
debugLog(`Actual operation: ${body.operationName}`);
debugLog(`Expected variableMatch: ${variableMatch}`);
debugLog(`Expected variableMatch: ${JSON.stringify(variableMatch)}`);
debugLog(`Actual variables: ${JSON.stringify(body.variables, null, 2)}`);

// Only proceed if operation name matches
if (body.operationName !== operationName) {
//debugLog(`❌ Operation name mismatch - continuing to next interceptor`);
debugLog(`❌ Operation name mismatch - continuing to next interceptor`);
return route.fallback();
}

Expand All @@ -70,7 +74,6 @@ async function interceptGraphQLRequest(
});

if (!allVariablesMatch) {
debugLog(`❌ Variable match failed - continuing to next interceptor`);
return route.fallback();
}
debugLog(`✅ Variable match succeeded`);
Expand Down Expand Up @@ -112,13 +115,13 @@ export async function apiInterceptors(page: Page, config: InterceptionEntry[], f
debugLog(`\n=== Registering Interceptor ${index + 1} ===`);
debugLog(`ID: ${interceptorId}`);
debugLog(`GraphQL Operation: ${gql || 'N/A'}`);
debugLog(`Variable Match: ${variableMatch || 'None'}`);
debugLog(`URL Pattern: ${urlRegExp}`);
debugLog(`Variable Match: ${JSON.stringify(variableMatch) || 'None'}`);
debugLog(`URL Pattern: ${gql ? `[?&]op=${gql}` : urlRegExp}`);

interceptorHits.set(interceptorId, false);

return gql
? interceptGraphQLRequest(page, urlRegExp, gql, mock, registerHit(interceptorId), variableMatch)
? interceptGraphQLRequest(page, gql, mock, registerHit(interceptorId), variableMatch)
: interceptRESTRequest(page, urlRegExp, mock, registerHit(interceptorId));
});

Expand Down
Loading