From 565cda4e6423bd33585e78823b2b29001cf90264 Mon Sep 17 00:00:00 2001 From: sashaCodeTest Date: Thu, 9 Jan 2025 09:05:14 +0100 Subject: [PATCH] Smoke Tests --- nala/blocks/smoke-test/smoke.page.js | 88 +++++++++++ nala/blocks/smoke-test/smoke.spec.js | 121 +++++++++++++++ nala/blocks/smoke-test/smoke.test.js | 218 +++++++++++++++++++++++++++ 3 files changed, 427 insertions(+) create mode 100644 nala/blocks/smoke-test/smoke.page.js create mode 100644 nala/blocks/smoke-test/smoke.spec.js create mode 100644 nala/blocks/smoke-test/smoke.test.js diff --git a/nala/blocks/smoke-test/smoke.page.js b/nala/blocks/smoke-test/smoke.page.js new file mode 100644 index 0000000..460ab47 --- /dev/null +++ b/nala/blocks/smoke-test/smoke.page.js @@ -0,0 +1,88 @@ +export default class SmokeTest { + constructor(page) { + this.page = page; + this.joinNowButton = page.locator( + '#feds-nav-wrapper .feds-cta--primary:has-text("Join Now")' + ); + this.signInButton = page.locator('.feds-signIn'); + this.GNav = page.locator('.feds-topnav'); + this.profileIcon = page.locator('.feds-profile-button'); + this.priceList = page.locator('[daa-ll="Price lists-1"]'); + this.tableSelector = '.table-container'; + this.searchGnav = page.locator('.feds-search-trigger'); + this.searchGnavField = page.locator('.feds-search-input'); + this.searchFieldPage = page.locator('#search'); + this.announcemnts = page.locator('[daa-ll="Announcements-6"]'); + } + + async verifyButtonExist() { + const joinNowExist = await this.joinNowButton.isVisible(); + const signInExists = await this.signInButton.isVisible(); + + return { + joinNowButton: joinNowExist, + signInButton: signInExists, + }; + } + + async verifyProtectedGnav() { + const gNavExists = await this.GNav.isVisible(); + + return { + GNav: gNavExists, + }; + } + + async verifyProfileIcon() { + const profileIconExists = await this.profileIcon.isVisible(); + + return { + profileIcon: profileIconExists, + }; + } + + async getCurrentUrl() { + return await this.page.url(); + } + + async clickDownloadButtonInFirstRow() { + const firstRowWithDownload = this.page + .locator(`${this.tableSelector} tr:has(td[headers="download"])`) + .first(); + const downloadButton = firstRowWithDownload.locator('#button'); + await downloadButton.click(); + } + + async searchPageDownloadButton() { + const enableAll = this.page.locator('#onetrust-accept-btn-handler'); + await enableAll.waitFor({ state: 'visible' }); + await enableAll.click(); + const shadowHost = await this.page + .locator('search-cards.search-cards-wrapper[data-idx="2"]') + .elementHandle(); + const shadowRoot = await shadowHost.evaluateHandle( + (node) => node.shadowRoot + ); + + const downloadButton = await shadowRoot.$( + 'sp-action-button[href="https://partners.stage.adobe.com/channelpartnerassets/assets/public/public_1/scanning_documents_into_pdf_files--ar.pdf?download"]' + ); + + await downloadButton.click(); + } + + async announcmentCardVerification() { + const shadowHostCard = await this.page + .locator( + 'announcements-cards.content.announcements-wrapper[data-idx="0"]' + ) + .elementHandle(); + const shadowRootCard = await shadowHostCard.evaluateHandle( + (node) => node.shadowRoot + ); + + const announcementsCrad = await shadowRootCard.$$('.card-wrapper'); + const firstCard = announcementsCrad[0]; + await firstCard.isVisible(); + } +} diff --git a/nala/blocks/smoke-test/smoke.spec.js b/nala/blocks/smoke-test/smoke.spec.js new file mode 100644 index 0000000..3138f26 --- /dev/null +++ b/nala/blocks/smoke-test/smoke.spec.js @@ -0,0 +1,121 @@ +export default { + FeatureName: 'Smoke Tests', + features: [ + { + tcid: '1', + name: '@lending-page-validation-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + baseURL: 'https://www.stage.adobe.com?akamaiLocale=us', + }, + + { + tcid: '2', + name: '@home-page-validation-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + baseURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-latin-na-platinum:', + signInButtonInternationalText: 'Sign In', + }, + }, + + { + tcid: '3', + name: '@price-list-validation-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + basedURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-distributor-us:', + signInButtonInternationalText: 'Sign In', + expectedPublicPageURL: + 'https://partners.stage.adobe.com/na/channelpartners/home/pricelists/', + }, + }, + + { + tcid: '4', + name: '@search-page-validation-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + basedURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-distributor-us:', + signInButtonInternationalText: 'Sign In', + searchText: 'pdf', + }, + }, + + { + tcid: '5', + name: '@user-redirection-apac-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + basedURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-distributor-india:', + expectedPublicPageURL: + 'https://partners.stage.adobe.com/apac/channelpartners/drafts/automation/regression/protected-home#', + signInButtonInternationalText: 'Sign In', + }, + }, + + { + tcid: '6', + name: '@user-redirection-emea-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + basedURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-emea-platinum:', + expectedPublicPageURL: + 'https://partners.stage.adobe.com/emea/channelpartners/drafts/automation/regression/protected-home#', + signInButtonInternationalText: 'Sign In', + }, + }, + + { + tcid: '7', + name: '@user-redirection-jp-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + basedURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-distributor-japan:', + expectedPublicPageURL: + 'https://partners.stage.adobe.com/jp/channelpartners/drafts/automation/regression/protected-home#', + signInButtonInternationalText: 'Sign In', + }, + }, + + { + tcid: '8', + name: '@user-redirection-latam-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + basedURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-latin-america-na-platinum:', + expectedPublicPageURL: + 'https://partners.stage.adobe.com/latam/channelpartners/drafts/automation/regression/protected-home#', + signInButtonInternationalText: 'Sign In', + }, + }, + + { + tcid: '9', + name: '@announcement-page-validation-smoke-test', + path: 'https://partners.stage.adobe.com/channelpartners/drafts/automation/regression/public-page?georouting=off', + tags: '@dme-smoke-test', + baseURL: 'https://www.stage.adobe.com?akamaiLocale=us', + data: { + partnerLevel: 'cpp-na-certified:', + expectedPublicPageURL: + 'https://partners.stage.adobe.com/latam/channelpartners/drafts/automation/regression/protected-home#', + signInButtonInternationalText: 'Sign In', + }, + }, + ], +}; diff --git a/nala/blocks/smoke-test/smoke.test.js b/nala/blocks/smoke-test/smoke.test.js new file mode 100644 index 0000000..e5f3cfd --- /dev/null +++ b/nala/blocks/smoke-test/smoke.test.js @@ -0,0 +1,218 @@ +import { test, expect } from '@playwright/test'; +import smokeSpec from './smoke.spec'; +import SmokeTest from './smoke.page.js'; +import SignInPage from '../signin/signin.page.js'; + +let smokeTest; +let signInSmokeTest; + +const { features } = smokeSpec; + +test.describe('Smoke Tests', () => { + test.beforeEach(async ({ page, baseURL }) => { + smokeTest = new SmokeTest(page); + signInSmokeTest = new SignInPage(page); + + const { path } = features[0]; + await test.step('Go to Landing page', async () => { + await page.goto(new URL(path, baseURL).href); + }); + }); + //@lending-page-validation-smoke-test + test(`${features[0].name}, ${features[0].tags}`, async () => { + await test.step('Validate Join Now and Sign In Buttons', async () => { + // checking if there are buttons on the page + await smokeTest.verifyButtonExist(); + }); + }); + //@home-page-validation-smoke-test + test(`${features[1].name}, ${features[1].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[1].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, enter user email and password', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[1].data.partnerLevel}`); + }); + await test.step('Verify protected Gnav exists', async () => { + await smokeTest.verifyProtectedGnav(); + }); + await test.step('Verify Profile Icon exists', async () => { + await smokeTest.verifyProfileIcon(); + }); + }); + //@price-list-validation-smoke-test + test(`${features[2].name}, ${features[2].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[2].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, enter user email and password', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[2].data.partnerLevel}`); + }); + await test.step('Go to Price List from GNav and verify redirection', async () => { + //cliking on price list from gnav + await smokeTest.priceList.click(); + await page.waitForTimeout(3000); + //checking url + const currentURL = await page.evaluate(() => window.location.href); + await expect(currentURL).toContain( + features[2].data.expectedPublicPageURL + ); + }); + await test.step('Find a row in price list and click on download', async () => { + await smokeTest.clickDownloadButtonInFirstRow(); + }); + }); + //@search-page-validation-smoke-test + test(`${features[3].name}, ${features[3].tags}`, async ({ page }) => { + const { data } = features[3]; + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[3].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, enter user email and password', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[2].data.partnerLevel}`); + }); + await test.step('Click rearch from GNav', async () => { + //cliking on search from gnav + await smokeTest.searchGnav.click(); + }); + //search pdf and click enter + await test.step('Verify a search field and type text', async () => { + // await smokeTest.search(); + await smokeTest.searchGnavField.fill(data.searchText); + await smokeTest.searchGnavField.press('Enter'); + }); + + await test.step('Verify search page conntent', async () => { + const searchFieldValue = await smokeTest.searchFieldPage.getAttribute( + 'value' + ); + expect(searchFieldValue).toContain(data.searchText); + }); + + await test.step('Find a row in assets list and click on download', async () => { + // await smokeTest.searchFirstAsset.click(); + await smokeTest.searchPageDownloadButton(); + }); + }); + + //@user-redirection-apac-smoke-test + test(`${features[4].name}, ${features[4].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[4].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, verify user redirection', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[4].data.partnerLevel}`); + await page.waitForTimeout(10000); + + const currentURL = await page.evaluate(() => window.location.href); + await expect(currentURL).toContain( + features[4].data.expectedPublicPageURL + ); + }); + }); + //@user-redirection-emea-smoke-test + test(`${features[5].name}, ${features[5].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[5].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, verify user redirection', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[5].data.partnerLevel}`); + await page.waitForTimeout(10000); + + const currentURL = await page.evaluate(() => window.location.href); + await expect(currentURL).toContain( + features[5].data.expectedPublicPageURL + ); + }); + }); + //@user-redirection-jp-smoke-test + test(`${features[6].name}, ${features[6].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[6].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, verify user redirection', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[6].data.partnerLevel}`); + await page.waitForTimeout(10000); + const currentURL = await page.evaluate(() => window.location.href); + await expect(currentURL).toContain( + features[6].data.expectedPublicPageURL + ); + }); + }); + //@search-page-validation-smoke-test + test(`${features[7].name}, ${features[7].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[7].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In, verify user redirection', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[7].data.partnerLevel}`); + await page.waitForTimeout(10000); + const currentURL = await page.evaluate(() => window.location.href); + await expect(currentURL).toContain( + features[7].data.expectedPublicPageURL + ); + }); + }); + //@announcement-page-validation-smoke-test + test(`${features[8].name}, ${features[8].tags}`, async ({ page }) => { + await test.step('Click Sign In button', async () => { + // finding sign in button + const signInButtonInt = await signInSmokeTest.getSignInButton( + `${features[7].data.signInButtonInternationalText}` + ); + //click on sign in button + await signInButtonInt.click(); + }); + await test.step('Sing In', async () => { + // entering user email and password + await signInSmokeTest.signIn(page, `${features[8].data.partnerLevel}`); + + await test.step('Click on Announcments from GNav and verify one Announcment card is displayed', async () => { + await smokeTest.announcemnts.click(); + await smokeTest.announcmentCardVerification(); + }); + }); + }); +});