Skip to content

Commit

Permalink
LPD-41705 fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosapmf authored and brianchandotcom committed Jan 16, 2025
1 parent 4d5f41c commit d81f9ed
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ import {dataApiHelpersTest} from '../../fixtures/dataApiHelpersTest';
import {featureFlagsTest} from '../../fixtures/featureFlagsTest';
import {loginAnalyticsCloudTest} from '../../fixtures/loginAnalyticsCloudTest';
import {loginTest} from '../../fixtures/loginTest';
import {liferayConfig} from '../../liferay.config';
import getRandomString from '../../utils/getRandomString';
import {clickOnActionButton} from './utils/ab-test';
import {createChannel} from './utils/channel';
import {syncAnalyticsCloud} from '../analytics-settings-web/utils/analytics-settings';
import { faroConfig } from './faro.config';
import { clickOnLink } from './utils/actions';
import {switchChannel} from './utils/channel';
import {
ACPage,
navigateTo,
navigateToACPageViaURL,
navigateToACSettingsViaURL,
navigateToACWorkspace,
} from './utils/navigation';
import {addBreakdownByIndividualAttribute} from './utils/utils';

export const test = mergeTests(
apiHelpersTest,
Expand All @@ -29,30 +35,16 @@ export const test = mergeTests(
loginTest()
);

const randomString = getRandomString();

const channelName = 'My Property ' + randomString;

let channel;
let project;

test.beforeEach(async ({apiHelpers}) => {
const result = await createChannel({
apiHelpers,
channelName,
});
const randomString = getRandomString();

channel = result.channel;
project = result.project;
test.beforeEach(async ({apiHelpers}) => {
project = await apiHelpers.jsonWebServicesOSBFaro.createProject('My Project ' + randomString)
});

test.afterEach(async ({apiHelpers}) => {
await test.step('Delete channel', async () => {
await apiHelpers.jsonWebServicesOSBFaro.deleteChannel(
`[${channel.id}]`,
project.groupId
);
});
await apiHelpers.jsonWebServicesOSBFaro.deleteProject(project.groupId);
});

test(
Expand All @@ -63,10 +55,6 @@ test(
},

async ({page}) => {
await test.step('Go to Analytics Cloud', async () => {
await navigateToACWorkspace({page});
});

await test.step('Go to Data Sources, check the empty page status message', async () => {
await navigateToACSettingsViaURL({
acPage: ACPage.dataSourcePage,
Expand All @@ -85,7 +73,8 @@ test(
page.getByText('Access our documentation to learn more.')
).toBeVisible();

await clickOnActionButton({
await clickOnLink({
baseUrl:faroConfig.environment.baseUrl,
name: 'Access our documentation to learn more.',
page,
});
Expand Down Expand Up @@ -115,7 +104,8 @@ test(
page.getByText('Access our documentation to learn more.')
).toBeVisible();

await clickOnActionButton({
await clickOnLink({
baseUrl:faroConfig.environment.baseUrl,
name: 'Access our documentation to learn more.',
page,
});
Expand Down Expand Up @@ -155,24 +145,45 @@ test(
projectID: project.groupId,
});

clickOnActionButton({name: 'canonicalUrl', page});
//await clickOnLink({baseUrl:faroConfig.environment.baseUrl, name: 'canonicalUrl', page});

const tableBodyElement = await page.locator('table tbody');

await expect(
tableBodyElement
).toBeVisible();

const elements = await tableBodyElement.locator('td .table-title a').all();

const href = await elements[0].getAttribute('href');

await page.goto(`${faroConfig.environment.baseUrl}${href}`);

await expect(
page.getByText(
'No Sample Data Found,You can come back later and check if there is any data received from your events.,Learn more about event tracking.'
'No Sample Data Found'
)
).toBeVisible();
await expect(
page.getByText(
'You can come back later and check if there is any data received from your events.Learn more about event tracking'
)
).toBeVisible();
await expect(
page.getByText('Learn more about event tracking.')
).toBeVisible();

await clickOnActionButton({
await clickOnLink({
baseUrl:faroConfig.environment.baseUrl,
name: 'Learn more about event tracking.',
page,
});

await expect(page).toHaveTitle('Definitions - Liferay Learn');
await expect(page.getByText('Event Attributes')).toBeVisible();

const header = await page.locator('h2#event-attributes');

await expect(header.getByText('Event Attributes')).toBeVisible();
});

await test.step('Go to Definitions, then go to Events, select the Custom Events tab and check the empty page status message then check the if the hyperlink is taking the user to the documentation', async () => {
Expand All @@ -192,7 +203,8 @@ test(
page.getByText('Learn how to add custom events on your site.')
).toBeVisible();

await clickOnActionButton({
await clickOnLink({
baseUrl:faroConfig.environment.baseUrl,
name: 'Learn how to add custom events on your site.',
page,
});
Expand All @@ -219,7 +231,8 @@ test(
)
).toBeVisible();

await clickOnActionButton({
await clickOnLink({
baseUrl:faroConfig.environment.baseUrl,
name: 'Access our documentation to learn how to manage custom events.',
page,
});
Expand Down Expand Up @@ -262,17 +275,20 @@ test(
page.getByText('Access our documentation to learn more.')
).toBeVisible();

await clickOnActionButton({
await clickOnLink({
baseUrl:faroConfig.environment.baseUrl,
name: 'Access our documentation to learn more.',
page,
});

await expect(page).toHaveTitle(
'Data Control and Privacy - Liferay Learn'
);

const element = await page.locator('a#data-control-and-privacy');

await expect(
page
.locator('a#data-control-and-privacy')
element
.getByText('Data Control and Privacy')
).toBeVisible();
});
Expand Down
11 changes: 2 additions & 9 deletions modules/test/playwright/tests/osb-faro-web/utils/ab-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {Page, expect} from '@playwright/test';

import {liferayConfig} from '../../../liferay.config';
import { clickOnLink } from './actions';

export async function checkEmptyStateOnACSide(page: Page) {
await expect(page.getByText('There are no tests found.')).toBeVisible();
Expand All @@ -18,13 +19,5 @@ export async function clickOnActionButton({
name: string;
page: Page;
}) {
const reviewTagA = await page.locator(
`xpath=//a[contains(text(),"${name}")]`
);

const href = await reviewTagA.getAttribute('href');

await page.goto(
href.replace('http://localhost:8080', liferayConfig.environment.baseUrl)
);
await clickOnLink({baseUrl: liferayConfig.environment.baseUrl, name, page});
}
34 changes: 34 additions & 0 deletions modules/test/playwright/tests/osb-faro-web/utils/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import {Page, expect} from '@playwright/test';

import {liferayConfig} from '../../../liferay.config';

export async function checkEmptyStateOnACSide(page: Page) {
await expect(page.getByText('There are no tests found.')).toBeVisible();
}

export async function clickOnLink({
baseUrl,
name,
page,
}: {
baseUrl: string;
name: string;
page: Page;
}) {
const reviewTagA = await page.locator(
`xpath=//a[contains(text(),"${name}")]`
);

const href = await reviewTagA.getAttribute('href');

console.log('href', href);

await page.goto(
href.replace('http://localhost:8080', baseUrl)
);
}
50 changes: 50 additions & 0 deletions modules/test/playwright/tests/osb-faro-web/utils/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import {Page, expect} from '@playwright/test';

import getRandomString from '../../../utils/getRandomString';
import { faroConfig } from '../faro.config';


export async function acceptsCookiesBanner(page: Page) {
const cookiesBannerButton = page.getByRole('button', {name: 'Accept All'});

if (await cookiesBannerButton.isVisible()) {
await cookiesBannerButton.click();
}
}

export async function createProject({
page,
}: {
page: Page;
}) {
await page.goto(faroConfig.environment.baseUrl);

await page.getByRole('link', {name: 'Start Free Trial'}).click();

const workspaceName = 'Workspace ' + getRandomString();

await page.getByLabel('Workspace Name').fill(workspaceName);

await page.getByRole('textbox').nth(4).fill('test@liferay.com');

await page.getByLabel('I Agree').check();

await page.getByRole('button', {name: 'Finish Setup'}).click();

await expect(page.getByText('Success:Success')).toBeVisible();

await page.waitForTimeout(1000);

expect(page.getByText('Welcome to Analytics Cloud')).toBeVisible();

expect(
page.getByText(
'Just a few more steps to set up your workspace.'
)
).toBeVisible();
}

0 comments on commit d81f9ed

Please sign in to comment.