Skip to content

Commit

Permalink
Implementing sign in testcases (#406)
Browse files Browse the repository at this point in the history
* config file

* config file

* config file

* config file

* logout

* Fix: eslint errors

* test updates

* Update: synced dev branches with cod17828/nala repo

* New: added login flow test cases

* test updates

* Fix: refactored function for email extraction from secret

* Fix: extracted sign in flow; cleaned up selectors file

* Fix: removed unnecessary dialog popup checks

* update partners url

* remove console logs

* Fix: refactored test cases due to changes from archive news page

* Fix: extracted functions to selectors file; refactored tests due to archive page changes;

* Fix: moved test case data to spec file

* function specific for these testcases. Only sign in would be used in other tests

* eslint fix

* update paths

* update paths

* include nopr tag

* eslint fix

* New: mapp signin test cases; Fix: extracted sign in function from news.page.js;

* Fix: removed unnecessary selectors from news page

* Fix: introduced variables in spec file to avoid hardcoded strings within test

* Fix: introduced variables in news spec file to avoid hardcoded strings within test

* Refactor: extracted verify function from test file

* Refactor: removed test steps from page file

---------

Co-authored-by: Kristijan Vizi <[email protected]>
  • Loading branch information
cod17828 and Kristijan Vizi authored Jul 29, 2024
1 parent 1527850 commit 87b78bb
Show file tree
Hide file tree
Showing 6 changed files with 457 additions and 18 deletions.
7 changes: 7 additions & 0 deletions features/dx/news.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
name: '@desc-regression-news-page-read-article',
path: '/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @anonymous',
expectedToSeeInURL: '/solutionpartners/drafts/automation/regression/caas-cards/automation-regression-card-no1',
},
{
tcid: '5',
Expand All @@ -36,6 +37,11 @@ module.exports = {
name: '@login-news-page-platinum-user',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-news @regression @login @nopr',
data: {
partnerLevel: 'spp-platinum:',
expectedToSeeInURL: '/solutionpartners/drafts/'
+ 'automation/regression/caas-cards/automation-regression-platinum-card-no1',
},
},
{
tcid: '7',
Expand Down Expand Up @@ -91,6 +97,7 @@ module.exports = {
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dx-news @regression @login @nopr',
partnerLevel: 'tpp-platinum:',
},
],
};
129 changes: 129 additions & 0 deletions features/dx/signin.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
module.exports = {
FeatureName: 'DX Sign In Flow',
features: [
{
tcid: '1',
name: '@login-redirect-to-protected-home',
testId: '@MWPW-140197',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-platinum:',
expectedProtectedURL: '/solutionpartners/drafts/automation/regression/protected-home',
expectedPublicURL: '/solutionpartners/drafts/automation/regression/public-page',
},
},
{
tcid: '2',
name: '@login-no-redirection-public-news',
testId: '@MWPW-140198 @MWPW-140201',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-gold:',
expectedToSeeInURL: '/solutionpartners/drafts/automation/regression/partner-news',
},
},
{
tcid: '3',
name: '@login-accessing-public-home-page-with-member-user-logged-in-to-adobe',
testId: '@MWPW-140202',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-community:',
expectedProtectedURL: '/solutionpartners/drafts/automation/regression/protected-home',
},
},
{
tcid: '4',
name: '@login-accessing-restricted-home-page-with-member-user-logged-in-to-adobe',
testId: '@MWPW-140203',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-platinum:',
expectedProtectedURL: '/solutionpartners/drafts/automation/regression/protected-home',
},
},
{
tcid: '5',
name: '@login-public-page-sign-in-with-non-member',
testId: '@MWPW-140207',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
newsPath: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/partner-news',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'tpp-platinum:',
expectedToSeeInURL: '/solutionpartners/error/contact-not-found',
},
},
{
tcid: '6',
name: '@login-accessing-restricted-home-page-with-non-member-user-logged-in-to-adobe',
testId: '@MWPW-140202',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/protected-home',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'tpp-platinum:',
expectedToSeeInURL: '/solutionpartners/error/contact-not-found',
},
},
{
tcid: '7',
name: '@login-accessing-public-page-with-non-member-user-logged-in-to-adobe',
testId: '@MWPW-140212',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
baseURL: 'https://www.stage.adobe.com/partners.html',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'tpp-platinum:',
expectedToSeeInURL: '/solutionpartners/error/contact-not-found',
},
},
{
tcid: '8',
name: '@login-accessing-restricted-home-page-with-non-logged-in-user',
testId: '@MWPW-140213',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/protected-home',
tags: '@dx-signin @regression @login @nopr',
expectedToSeeInURL: 'https://auth-stg1.services.adobe.com/',
},
{
tcid: '9',
name: '@login-with-submitted-in-review-spp-user',
testId: '@MWPW-140214',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-submitted-in-review:',
expectedLandingPageURL: 'https://partners.stage.adobe.com/solutionpartners/error/submitted-in-review',
},
},
{
tcid: '10',
name: '@login-with-deactivated-spp-user',
testId: '@MWPW-140224',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-deactivated:',
expectedLandingPageURL: 'https://partners.stage.adobe.com/solutionpartners/error/contact-inactive',
},
},
{
tcid: '11',
name: '@login-with-expired-spp-user',
testId: 'MWPW-140215',
path: 'https://partners.stage.adobe.com/solutionpartners/drafts/automation/regression/public-page',
tags: '@dx-signin @regression @login @nopr',
data: {
partnerLevel: 'spp-expired:',
expectedLandingPageURL: 'https://partners.stage.adobe.com/solutionpartners/error/account-expired',
},
},
],
};
12 changes: 0 additions & 12 deletions selectors/dx/news.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export default class NewsPage {
this.lastCardDate = page.locator('.card-date').nth(5);

this.signInButton = page.locator('button[daa-ll="Sign In"].feds-signIn');
this.emailField = page.locator('#EmailPage-EmailField');
this.emailPageContinueButton = page.locator('//button[@data-id="EmailPage-ContinueButton"]');
this.passwordField = page.locator('#PasswordPage-PasswordField');
this.passwordPageContinueButton = page.locator('//button[@data-id="PasswordPage-ContinueButton"]');
this.profileIconButton = page.locator('.feds-profile-button');
this.profileName = page.locator('.feds-profile-name');
this.logoutButton = page.locator('[daa-ll="Sign Out"]');
Expand All @@ -42,12 +38,4 @@ export default class NewsPage {
async clearFilter(filter, number) {
await this.page.locator(`[aria-label="${filter}"] + [aria-label="${number}"]`).click();
}

async signIn(partnerLevel) {
const email = process.env.IMS_EMAIL.split(partnerLevel)[1].split(';')[0];
await this.emailField.fill(email);
await this.emailPageContinueButton.click();
await this.passwordField.fill(process.env.IMS_PASS);
await this.passwordPageContinueButton.click();
}
}
39 changes: 39 additions & 0 deletions selectors/dx/signin.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export default class SignInPage {
constructor(page) {
this.page = page;
this.signInButton = page.locator('button[daa-ll="Sign In"].feds-signIn');
this.signInButtonStageAdobe = page.locator('.profile-comp.secondary-button');
this.profileIconButton = page.locator('.feds-profile-button');
this.joinNowButton = page.locator('a:has-text("Join now")');
this.explorePastArticles = page.locator('a:has-text("Explore past articles")');
this.newsletterLink = page.locator('a:has-text("product newsletter")');
this.logoutButton = page.locator('[daa-ll="Sign Out"]');
this.userNameDisplay = page.locator('.user-name');

this.IMSEmailPage = page.locator('form#EmailForm');
this.emailField = page.locator('#EmailPage-EmailField');
this.emailPageContinueButton = page.locator('//button[@data-id="EmailPage-ContinueButton"]');
this.IMSPasswordPage = page.locator('form#PasswordForm');
this.passwordField = page.locator('#PasswordPage-PasswordField');
this.passwordPageContinueButton = page.locator('//button[@data-id="PasswordPage-ContinueButton"]');
}

async signIn(page, partnerLevel) {
const email = process.env.IMS_EMAIL.split(partnerLevel)[1].split(';')[0];
await page.waitForLoadState('domcontentloaded');
await this.emailField.fill(email);
await this.emailPageContinueButton.click();
await this.passwordField.fill(process.env.IMS_PASS);
await this.passwordPageContinueButton.click();
}

async verifyLandingPageAfterLogin({ page, expect, path, partnerLevel, expectedLandingPageURL }) {
await page.goto(path);
await page.waitForLoadState('domcontentloaded');
await this.signInButton.click();
await this.signIn(page, partnerLevel);
await this.profileIconButton.waitFor({ state: 'visible', timeout: 20000 });
const pages = await page.context().pages();
await expect(pages[0].url()).toContain(expectedLandingPageURL);
}
}
16 changes: 10 additions & 6 deletions tests/dx/news.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { test, expect } from '@playwright/test';
import NewsPage from '../../selectors/dx/news.page.js';
import SignInPage from '../../selectors/dx/signin.page.js';

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

const { features } = News;

test.describe('Validate news block', () => {
test.beforeEach(async ({ page }) => {
newsPage = new NewsPage(page);
signInPage = new SignInPage(page);
});

async function findCardsForPartnerLevel(page, path, cardPartnerLevel, partnerLevel, resultTotal, cardLevelAbove) {
Expand All @@ -25,7 +28,7 @@ test.describe('Validate news block', () => {
});

await test.step('I load the news page', async () => {
await newsPage.signIn(partnerLevel);
await signInPage.signIn(page, partnerLevel);
});

await test.step('Find automation regression cards for current partner level', async () => {
Expand Down Expand Up @@ -173,6 +176,7 @@ test.describe('Validate news block', () => {
await test.step('Go to News page', async () => {
await page.goto(`${baseURL}${features[3].path}`);
await newsPage.searchField.fill('Automation regression news card SPP Public no1');
await newsPage.firstCardTitle.waitFor({ state: 'visible', timeout: 10000 });
const resultAfterSearch = await newsPage.resultNumber.textContent();
await expect(parseInt(resultAfterSearch.split(' ')[0], 10)).toBe(1);
});
Expand All @@ -181,7 +185,7 @@ test.describe('Validate news block', () => {
await newsPage.readCard.click();
const pages = await page.context().pages();
await expect(pages[0].url())
.toContain('/solutionpartners/drafts/automation/regression/caas-cards/automation-regression-card-no1');
.toContain(`${features[3].expectedToSeeInURL}`);
});
});

Expand Down Expand Up @@ -229,7 +233,7 @@ test.describe('Validate news block', () => {
});

await test.step('I load the news page', async () => {
await newsPage.signIn('spp-platinum:');
await signInPage.signIn(page, `${features[5].data.partnerLevel}`);
});

await test.step('Find platinum automation regression cards', async () => {
Expand All @@ -245,7 +249,7 @@ test.describe('Validate news block', () => {
await newsPage.readCard.click();
const pages = await page.context().pages();
await expect(pages[0].url())
.toContain('/solutionpartners/drafts/automation/regression/caas-cards/automation-regression-platinum-card-no1');
.toContain(`${features[5].data.expectedToSeeInURL}`);
});
});

Expand Down Expand Up @@ -297,7 +301,7 @@ test.describe('Validate news block', () => {

test(`${features[10].name},${features[10].tags}`, async ({ page, context }) => {
await test.step('Go to stage.adobe.com', async () => {
const url = `${features[10].path}`;
const url = `${features[10].baseURL}`;
await page.evaluate((navigationUrl) => {
window.location.href = navigationUrl;
}, url);
Expand All @@ -307,7 +311,7 @@ test.describe('Validate news block', () => {
});

await test.step('Sign in with non spp member', async () => {
await newsPage.signIn('tpp-platinum:');
await signInPage.signIn(page, `${features[10].partnerLevel}`);
});

await test.step(`Open ${features[10].path} in a new tab`, async () => {
Expand Down
Loading

0 comments on commit 87b78bb

Please sign in to comment.