-
Notifications
You must be signed in to change notification settings - Fork 27
Add POM Refactor #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alvitazwar
wants to merge
1
commit into
master
Choose a base branch
from
add/pom
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add POM Refactor #160
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| const { expect } = require("@playwright/test"); | ||
| const { selectors } = require('../utils/selectors') | ||
| const { | ||
| WP_BASE_URL, | ||
| WP_USERNAME, | ||
| WP_PASSWORD | ||
| } = require('../e2e-test-utils-playwright/src/config'); | ||
|
|
||
| exports.LoginGoogle = class LoginGoogle { | ||
| constructor(page) { | ||
| this.page = page; | ||
| } | ||
|
|
||
| // this function is used to navigate to Settings page | ||
| async navigateToSettings(){ | ||
| await this.page.goto("./wp-admin/options-general.php?page=login-with-google", { waitUntil: "load" }); | ||
| } | ||
| // this function is used to validate setting's page Heading | ||
| async validateHeading(){ | ||
| await expect(this.page.locator(selectors.settingsHeader)).toHaveText(selectors.settingsHeading); | ||
| } | ||
| // 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 add proper secret and ID | ||
| async setIdSecret(){ | ||
| await this.page.click(selectors.clientIdInput, { clickCount: 3 }) | ||
| await this.page.keyboard.press('Backspace') | ||
| await this.page.type(selectors.clientIdInput,selectors.clientIdValue) | ||
| await this.page.waitForTimeout(1000) | ||
| await this.page.click(selectors.clientSecretInput, { clickCount: 3 }) | ||
| await this.page.keyboard.press('Backspace') | ||
| await this.page.type(selectors.clientSecretInput,selectors.clientSecretValue) | ||
| } | ||
| // this function is used to validate Login with google block is present in the editor | ||
| async validateBlock(){ | ||
| await this.page.type(selectors.titleInput,selectors.titleValue); | ||
| await this.page.click(selectors.addBlockButton); | ||
| await this.page.type(selectors.searchInput,selectors.searchInputValue); | ||
| expect(this.page.locator(selectors.validateOption)).not.toBe(null); | ||
| } | ||
| // this function is used to add Login with google block after validate Block | ||
| async addLoginGoogleBlock(){ | ||
| await this.page.click(selectors.validateOption); | ||
| await this.page.type(selectors.loginGoogleDiv,selectors.searchInputValue); | ||
| } | ||
| // this function is used to validate login with google component on the frontend after adding the google block | ||
| async validateLoginBlockFrontend(){ | ||
| await this.page.click(selectors.logoutCheckbox); | ||
| await this.page.click(selectors.publishPanel); | ||
| await this.page.click(selectors.publishButton); | ||
| await this.page.focus(selectors.viewPostButton); | ||
| await this.page.locator(selectors.viewPostButton).click(); | ||
| await this.page.waitForTimeout(1000); | ||
| await expect(this.page.locator(selectors.frontendLoginButton)).toHaveText("Log out"); | ||
| } | ||
| // this function is used to validate disable button on the frontend | ||
| async validateDisableButtonFrontend(){ | ||
| await this.page.locator(selectors.logoutCheckbox).uncheck(); | ||
| await this.page.click(selectors.publishPanel); | ||
| await this.page.click(selectors.publishButton); | ||
| await this.page.click(selectors.viewPostButton); | ||
| await this.page.waitForTimeout(1000); | ||
| await expect(this.page.locator(selectors.frontendLoginButton)).toBeHidden(); | ||
| } | ||
| // this function is used for logout | ||
| async logOut(){ | ||
| await this.page.hover(selectors.wpAdminBar); | ||
| await this.page.click(selectors.wpLogout); | ||
| } | ||
| // this function is used to validate login with google button after logout | ||
| async validateButtonAfterLogout(){ | ||
| await this.page.goto('/wp-admin/', { waitUntil: "load" }); | ||
| await this.page.waitForTimeout(1000); | ||
| expect(this.page.locator(selectors.wpGoogleLogin)).not.toBe(null); | ||
| } | ||
| // this function is used to disable new user registration | ||
| async disableUserReg(){ | ||
| await this.page.locator(selectors.userRegistration).uncheck(); | ||
| expect(await this.page.locator(selectors.userRegistration).isChecked()).toBeFalsy(); | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
15 changes: 5 additions & 10 deletions
15
tests/e2e-playwright/specs/01_validate-settings-test.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,14 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
|
|
||
| test.describe("Validate the login with google settings", () => { | ||
| test("should be able to validate the settings", async ({ page, admin }) => { | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await admin.visitAdminPage("/"); | ||
|
|
||
| await page.hover('role=link[name="Settings"i]'); | ||
|
|
||
| await page.click('role=link[name="Login with Google"i]'); | ||
|
|
||
| await page.waitForTimeout(1000); | ||
| expect(page.locator("form[action='options.php'] h2")).toHaveText( | ||
| "Log in with Google Settings" | ||
| ); | ||
| await loginGoogleobj.navigateToSettings(); | ||
| await loginGoogleobj.validateHeading(); | ||
| }); | ||
| }); |
35 changes: 9 additions & 26 deletions
35
tests/e2e-playwright/specs/02_validate-clientid-secret-test.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,16 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require('@wordpress/e2e-test-utils-playwright') | ||
| const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
| const { selectors } = require('../utils/selectors.js'); | ||
|
|
||
| test.describe('Add Client ID and secrete in settings', () => { | ||
| test('should be able to add the ID and secrete', async ({ page, admin }) => { | ||
| await admin.visitAdminPage('/') | ||
|
|
||
| await page.hover('role=link[name="Settings"i]') | ||
|
|
||
| await page.click('role=link[name="Login with Google"i]') | ||
|
|
||
| expect(page.locator("form[action='options.php'] h2")).toHaveText( | ||
| 'Log in with Google Settings' | ||
| ) | ||
|
|
||
| await page.click('#client-id', { clickCount: 3 }) | ||
| await page.keyboard.press('Backspace') | ||
| await page.type( | ||
| '#client-id', | ||
| '278082871881-qp9srgor0iqvl1aq200ctf1sdb49bli1.apps.googleusercontent.com' | ||
| ) | ||
|
|
||
| await page.waitForTimeout(1000) | ||
|
|
||
| await page.click('#client-secret', { clickCount: 3 }) | ||
| await page.keyboard.press('Backspace') | ||
| await page.type('#client-secret', 'Y3O4gbY4JnateqAj10GxL_6t') | ||
|
|
||
| await page.click('#submit') | ||
| test('should be able to add the ID and secrete', async ({ page }) => { | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await loginGoogleobj.navigateToSettings(); | ||
| await loginGoogleobj.validateHeading(); | ||
| await loginGoogleobj.setIdSecret(); | ||
| await loginGoogleobj.saveSetting(); | ||
| }) | ||
| }) |
15 changes: 4 additions & 11 deletions
15
tests/e2e-playwright/specs/03_validate-loginwithgoogle-block.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,13 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { test } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
|
|
||
| test.describe("Validate the login with google block ", () => { | ||
| test("Login with google block should be present", async ({ page, admin }) => { | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await admin.createNewPost(); | ||
|
|
||
| await page.type("h1[aria-label='Add title']", "Test block"); | ||
|
|
||
| await page.click('role=button[name="Add block"i]'); | ||
|
|
||
| await page.type("#components-search-control-0", "Login with google"); | ||
|
|
||
| expect(page.locator("role=option[name=/Log in with Google/i]")).not.toBe( | ||
| null | ||
| ); | ||
| await loginGoogleobj.validateBlock(); | ||
| }); | ||
| }); |
23 changes: 5 additions & 18 deletions
23
tests/e2e-playwright/specs/04_Add_loginwithgoogle-block.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,15 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
|
|
||
| test.describe("Add login with google block ", () => { | ||
| test("Should be able to add the login with google block", async ({ page, admin }) => { | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await admin.createNewPost(); | ||
|
|
||
| await page.type("h1[aria-label='Add title']", "Test block"); | ||
|
|
||
| await page.click('role=button[name="Add block"i]'); | ||
|
|
||
| await page.type("#components-search-control-0", "Login with google"); | ||
|
|
||
| expect(page.locator("role=option[name=/Log in with Google/i]")).not.toBe( | ||
| null | ||
| ); | ||
|
|
||
| await page.click( "role=option[name=/Log in with Google/i]" ); | ||
|
|
||
| await page.type( "div[aria-label='Log in with Google']", "Login with google" ); | ||
|
|
||
| await loginGoogleobj.validateBlock(); | ||
| await loginGoogleobj.addLoginGoogleBlock(); | ||
| }); | ||
|
|
||
|
|
||
| }); | ||
|
|
43 changes: 7 additions & 36 deletions
43
tests/e2e-playwright/specs/05_enable-logoutbutton-test.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,15 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
|
|
||
| test.describe("Enable the logout button", () => { | ||
| test("Should be able to view the logout button", async ({ page, admin }) => { | ||
| test("Should be able to view the logout button on the frontend", async ({ page, admin }) => { | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await admin.createNewPost(); | ||
|
|
||
| await page.type("h1[aria-label='Add title']", "Test block"); | ||
|
|
||
| await page.click('role=button[name="Add block"i]'); | ||
|
|
||
| await page.type("#components-search-control-0", "Login with google"); | ||
|
|
||
| expect(page.locator("role=option[name=/Log in with Google/i]")).not.toBe( | ||
| null | ||
| ); | ||
|
|
||
| await page.click("role=option[name=/Log in with Google/i]"); | ||
|
|
||
| await page.type( | ||
| "div[aria-label='Log in with Google']", | ||
| "Login with google" | ||
| ); | ||
|
|
||
| await page.click('role=checkbox[name="Display Logout"i]'); | ||
|
|
||
| await page.click( | ||
| ".components-button.block-editor-post-preview__button-toggle.components-dropdown-menu__toggle.is-tertiary" | ||
| ); | ||
|
|
||
| //Click on publish button | ||
| await page.click(".editor-post-publish-panel__toggle"); | ||
|
|
||
| //Double check, click again on publish button | ||
| await page.click(".editor-post-publish-button"); | ||
|
|
||
| await page.click('[aria-label="Editor publish"] >> text=View Post'); | ||
|
|
||
| await page.waitForTimeout(1000); | ||
| expect(page.locator(".wp_google_login__button")).toHaveText("Log out"); | ||
| await loginGoogleobj.validateBlock(); | ||
| await loginGoogleobj.addLoginGoogleBlock(); | ||
| await loginGoogleobj.validateLoginBlockFrontend(); | ||
| }); | ||
| }); |
42 changes: 6 additions & 36 deletions
42
tests/e2e-playwright/specs/06_disable_logoutbutton-test.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,16 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
|
|
||
| test.describe("Disable the logout button", () => { | ||
| test("Logout button should not be visible", async ({ page, admin }) => { | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await admin.createNewPost(); | ||
|
|
||
| await page.type("h1[aria-label='Add title']", "Test block"); | ||
|
|
||
| await page.click('role=button[name="Add block"i]'); | ||
|
|
||
| await page.type("#components-search-control-0", "Login with google"); | ||
|
|
||
| expect(page.locator("role=option[name=/Log in with Google/i]")).not.toBe( | ||
| null | ||
| ); | ||
|
|
||
| await page.click("role=option[name=/Log in with Google/i]"); | ||
|
|
||
| await page.type( | ||
| "div[aria-label='Log in with Google']", | ||
| "Login with google" | ||
| ); | ||
|
|
||
| await page.locator('role=checkbox[name="Display Logout"i]').uncheck(); | ||
|
|
||
| await page.click( | ||
| ".components-button.block-editor-post-preview__button-toggle.components-dropdown-menu__toggle.is-tertiary" | ||
| ); | ||
|
|
||
| //Click on publish button | ||
| await page.click(".editor-post-publish-panel__toggle"); | ||
|
|
||
| //Double check, click again on publish button | ||
| await page.click(".editor-post-publish-button"); | ||
|
|
||
| await page.click('[aria-label="Editor publish"] >> text=View Post'); | ||
|
|
||
| await page.waitForTimeout(1000); | ||
|
|
||
| expect(page.locator(".wp_google_login__button")).not.toBeVisible(); | ||
| await loginGoogleobj.validateBlock(); | ||
| await loginGoogleobj.addLoginGoogleBlock(); | ||
| await loginGoogleobj.validateDisableButtonFrontend(); | ||
| }); | ||
| }); | ||
|
|
23 changes: 6 additions & 17 deletions
23
tests/e2e-playwright/specs/07_check-login-with-googlebtn-test.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,14 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| const { test, expect } = require("@wordpress/e2e-test-utils-playwright"); | ||
| const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
| const { LoginGoogle } = require('../page/LoginGoogle.js'); | ||
|
|
||
| test.describe("Check the login with google button", () => { | ||
|
|
||
| test("should be able validate login with google button", async ({ page, admin }) => { | ||
| await admin.visitAdminPage("/"); | ||
|
|
||
| // Hover on profile icon. | ||
| await page.hover( '#wp-admin-bar-my-account' ); | ||
|
|
||
| // Click on logout button. | ||
| await page.click( '#wp-admin-bar-logout' ); | ||
|
|
||
| await page.waitForTimeout(1000); | ||
| expect(page.locator( '.message' )).toHaveText( 'You are now logged out.' ); | ||
|
|
||
| expect( page.locator( '.wp_google_login' ) ).not.toBe(null); | ||
|
|
||
|
|
||
| test("should be able validate login with google button", async ({ page,context }) => { | ||
| await context.clearCookies(); | ||
| const loginGoogleobj = new LoginGoogle(page); | ||
| await loginGoogleobj.validateButtonAfterLogout(); | ||
| }); | ||
| }); | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvitazwar
Add the assertions for this function. Validate whether the block is added successfully.