diff --git a/tests/e2e/artifacts/storage-states/admin.json b/tests/e2e/artifacts/storage-states/admin.json new file mode 100644 index 0000000..8556cdb --- /dev/null +++ b/tests/e2e/artifacts/storage-states/admin.json @@ -0,0 +1 @@ +{"cookies":[{"name":"wordpress_test_cookie","value":"WP+Cookie+check","domain":"rtmediapro.local","path":"/","expires":-1,"httpOnly":false,"secure":false,"sameSite":"Lax"},{"name":"wordpress_785143b184cbf7f0f58a34577eca6c65","value":"automation%7C1692206281%7CR75VuSPhyAS0SpSBP9bHjOOApzwBlb620W5sxgRZQxX%7Cab826fe25c088c1474e53bfcd05017034f34bcce7536164f19e8abefdf59e3ce","domain":"rtmediapro.local","path":"/wp-content/plugins","expires":-1,"httpOnly":true,"secure":false,"sameSite":"Lax"},{"name":"wordpress_785143b184cbf7f0f58a34577eca6c65","value":"automation%7C1692206281%7CR75VuSPhyAS0SpSBP9bHjOOApzwBlb620W5sxgRZQxX%7Cab826fe25c088c1474e53bfcd05017034f34bcce7536164f19e8abefdf59e3ce","domain":"rtmediapro.local","path":"/wp-admin","expires":-1,"httpOnly":true,"secure":false,"sameSite":"Lax"},{"name":"wordpress_logged_in_785143b184cbf7f0f58a34577eca6c65","value":"automation%7C1692206281%7CR75VuSPhyAS0SpSBP9bHjOOApzwBlb620W5sxgRZQxX%7C9be4b6d17d5c0e3e16131b093e529726fb1cff1d4c9b24564823e1ff4aa097d1","domain":"rtmediapro.local","path":"/","expires":-1,"httpOnly":true,"secure":false,"sameSite":"Lax"},{"name":"wp-settings-time-1","value":"1692033481","domain":"rtmediapro.local","path":"/","expires":1723569481.625,"httpOnly":false,"secure":false,"sameSite":"Lax"}],"nonce":"998e26f68c","rootURL":"http://rtmediapro.local/wp-json/"} \ No newline at end of file diff --git a/tests/e2e/page/RtSocial.js b/tests/e2e/page/RtSocial.js new file mode 100644 index 0000000..c26d2ab --- /dev/null +++ b/tests/e2e/page/RtSocial.js @@ -0,0 +1,171 @@ +const { expect } = require("@playwright/test"); +const { selectors } = require('../utils/selectors') +exports.RtSocial = class RtSocial { + constructor(page,context) { + this.page = page; + this.context= context + } + // this functions is to navigate to the Mention link Setting page + async navigateToSettingPage() { + await this.page.goto("./wp-admin/options-general.php?page=rtsocial-options", { waitUntil: "load" }); + } + // this function is used to validate all the visible options in the settings page + async validateVisibleOptions(){ + const placementSettings = this.page.locator(selectors.placementSettingsDiv) + expect(placementSettings).not.toBeNull(); + const buttonStyle = this.page.locator(selectors.buttonStyleDiv) + expect(buttonStyle).not.toBeNull(); + const alignmentSetting = this.page.locator(selectors.leftAlignment); + expect(alignmentSetting).not.toBeNull(); + const activeButtons = this.page.locator(selectors.activeButtonDiv); + expect(activeButtons).not.toBeNull(); + const twitterHandle = this.page.locator(selectors.twitterHandleInput); + expect(twitterHandle).not.toBeNull(); + const facebookToken = this.page.locator(selectors.faceBooktokenInput); + expect(facebookToken).not.toBeNull(); + } + // this function is used to test Alignment Settings checkboxes + async validateAlignmentCheckbox(){ + expect(selectors.leftAlignment).not.toBeNull() + expect(selectors.rightAlignment).not.toBeNull() + expect(selectors.centerAlignment).not.toBeNull() + expect(selectors.noneAlignment).not.toBeNull() + } + // this function is used to Test Button Style checkboxes + async validateButtonStyleCheckbox(){ + expect(selectors.horizontalButtonStyle).not.toBeNull(); + expect(selectors.iconCountButtonStyle).not.toBeNull(); + expect(selectors.iconButtonStyle).not.toBeNull(); + expect(selectors.verticalButtonStyle).not.toBeNull(); + } + // this function is used to Test Placement Checkboxes + async validatePlacementCheckbox(){ + expect(selectors.topPlacement).not.toBeNull(); + expect(selectors.bottomPlacement).not.toBeNull(); + } + + // this function is used to set Left aligned in top position with icon style Social Icons + async setLeftAlignTopPlaceIcon(){ + await this.page.locator(selectors.topPlacement).check(); + await this.page.locator(selectors.iconButtonStyle).check() + await this.page.locator(selectors.leftAlignment).check(); + } + // this functions is used to save settings + async saveSetting(){ + await this.page.locator(selectors.buttonSaveSetting).click(); + expect(this.page.locator(selectors.messageSaveSetting)).not.toBeNull(); + } + // this function is used to validate Left aligned in top position with iconCount style Social Icons + async validateLeftAlignTopPlaceIcon(){ + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.leftAlignedValidate).first()).toBeVisible(); + } + // this function is used to set Right aligned in top position with iconCount style Social Icons + async setRightAlignTopPlaceIcon(){ + await this.page.locator(selectors.topPlacement).check(); + await this.page.locator(selectors.iconCountButtonStyle).check() + await this.page.locator(selectors.rightAlignment).check(); + } + // this function is used to validate Right aligned in top position with iconCount style Social Icons + async validateRightAlignTopPlaceIcon(){ + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.rightAlignedValidate).first()).toBeVisible(); + } + // this function is used to set Center alignement with top placement and horizontal + async setCenterAlignTopPlaceHorizontal(){ + await this.page.locator(selectors.topPlacement).check(); + await this.page.locator(selectors.centerAlignment).check(); + await this.page.locator(selectors.horizontalButtonStyle).check() + } + // this function is used to validate Center alignement with top placement and horizontal + async validateCenterAlignTopPlaceHorizontal(){ + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.buttonHorizontalValidate).first()).toBeVisible(); + } + // this function is used to set Center alignement with top placement and icon button style + async setCenterAlignTopPlaceIconButtonStyle() { + await this.page.locator(selectors.topPlacement).check(); + await this.page.locator(selectors.centerAlignment).check(); + await this.page.locator(selectors.iconButtonStyle).check() + } + // this function is used to validate Center alignement with top placement and icon button style + async validateCenterAlignTopPlaceIconButtonStyle(){ + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.iconValidate).first()).toBeVisible(); + } + // this function is used to set Center alignement with botton placement and iconcount button style + async setCenterAlignBottomPlaceIconCount(){ + await this.page.locator(selectors.bottomPlacement).check(); + await this.page.locator(selectors.centerAlignment).check(); + await this.page.locator(selectors.iconCountButtonStyle).check() + } + // this function is used to validate Center alignement with botton placement and iconcount button style + async validateCenterAlignBottomPlaceIconCount() { + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.iconCountValidate).first()).toBeVisible(); + } + // this function is used to set Center alignement with top placement and vertical button style + async setCenterAlignTopPlaceVerticalIcon(){ + await this.page.locator(selectors.topPlacement).check(); + await this.page.locator(selectors.centerAlignment).check(); + await this.page.locator(selectors.verticalButtonStyle).check() + } + // this function is used to Validate Center alignement with top placement and vertical button style + async validateCenterAlignTopPlaceVerticalIcon(){ + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.topValidate).first()).toBeVisible(); + } + // this function is used to set Center alignement with bottom placement and vertical button style + async setCenterAlignBottomPlaceVerticalIcon(){ + await this.page.locator(selectors.bottomPlacement).check(); + await this.page.locator(selectors.centerAlignment).check(); + await this.page.locator(selectors.verticalButtonStyle).check(); + } + // this function is used to validate Center alignement with bottom placement and vertical button style + async valiateCenterAlignBottomPlaceVerticalIcon(){ + await Promise.all([ + this.page.click(selectors.adminBar), + ]); + await expect(this.page.locator(selectors.bottomValidate).first()).toBeVisible(); + } + // this function is used to Check active and inactive drag and drop + async setDragDrop(){ + const src = await this.page.$(selectors.activeButtonDiv) + const dst = await this.page.$(selectors.inactiveDestButton); + if (src && dst) { + const srcBound = await src.boundingBox() + const dstBound = await dst.boundingBox() + if (srcBound && dstBound) { + await this.page.mouse.click(srcBound.x + srcBound.width, srcBound.y + srcBound.height) + await this.page.mouse.down() + await this.page.mouse.move(srcBound.x + srcBound.width, srcBound.y + srcBound.height) + await this.page.mouse.move(dstBound.x + dstBound.width, dstBound.y + dstBound.height) + await this.page.mouse.down(); + } else { + throw new Error("No Element") + } + } + } + // this function is used to set and validate twitter handle input + async setValidateTwitterHandle(){ + await this.page.locator(selectors.twitterHandle).fill("test"); + await this.page.locator(selectors.twitterRaltedHandle).fill("test"); + } + // this function is used to set and validate facebook token input backend + async setValidateFacebookHandle(){ + await this.page.locator(selectors.facebookHandleToken).fill(selectors.facebookTokenValue); + await this.page.locator(selectors.facbookHandleCheckbox).nth(3).check(); + } +} \ No newline at end of file diff --git a/tests/e2e/specs/01_validate-settings-options.spec.js b/tests/e2e/specs/01_validate-settings-options.spec.js new file mode 100644 index 0000000..de7317c --- /dev/null +++ b/tests/e2e/specs/01_validate-settings-options.spec.js @@ -0,0 +1,13 @@ +/** + * WordPress dependencies + */ +const { test } = require('@wordpress/e2e-test-utils-playwright'); +const { RtSocial } = require('../page/RtSocial.js'); +test.describe('Validate Rtsocial Settings', () => { + test('Check rtSocial Options', async ({ admin, page }) => { + await admin.visitAdminPage("/"); + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.validateVisibleOptions(); + }); +}); \ No newline at end of file diff --git a/tests/e2e/specs/02_validate-alignment.spec.js b/tests/e2e/specs/02_validate-alignment.spec.js new file mode 100644 index 0000000..b2d1685 --- /dev/null +++ b/tests/e2e/specs/02_validate-alignment.spec.js @@ -0,0 +1,49 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); +const { RtSocial } = require('../page/RtSocial.js'); +const { selectors } = require('../utils/selectors.js'); +test.describe('Validate Alignement with button functionality', () => { + test('Check rtSocial button Alignment in the backend', async ({ page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.validateAlignmentCheckbox(); + }); + test('Validate rtSocial Left alignment with fixed position and button style with button functionality', async ({ context, page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setLeftAlignTopPlaceIcon(); + await rtSocialobj.saveSetting(); + await rtSocialobj.validateLeftAlignTopPlaceIcon(); + // Validate twitter + const [newPage] = await Promise.all([ + context.waitForEvent('page'), + page.locator(selectors.frontEndTwitterIcon).first().click() // Opens a new tab + ]) + await newPage.waitForLoadState(); + await expect(newPage).toHaveURL(/twitter/); + }); + test('Validate rtSocial Right alignment with fixed position and button style', async ({ context, page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setRightAlignTopPlaceIcon(); + await rtSocialobj.saveSetting(); + await rtSocialobj.validateRightAlignTopPlaceIcon(); + // Validate Facebook + const [newpage] = await Promise.all([ + context.waitForEvent('page'), + page.locator(selectors.frontEndFacebookIcon).first().click() // Opens a new tab // Opens a new tab + ]) + await newpage.waitForLoadState(); + await expect(newpage).toHaveURL(/facebook/); + // login and share + await newpage.locator(selectors.facebookInput).fill(selectors.userGmail); + await newpage.locator(selectors.facebookPassword).fill(selectors.userPassword); + await newpage.locator(selectors.facbookSubmit).click(); + await expect(newpage).toHaveURL(/facebook/); + // validate & Share + await expect(newpage.locator(selectors.facebookShareButton)).toBeVisible(); + await newpage.locator(selectors.facebookShareButton).click(); + }); +}); \ No newline at end of file diff --git a/tests/e2e/specs/03_validate-button.spec.js b/tests/e2e/specs/03_validate-button.spec.js new file mode 100644 index 0000000..797e72a --- /dev/null +++ b/tests/e2e/specs/03_validate-button.spec.js @@ -0,0 +1,50 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); +const { RtSocial } = require('../page/RtSocial.js'); +const { selectors } = require('../utils/selectors.js'); +test.describe('Validate button, alginment in the front end. ', () => { + test('Check rtSocial button checkbox in the backend', async ({ page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.validateButtonStyleCheckbox(); + }); + test(' Validate rtSocial Horizontal Buttons and with placement and Alignment', async ({ context, page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setCenterAlignTopPlaceHorizontal(); + await rtSocialobj.saveSetting(); + await rtSocialobj.validateCenterAlignTopPlaceHorizontal(); + // Validate pinterest + const [newPage] = await Promise.all([ + context.waitForEvent('page'), + page.locator(selectors.pinterestIcon).click() + ]) + await newPage.waitForLoadState(); + await expect(newPage).toHaveURL(/pinterest/); + }); + + test(' Validate rtSocial Icon Buttons and with placement and Alignment', async ({ context, page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setCenterAlignTopPlaceIconButtonStyle(); + await rtSocialobj.saveSetting(); + await rtSocialobj.validateCenterAlignTopPlaceIconButtonStyle(); + // Validate linkedin + const [newPage] = await Promise.all([ + context.waitForEvent('page'), + page.locator(selectors.linkedinIcon).click() + ]) + await newPage.waitForLoadState(); + await expect(newPage).toHaveURL(/link/); + + }); + test(' Validate rtSocial IconCount Buttons and with placement and Alignment.', async ({ page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setCenterAlignBottomPlaceIconCount(); + await rtSocialobj.saveSetting(); + await rtSocialobj.validateCenterAlignBottomPlaceIconCount(); + }); +}); \ No newline at end of file diff --git a/tests/e2e/specs/04_validate-placement.spec.js b/tests/e2e/specs/04_validate-placement.spec.js new file mode 100644 index 0000000..ad45eb7 --- /dev/null +++ b/tests/e2e/specs/04_validate-placement.spec.js @@ -0,0 +1,27 @@ +/** + * WordPress dependencies + */ +const { test } = require('@wordpress/e2e-test-utils-playwright'); +const { RtSocial } = require('../page/RtSocial.js'); +test.describe('Validate Placement and buttons functionality in the front end. ', () => { + test('Check rtSocial placement checkbox in the backend', async ({ admin, page, editor }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.validatePlacementCheckbox(); + }); + test(' Validate rtSocial Top placement settings with Vertical button style.', async ({ admin, page, editor }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setCenterAlignTopPlaceVerticalIcon(); + await rtSocialobj.saveSetting(); + await rtSocialobj.validateCenterAlignTopPlaceVerticalIcon(); + }); + test(' Validate rtSocial Bottom placement settings with Vertical button style.', async ({ admin, page, editor }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setCenterAlignBottomPlaceVerticalIcon(); + await rtSocialobj.saveSetting(); + await rtSocialobj.valiateCenterAlignBottomPlaceVerticalIcon(); + }); + +}); \ No newline at end of file diff --git a/tests/e2e/specs/05_validate-share-button-list.spec.js b/tests/e2e/specs/05_validate-share-button-list.spec.js new file mode 100644 index 0000000..95f0d19 --- /dev/null +++ b/tests/e2e/specs/05_validate-share-button-list.spec.js @@ -0,0 +1,32 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); +const { RtSocial } = require('../page/RtSocial.js'); +const { selectors } = require('../utils/selectors.js'); +test.describe('Validate Social Sharing Handle Inputs', () => { + test(' Validate rtSocial Handle and sharing buttons', async ({ page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setDragDrop(); + await rtSocialobj.saveSetting(); + // Validate Drag and drop after performing action + await expect(page.locator(selectors.activeButtonDiv)).toBeVisible(); + }); + test(' Validate rtSocial Twitter Handles input', async ({ page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setValidateTwitterHandle(); + await rtSocialobj.saveSetting(); + await expect(page.locator(selectors.twitterHandle)).toHaveValue("test"); + }); + + test(' Validate rtSocial Facebook Handles input', async ({ page }) => { + const rtSocialobj = new RtSocial(page); + await rtSocialobj.navigateToSettingPage(); + await rtSocialobj.setValidateFacebookHandle(); + await rtSocialobj.saveSetting(); + await expect(page.locator(selectors.facebookHandleToken)).toBeVisible(); + }); + +}); \ No newline at end of file diff --git a/tests/e2e/specs/validate-alignment.spec.js b/tests/e2e/specs/validate-alignment.spec.js deleted file mode 100644 index 3494c59..0000000 --- a/tests/e2e/specs/validate-alignment.spec.js +++ /dev/null @@ -1,75 +0,0 @@ -/** - * WordPress dependencies - */ -const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); -const { Placement, ButtonStyle, Alignment, SaveSetting, PlacementValidation } = require("../utils/locator.js"); -test.describe('Validate Alignement with button functionality', () => { - test.beforeEach(async ({ admin }) => { - await admin.visitAdminPage('options-general.php'); - }); - test('Check rtSocial button Alignment in the backend', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Test Alignment Settings checkboxes - expect(Alignment.Center).not.toBeNull() - expect(Alignment.Left).not.toBeNull() - expect(Alignment.None).not.toBeNull() - expect(Alignment.Right).not.toBeNull() - }); - test('Validate rtSocial Left alignment with fixed position and button style with button functionality', async ({ context, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement Top+ Button Icon count - await page.locator(Placement.Top).check(); - await page.locator(ButtonStyle.IconCount).check() - // Select Alignment Left - await page.locator(Alignment.Left).check(); - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.LeftAligned); - // Validate twitter - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - page.locator('div.rtsocial-twitter-icon > div > a').first().click() // Opens a new tab - ]) - await newPage.waitForLoadState(); - await expect(newPage).toHaveURL(/twitter/); - }); - test('Validate rtSocial Right alignment with fixed position and button style', async ({ context, page }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement Top+ Button Icon count - await page.locator(Placement.Top).check(); - await page.locator(ButtonStyle.IconCount).check() - // Select Alignment Right - await page.locator(Alignment.Right).check(); - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.RightAligned); - - // Validate Facebook - const [newpage] = await Promise.all([ - context.waitForEvent('page'), - page.locator('div.rtsocial-fb-icon-button > a').first().click() // Opens a new tab // Opens a new tab - ]) - await newpage.waitForLoadState(); - await expect(newpage).toHaveURL(/facebook/); - // login and share - await newpage.locator("input[name='email']").fill("qartcamp@gmail.com"); - await newpage.locator("input[name='pass']").fill("xzBykf8zJrkeZV8S"); - await newpage.locator("input[name='login']").click(); - await expect(newpage).toHaveURL(/facebook/); - // Share - await newpage.locator("button[name='__CONFIRM__']").click(); - }); - -}); \ No newline at end of file diff --git a/tests/e2e/specs/validate-button.spec.js b/tests/e2e/specs/validate-button.spec.js deleted file mode 100644 index 27641a5..0000000 --- a/tests/e2e/specs/validate-button.spec.js +++ /dev/null @@ -1,88 +0,0 @@ -/** - * WordPress dependencies - */ -const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); -const { Placement, ButtonStyle, Alignment, SaveSetting, PlacementValidation } = require("../utils/locator.js"); -test.describe('Validate button, alginment in the front end. ', () => { - test.beforeEach(async ({ admin }) => { - await admin.visitAdminPage('options-general.php'); - }); - test('Check rtSocial button checkbox in the backend', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Test Button Style checkboxes - expect(ButtonStyle.Horizontal).not.toBeNull(); - expect(ButtonStyle.IconCount).not.toBeNull(); - expect(ButtonStyle.Icon).not.toBeNull(); - expect(ButtonStyle.Vertical).not.toBeNull(); - }); - test(' Validate rtSocial Horizontal Buttons and with placement and Alignment', async ({ context, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement Top+ Alignment center - await page.locator(Placement.Top).check(); - await page.locator(Alignment.Center).check(); - // Select button Horizontal - await page.locator(ButtonStyle.Horizontal).check() - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.ButtonHorizontal); - // Validate pin it - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - page.locator('div.rtsocial-pinterest-horizontal-button > a').click() // Opens a new tab - ]) - await newPage.waitForLoadState(); - await expect(newPage).toHaveURL(/pinterest/); - }); - test(' Validate rtSocial Icon Buttons and with placement and Alignment', async ({ context, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement Top+ Alignment center - await page.locator(Placement.Top).check(); - await page.locator(Alignment.Center).check(); - // Select button Vertical - await page.locator(ButtonStyle.Icon).check() - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.Icon); - // Validate linkedin - const [newPage] = await Promise.all([ - context.waitForEvent('page'), - page.locator('div.rtsocial-linkedin-icon > div > a').click() // Opens a new tab - ]) - await newPage.waitForLoadState(); - await expect(newPage).toHaveURL(/link/); - - }); - test(' Validate rtSocial IconCount Buttons and with placement and Alignment.', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement Top+ Alignment center - await page.locator(Placement.Bottom).check(); - await page.locator(Alignment.Center).check(); - // Select button Vertical - await page.locator(ButtonStyle.IconCount).check() - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - - - - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.IconCount) - }); - -}); \ No newline at end of file diff --git a/tests/e2e/specs/validate-placement.spec.js b/tests/e2e/specs/validate-placement.spec.js deleted file mode 100644 index 6344fce..0000000 --- a/tests/e2e/specs/validate-placement.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * WordPress dependencies - */ -const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); -const { Placement, ButtonStyle, Alignment, SaveSetting, PlacementValidation } = require("../utils/locator.js"); - - -test.describe('Validate Placement and buttons functionality in the front end. ', () => { - test.beforeEach(async ({ admin }) => { - await admin.visitAdminPage('options-general.php'); - }); - test('Check rtSocial placement checkbox in the backend', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Test Placement checkboxes - expect(Placement.Top).not.toBeNull(); - expect(Placement.Bottom).not.toBeNull(); - }); - test(' Validate rtSocial Top placement settings with Vertical button style.', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement Top+ Alignment center - await page.locator(Placement.Top).check(); - await page.locator(Alignment.Center).check(); - // Select button Vertical - await page.locator(ButtonStyle.Vertical).check() - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.Top); - }); - test(' Validate rtSocial Bottom placement settings with Vertical button style.', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - //Select Placement bottom+ Alignment center - await page.locator(Placement.Bottom).check(); - await page.locator(Alignment.Center).check(); - // Select button Vertical - await page.locator(ButtonStyle.Vertical).check() - // Save Changes - await page.locator(SaveSetting.Button).click(); - expect(page.locator(SaveSetting.Message)).not.toBeNull(); - // Check changes in the front end - await Promise.all([ - page.click("#wp-admin-bar-site-name > a"), - ]); - // Validate Placement By checking Position is as expected - await page.focus(PlacementValidation.Bottom) - }); - -}); \ No newline at end of file diff --git a/tests/e2e/specs/validate-settings-options.spec.js b/tests/e2e/specs/validate-settings-options.spec.js deleted file mode 100644 index b005b71..0000000 --- a/tests/e2e/specs/validate-settings-options.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * WordPress dependencies - */ -const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); - -test.describe('Validate Rtsocial Settings', () => { - test.beforeEach(async ({ admin }) => { - await admin.visitAdminPage('options-general.php'); - }); - test('Check rtSocial Options', async ({ admin, page, editor }) => { - // Goto rtSocial options - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Check Placement Settings - const placementSettings = page.locator("#rtsocial-placement-settings-row > td > fieldset") - expect(placementSettings).not.toBeNull(); - // Check Button Style - const buttonStyle = page.locator("table[id='rtsocial-button-style-inner']") - expect(buttonStyle).not.toBeNull(); - // Check Alignment Settings - const alignmentSetting = page.locator("input[id='align_left_check']"); - expect(alignmentSetting).not.toBeNull(); - // Active Button - const activeButtons = page.locator("ul[id='rtsocial-sorter-active']"); - expect(activeButtons).not.toBeNull(); - // Validate twitter Setting - const twitterHandle = page.locator("input[id='tw_handle']"); - expect(twitterHandle).not.toBeNull(); - // Verify token - const facebookToken = page.locator("input[id='fb_access_token']"); - expect(facebookToken).not.toBeNull(); - }); -}); \ No newline at end of file diff --git a/tests/e2e/specs/validate-share-button-list.spec.js b/tests/e2e/specs/validate-share-button-list.spec.js deleted file mode 100644 index 97fa2ff..0000000 --- a/tests/e2e/specs/validate-share-button-list.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * WordPress dependencies - */ -const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); -const { SaveSetting } = require("../utils/locator.js"); - - -test.describe('Validate Social Sharing Handle Inputs', () => { - test.beforeEach(async ({ admin }) => { - await admin.visitAdminPage('options-general.php'); - }); - test(' Validate rtSocial Handle and sharing buttons', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Check active and inactive drag and drop - const src = await page.$("#rtsocial-ord-fb") - const dst = await page.$("#rtsocial-sorter-inactive"); - if (src && dst) { - const srcBound = await src.boundingBox() - const dstBound = await dst.boundingBox() - if (srcBound && dstBound) { - await page.mouse.click(srcBound.x + srcBound.width, srcBound.y + srcBound.height) - await page.mouse.down() - await page.mouse.move(srcBound.x + srcBound.width , srcBound.y + srcBound.height ) - await page.mouse.move(dstBound.x + dstBound.width , dstBound.y + dstBound.height ) - await page.mouse.down(); - } else { - throw new Error("No Element") - } - } - // Save Changes - await page.locator(SaveSetting.Button).click(); - }); - test(' Validate rtSocial Twitter Handles input', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Check input handle - await page.locator("input[name='rtsocial_plugin_options[tw_handle]']").fill("test"); - // Check related handle - await page.locator("input[name='rtsocial_plugin_options[tw_related_handle]']").fill("test"); - // Save changes - await page.locator(SaveSetting.Button).click(); - }); - - test(' Validate rtSocial Facebook Handles input', async ({ admin, page, editor }) => { - await page.locator("role=link[name='rtSocial Options'i]").click(); - // Check input handle - await page.locator("input[name='rtsocial_plugin_options[fb_access_token]']").fill("110099221"); - - // Choose one button - await page.locator("input[name='rtsocial_plugin_options[fb_style]']").nth(3).check(); - // Save changes - await page.locator(SaveSetting.Button).click(); - }); - - -}); \ No newline at end of file diff --git a/tests/e2e/utils/locator.js b/tests/e2e/utils/locator.js deleted file mode 100644 index 2a8c5b2..0000000 --- a/tests/e2e/utils/locator.js +++ /dev/null @@ -1,38 +0,0 @@ - - -const Placement = { - Top: "input[value='top']", - Bottom: "input[value='bottom']", -}; - -const ButtonStyle ={ - Vertical: "input[id='display_vertical_input']", - Horizontal: "input[id='display_horizontal_input']", - Icon: "input[id='display_icon_input']", - IconCount: "input[id='display_icon_count_input']" -} - -const Alignment ={ - Left: "input[id='align_left_check']", - Center: "input[id='align_center_check']", - Right: "input[id='align_right_check']", - None:"input[id='align_none_check']" -} - -const SaveSetting ={ - Button:"role=button[name='Save Changes'i]", - Message:"#setting-error-settings_updated", -} - -const PlacementValidation ={ - Top:"div[class='rtsocial-container rtsocial-container-align-center rtsocial-vertical']", - Bottom:"div[class='rtsocial-container rtsocial-container-align-center rtsocial-vertical']", - ButtonHorizontal:"div[class='rtsocial-container rtsocial-container-align-center rtsocial-horizontal']", - Icon:"div[class='rtsocial-container rtsocial-container-align-center rtsocial-icon']", - IconCount:"div[class='rtsocial-container rtsocial-container-align-center rtsocial-icon-count']", - LeftAligned:"div[class='rtsocial-container rtsocial-container-align-left rtsocial-icon-count']", - RightAligned:"div[class='rtsocial-container rtsocial-container-align-right rtsocial-icon-count']", -} - - -module.exports = { Placement, ButtonStyle, Alignment, SaveSetting,PlacementValidation }; \ No newline at end of file diff --git a/tests/e2e/utils/selectors.js b/tests/e2e/utils/selectors.js new file mode 100644 index 0000000..5da3f4a --- /dev/null +++ b/tests/e2e/utils/selectors.js @@ -0,0 +1,51 @@ +const selectors = { + adminBar: "#wp-admin-bar-site-name > a", + topPlacement: "input[value='top']", + bottomPlacement: "input[value='bottom']", + + verticalButtonStyle: "input[id='display_vertical_input']", + horizontalButtonStyle: "input[id='display_horizontal_input']", + iconButtonStyle: "input[id='display_icon_input']", + iconCountButtonStyle: "input[id='display_icon_count_input']", + + leftAlignment: "input[id='align_left_check']", + centerAlignment: "input[id='align_center_check']", + rightAlignment: "input[id='align_right_check']", + noneAlignment: "input[id='align_none_check']", + + buttonSaveSetting: "role=button[name='Save Changes'i]", + messageSaveSetting: "#setting-error-settings_updated", + + topValidate: "div[class='rtsocial-container rtsocial-container-align-center rtsocial-vertical']", + bottomValidate: "div[class='rtsocial-container rtsocial-container-align-center rtsocial-vertical']", + buttonHorizontalValidate: "div[class='rtsocial-container rtsocial-container-align-center rtsocial-horizontal']", + iconValidate: "div[class='rtsocial-container rtsocial-container-align-center rtsocial-icon']", + iconCountValidate: "div[class='rtsocial-container rtsocial-container-align-center rtsocial-icon-count']", + leftAlignedValidate: "div[class='rtsocial-container rtsocial-container-align-left rtsocial-icon']", + rightAlignedValidate: "div[class='rtsocial-container rtsocial-container-align-right rtsocial-icon-count']", + + placementSettingsDiv: "#rtsocial-placement-settings-row > td > fieldset", + buttonStyleDiv: "table[id='rtsocial-button-style-inner']", + activeButtonDiv: "ul[id='rtsocial-sorter-active']", + twitterHandleInput: "input[id='tw_handle']", + faceBooktokenInput: "input[id='fb_access_token']", + frontEndTwitterIcon: 'div.rtsocial-twitter-icon > div > a', + frontEndFacebookIcon: 'div.rtsocial-fb-icon-button > a', + facebookInput: "input[name='email']", + userGmail: "qartcamp@gmail.com", + userPassword: "xzBykf8zJrkeZV8S", + facebookPassword: "input[name='pass']", + facbookSubmit: "input[name='login']", + facebookShareButton: "button[name='__CONFIRM__']", + pinterestIcon: 'div.rtsocial-pinterest-horizontal-button > a', + linkedinIcon: 'div.rtsocial-linkedin-icon > div > a', + activeSrcButton: "#rtsocial-ord-fb", + inactiveDestButton: "#rtsocial-sorter-inactive", + twitterHandle:"input[name='rtsocial_plugin_options[tw_handle]']", + twitterRaltedHandle:"input[name='rtsocial_plugin_options[tw_related_handle]']", + facebookHandleToken:"input[name='rtsocial_plugin_options[fb_access_token]']", + facbookHandleCheckbox: "input[name='rtsocial_plugin_options[fb_style]']", + facebookTokenValue: "110099221", +} + +module.exports = { selectors } \ No newline at end of file