Skip to content

Commit

Permalink
Dx partners/news page (#351)
Browse files Browse the repository at this point in the history
* news page test

* news page test url

* update after comments

* update after comments

* update after comments

* update after comments
  • Loading branch information
cod17828 authored May 30, 2024
1 parent 34ecfc0 commit 95bf24d
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 0 deletions.
70 changes: 70 additions & 0 deletions configs/dx.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// @ts-check
const { devices } = require('@playwright/test');

const envs = require('../envs/envs.js');

/**
* @see https://playwright.dev/docs/test-configuration
* @type {import('@playwright/test').PlaywrightTestConfig}
*/
const config = {
testDir: '../tests/dx',
outputDir: '../test-results',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 4 : 3,
/* Reporter to use. */
reporter: process.env.CI
? [['github'], ['list'], ['../utils/reporters/base-reporter.js']]
: [['html', { outputFolder: 'test-html-results' }], ['list'], ['../utils/reporters/base-reporter.js']],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 60000,

trace: 'on-first-retry',
baseURL: process.env.BASE_URL || envs['@dx_stage'] || 'https://stage--dx-partners--adobecom.hlx.live',
},

/* Configure projects for major browsers */
projects: [
{
name: 'dx-live-chromium',
use: {
...devices['Desktop Chrome'],
baseURL: envs['@dx_stage'],
},
},

{
name: 'dx-live-firefox',
use: {
...devices['Desktop Firefox'],
baseURL: envs['@dx_stage'],
},
},

{
name: 'dx-live-webkit',
use: {
...devices['Desktop Safari'],
baseURL: envs['@dx_stage'],
},
},
],
};
module.exports = config;
1 change: 1 addition & 0 deletions envs/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ module.exports = {
'@local3000': 'http://localhost:3000',
'@local6456': 'http://localhost:6456',
'@helpx_live': 'https://helpx-internal.stage.adobe.com',
'@dx_stage': 'https://stage--dx-partners--adobecom.hlx.live',
};
11 changes: 11 additions & 0 deletions features/dx/news.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
FeatureName: 'DX News page',
features: [
{
tcid: 'MWPW-137796',
name: '@desc-public-app-gravity-card-collection',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression',
},
],
};
27 changes: 27 additions & 0 deletions selectors/dx/news.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default class NewsPage {
constructor(page) {
this.page = page;
this.resultNumber = page.locator('.partner-cards-cards-results').nth(0);
this.firstCardTitle = page.locator('.card-title').nth(0);
}

async clickSearchField() {
await this.searchField.click();
}

/**
* @returns get result number
*/
async getResultNumber() {
const text = await this.resultNumber.textContent();
return text;
}

/**
* @returns get first card text
*/
async getFirstCardTitle() {
const text = await this.firstCardTitle.textContent();
return text;
}
}
18 changes: 18 additions & 0 deletions tests/dx/news.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test';

const News = require('../../features/dx/news.spec.js');

const { features } = News;

test.describe('Validate news page for public users', () => {
// Test - MWPW-137796
test(`${features[0].name},${features[0].tags}`, async ({ page, baseURL }) => {
console.info(`${baseURL}${features[0].path}`);

// test step-1
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${features[0].path}`);
await expect(page).toHaveURL(`${baseURL}${features[0].path}`);
});
});
});

0 comments on commit 95bf24d

Please sign in to comment.