-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add POM and Update Tests Name #27
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.
+178
−234
Open
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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -21,3 +21,4 @@ Thumbs.db | |
# Other | ||
.cache | ||
.env | ||
artifacts |
This file contains 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,88 @@ | ||
const { expect } = require("@playwright/test"); | ||
const { selectors } = require('../utils/selectors') | ||
exports.MentionLinks = class MentionLinks { | ||
constructor(page) { | ||
this.page = page | ||
} | ||
// this functions is to navigate to the Mention link Setting page | ||
async navigateToSettingPage(){ | ||
await this.page.goto("./wp-admin/options-general.php?page=wp-mention-links",{waitUntil:"load"}); | ||
} | ||
|
||
// this function is used to validate all the setting is presnet on the page. | ||
async validateElements(){ | ||
// Focus and validate all the settings is present or not. | ||
await this.page.focus(selectors.userField); | ||
await this.page.focus(selectors.postCheckbox); | ||
await this.page.focus(selectors.pageCheckbox); | ||
} | ||
// this function is used to select Username | ||
async selectUsername(){ | ||
await this.page.focus(selectors.userField); | ||
await this.page.locator(selectors.userField).selectOption('username'); | ||
} | ||
// this function is used to select Displayname | ||
async selectDisplayname(){ | ||
await this.page.focus(selectors.userField); | ||
await this.page.locator(selectors.userField).selectOption('displayname'); | ||
} | ||
// this function is used to check both page and post Checkbox | ||
async checkBothPagePostCheckbox(){ | ||
await this.page.locator(selectors.postCheckbox).check(); | ||
await this.page.locator(selectors.pageCheckbox).check(); | ||
} | ||
// this functions is used to validate both post and page checkbox are checked | ||
async validateBothPostPageChecked(){ | ||
// Check for the final time the elements are saved after save button | ||
expect(await this.page.locator(selectors.postCheckbox).isChecked()).toBeTruthy(); | ||
expect(await this.page.locator(selectors.pageCheckbox).isChecked()).toBeTruthy(); | ||
} | ||
// this function is used to Save settings and verify | ||
async saveSettings(){ | ||
await this.page.locator(selectors.submitButton).click(); | ||
await this.page.focus(selectors.saveMessage); | ||
} | ||
// this function is used to check only page and uncheck post | ||
async checkOnlyPageCheckbox(){ | ||
await this.page.locator(selectors.pageCheckbox).check(); | ||
await this.page.locator(selectors.postCheckbox).uncheck(); | ||
} | ||
// this function is used to check only post and uncheck page | ||
async checkOnlyPostCheckbox(){ | ||
await this.page.locator(selectors.postCheckbox).check(); | ||
await this.page.locator(selectors.pageCheckbox).uncheck(); | ||
} | ||
// this function is used to validate checked page and unchecked post | ||
async validateOnlyPageChecked(){ | ||
expect(await this.page.locator(selectors.pageCheckbox).isChecked()).toBeTruthy(); | ||
expect(await this.page.locator(selectors.postCheckbox).isChecked()).toBeFalsy(); | ||
} | ||
// this function is used to validate checked page and unchecked post | ||
async validateOnlyPostChecked(){ | ||
expect(await this.page.locator(selectors.postCheckbox).isChecked()).toBeTruthy(); | ||
expect(await this.page.locator(selectors.pageCheckbox).isChecked()).toBeFalsy(); | ||
} | ||
// this function is used to validate Mention Element is present on the Backend | ||
async validateBackend(){ | ||
await this.page.keyboard.type(selectors.userName); | ||
await this.page.focus(selectors.backendPopover); | ||
await expect(this.page.locator(selectors.backendPopover)).toBeVisible(); | ||
await this.page.locator(selectors.backendPopover).click(); | ||
} | ||
// this fucntion is used to Publish and verify page/post | ||
async publishPagePost(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add assertion here as well to validate if the page is published. |
||
await this.page.click(selectors.publishToggle); | ||
await this.page.click(selectors.publishButton); | ||
await this.page.locator(selectors.successClass); | ||
} | ||
// this function is used to validate Mention Element is present on the Frontend | ||
async validateFrontend(){ | ||
await this.page.locator(selectors.viewButton).click(); | ||
await expect(this.page.locator(selectors.userLink).first()).not.toBeNull(); | ||
const locator = this.page.locator(selectors.userLink).first(); | ||
await expect(locator).toBeEnabled(); | ||
} | ||
|
||
|
||
|
||
} |
55 changes: 14 additions & 41 deletions
55
tests/e2e-playwright/specs/01_enable-settings-test.spec.js
This file contains 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,48 +1,21 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); | ||
|
||
const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
const { MentionLinks } = require('../page/MentionLinks.js'); | ||
test.describe('Check settings page', () => { | ||
test.beforeEach(async ({ admin }) => { | ||
await admin.visitAdminPage('options-general.php?page=wp-mention-links'); | ||
test('Perform Checking All the contents of the page is present', async ({ admin, page }) => { | ||
await admin.visitAdminPage('/'); | ||
const mentionLinkobj = new MentionLinks(page); | ||
await mentionLinkobj.navigateToSettingPage(); | ||
await mentionLinkobj.validateElements(); | ||
}); | ||
test('Perform Checking All the contents of the page is present', async ({ admin, page, editor }) => { | ||
|
||
// Focus and validate all the settings is present or not. | ||
await page.focus('#wpml_user_field_to_use'); | ||
await page.focus("label[for='posts_checkbox']"); | ||
await page.focus("label[for='pages_checkbox']") | ||
|
||
test('Perform Click option and save settings', async ({ page }) => { | ||
const mentionLinkobj = new MentionLinks(page); | ||
await mentionLinkobj.navigateToSettingPage(); | ||
await mentionLinkobj.selectUsername(); | ||
await mentionLinkobj.checkBothPagePostCheckbox(); | ||
await mentionLinkobj.saveSettings(); | ||
await mentionLinkobj.validateBothPostPageChecked(); | ||
}); | ||
test('Perform Click option and save settings', async ({ admin, page, editor }) => { | ||
// Focus | ||
await page.focus('#wpml_user_field_to_use'); | ||
// Select username | ||
await page.locator('#wpml_user_field_to_use').selectOption('username'); | ||
|
||
// Check post and pages are properly checked or not | ||
const post_check= await page.locator("label[for='posts_checkbox']").isChecked(); | ||
const page_check = await page.locator("label[for='pages_checkbox']").isChecked(); | ||
//console.log(post_check, page_check); | ||
// ensure both element are checked | ||
if ( post_check == false){ | ||
await page.locator("label[for='posts_checkbox']").check(); | ||
} | ||
|
||
|
||
if (page_check == false) { | ||
await page.locator("label[for='pages_checkbox']").check(); | ||
} | ||
|
||
// save and verify | ||
await page.locator("input[id='submit']").click(); | ||
await page.focus("div[id='setting-error-settings_updated']"); | ||
|
||
// Check for the final time the elements are saved after save button | ||
expect(await page.locator("label[for='posts_checkbox']").isChecked()).toBeTruthy(); | ||
expect(await page.locator("label[for='pages_checkbox']").isChecked()).toBeTruthy(); | ||
|
||
}); | ||
|
||
}); |
This file contains 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,58 +1,28 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); | ||
test.describe('Check page Create setting', () => { | ||
test.beforeEach(async ({ admin }) => { | ||
await admin.visitAdminPage('options-general.php?page=wp-mention-links'); | ||
}); | ||
test('Set page only setting and validate mention in both end', async ({ admin, page, editor }) => { | ||
|
||
// Focus and check element is present on the page. | ||
await page.focus('#wpml_user_field_to_use'); | ||
// Select Displayname to validate | ||
await page.locator('#wpml_user_field_to_use').selectOption('username'); | ||
|
||
// Check create new page | ||
const post_check = await page.locator("label[for='posts_checkbox']").isChecked(); | ||
const page_check = await page.locator("label[for='pages_checkbox']").isChecked(); | ||
//console.log(post_check, page_check); | ||
// ensure both element are checked | ||
if (page_check == false) { | ||
await page.locator("label[for='pages_checkbox']").check(); | ||
} | ||
const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
const { MentionLinks } = require('../page/MentionLinks.js'); | ||
|
||
if (post_check == true) { | ||
await page.locator("label[for='posts_checkbox']").uncheck(); | ||
} | ||
// save and verify | ||
await page.locator("input[id='submit']").click(); | ||
await page.focus("div[id='setting-error-settings_updated']"); | ||
|
||
// Check for the final time the elements are saved after save button | ||
expect(await page.locator("label[for='pages_checkbox']").isChecked()).toBeTruthy(); | ||
expect(await page.locator("label[for='posts_checkbox']").isChecked()).toBeFalsy(); | ||
test.describe('Check page Create setting', () => { | ||
test('Set page only setting and validate mention in both end', async ({ page }) => { | ||
const mentionLinkobj = new MentionLinks(page); | ||
await mentionLinkobj.navigateToSettingPage(); | ||
await mentionLinkobj.selectUsername(); | ||
await mentionLinkobj.checkOnlyPageCheckbox(); | ||
await mentionLinkobj.saveSettings(); | ||
await mentionLinkobj.validateOnlyPageChecked(); | ||
}); | ||
test('Create a new page and check UserName', async ({ admin, page, editor }) => { | ||
// Create new post page | ||
const mentionLinkobj = new MentionLinks(page); | ||
// Create new page | ||
await admin.createNewPost({ postType: 'page', title: 'Dummy page' }) | ||
// Click on paragraph block | ||
await editor.insertBlock({ | ||
name: "core/paragraph", | ||
}); | ||
// Validate backend | ||
await page.keyboard.type("@automation"); | ||
await page.focus('div.popover-slot > div'); | ||
await page.locator('div.popover-slot > div').click(); | ||
//Validate frontend | ||
// pusblish | ||
await page.click(".editor-post-publish-panel__toggle"); | ||
// Double check, click again on publish button | ||
await page.click(".editor-post-publish-button"); | ||
// A success notice should show up | ||
page.locator(".components-snackbar"); | ||
|
||
await page.locator("a[class='components-button is-primary']").click(); | ||
await expect(page.locator("role=link[name='automation']").first()).not.toBeNull(); | ||
await mentionLinkobj.validateBackend(); | ||
await mentionLinkobj.publishPagePost(); | ||
await mentionLinkobj.validateFrontend(); | ||
}); | ||
}); |
62 changes: 14 additions & 48 deletions
62
tests/e2e-playwright/specs/03_page-displayname-test.spec.js
This file contains 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,61 +1,27 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require('@wordpress/e2e-test-utils-playwright'); | ||
const { test } = require('@wordpress/e2e-test-utils-playwright'); | ||
const { MentionLinks } = require('../page/MentionLinks.js'); | ||
test.describe('Check page Create setting', () => { | ||
test.beforeEach(async ({ admin }) => { | ||
await admin.visitAdminPage('options-general.php?page=wp-mention-links'); | ||
}); | ||
test('Set page only setting and validate mention in both end', async ({ admin, page, editor }) => { | ||
|
||
// Focus and check element is present on the page. | ||
await page.focus('#wpml_user_field_to_use'); | ||
// Select Displayname to validate | ||
await page.locator('#wpml_user_field_to_use').selectOption('displayname'); | ||
|
||
// Check create new page | ||
const post_check = await page.locator("label[for='posts_checkbox']").isChecked(); | ||
const page_check = await page.locator("label[for='pages_checkbox']").isChecked(); | ||
//console.log(post_check, page_check); | ||
// ensure both element are checked | ||
if (page_check == false) { | ||
await page.locator("label[for='pages_checkbox']").check(); | ||
} | ||
|
||
if (post_check == true) { | ||
await page.locator("label[for='posts_checkbox']").uncheck(); | ||
} | ||
|
||
// save and verify | ||
await page.locator("input[id='submit']").click(); | ||
await page.focus("div[id='setting-error-settings_updated']"); | ||
|
||
// Check for the final time the elements are saved after save button | ||
expect(await page.locator("label[for='pages_checkbox']").isChecked()).toBeTruthy(); | ||
expect(await page.locator("label[for='posts_checkbox']").isChecked()).toBeFalsy(); | ||
test('Set page only setting and validate mention in both end', async ({ page }) => { | ||
const mentionLinkobj = new MentionLinks(page); | ||
await mentionLinkobj.navigateToSettingPage(); | ||
await mentionLinkobj.selectDisplayname(); | ||
await mentionLinkobj.checkOnlyPageCheckbox(); | ||
await mentionLinkobj.saveSettings(); | ||
await mentionLinkobj.validateOnlyPageChecked(); | ||
}); | ||
test('Create a new page and check DisplayName', async ({ admin, page, editor }) => { | ||
// Create new post page | ||
const mentionLinkobj = new MentionLinks(page); | ||
// Create new page | ||
await admin.createNewPost({ postType: 'page', title: 'Dummy page' }) | ||
// Click on paragraph block | ||
await editor.insertBlock({ | ||
name: "core/paragraph", | ||
}); | ||
// Validate backend | ||
await page.keyboard.type("@automation"); | ||
await page.focus('div.popover-slot > div'); | ||
await page.locator('div.popover-slot > div').click(); | ||
//Validate frontend | ||
// pusblish | ||
await page.click(".editor-post-publish-panel__toggle"); | ||
// Double check, click again on publish button | ||
await page.click(".editor-post-publish-button"); | ||
// A success notice should show up | ||
page.locator(".components-snackbar"); | ||
|
||
await page.locator("a[class='components-button is-primary']").click(); | ||
await expect(page.locator("role=link[name='automation']").first()).not.toBeNull(); | ||
const locator = page.locator("role=link[name='automation']").first() | ||
await expect(locator).toBeEnabled(); | ||
await mentionLinkobj.validateBackend(); | ||
await mentionLinkobj.publishPagePost(); | ||
await mentionLinkobj.validateFrontend(); | ||
}); | ||
}); |
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 assertion here and validate whether the settings are saved.