-
Notifications
You must be signed in to change notification settings - Fork 146
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
[Automation] WPUF-lite: e2e testing for Login, Setup, PostForms and RegistrationForms #1365
base: develop
Are you sure you want to change the base?
[Automation] WPUF-lite: e2e testing for Login, Setup, PostForms and RegistrationForms #1365
Conversation
…wp-user-frontend into automation/wpuf-e2e-pw
WalkthroughThis update introduces a comprehensive set of end-to-end tests for a WordPress application using Playwright. Key enhancements include automated testing for login, post forms, registration forms, and subscription functionalities, streamlining the testing process. New configuration files and utility scripts support improved management of test data and environment setup, ensuring that the application remains functional and reliable after changes. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant System
participant Database
User->>System: Starts E2E tests
System->>Database: Initialize state
System->>User: Begin login test
User->>System: Submit login credentials
System->>Database: Validate credentials
Database-->>System: Return success/failure
System-->>User: Display dashboard or error
User->>System: Conduct post forms tests
System->>Database: Create and validate forms
Database-->>System: Return form status
System->>User: Show form results
User->>System: Finish tests
System-->>User: Test summary report
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 45
Outside diff range, codebase verification and nitpick comments (37)
tests/e2e/tests/resetWordpressSite.spec.ts (3)
8-8
: Consider renaming the function for clarity.The function name
resetWordpressSite
might be misleading as it does not directly reset the site but rather contains tests related to resetting. Consider renaming it to something liketestResetWordpressSite
for clarity.
11-11
: Add a meaningful description to the test suite.The test suite description
'TEST :-->'
is not informative. Consider providing a more descriptive name that reflects the purpose of the tests, such as'Reset Local WordPress Site Tests'
.- test.describe('TEST :-->', () => { + test.describe('Reset Local WordPress Site Tests', () => {
13-13
: Ensure test names are descriptive.The test name
'0000:[Reset Local Site] Resetting Local Site'
could be simplified and made more descriptive. Consider using a name like'should reset the local WordPress site successfully'
.- test('0000:[Reset Local Site] Resetting Local Site', async ({ page }) => { + test('should reset the local WordPress site successfully', async ({ page }) => {tests/e2e/pages/basicLogout.ts (1)
23-23
: Use a logging library instead ofconsole.log
.Consider using a logging library for better control over log levels and outputs, especially in a testing environment.
tests/e2e/pages/base.ts (1)
5-5
: Consider renaming the class for clarity.The class name
base
is too generic. Consider renaming it to something more descriptive, likeBasePage
, to better reflect its purpose.- export class base { + export class BasePage {tests/e2e/pages/subscriptionFrontEnd (1)
44-44
: Reminder: Rework this page.The TODO comment indicates that the entire page needs reworking. Ensure that the necessary updates are made to align with the current requirements.
tests/e2e/README.md (3)
9-9
: Verify link fragments.Ensure that the link fragments
[Install Node.js](#install-node.js)
and[How to run tests](#how-to-run-tests)
are valid and correctly formatted.Also applies to: 16-16
Tools
Markdownlint
9-9: null
Link fragments should be valid(MD051, link-fragments)
40-40
: Specify language for code blocks.Add a language identifier to the fenced code blocks for better syntax highlighting and readability.
- ``` + ```bashAlso applies to: 46-46
Tools
Markdownlint
40-40: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
40-40: Expected: indented; Actual: fenced
Code block style(MD046, code-block-style)
54-54
: Remove trailing punctuation in headings.The heading "## Initial Setup:" should not have a trailing colon.
- ## Initial Setup: + ## Initial SetupTools
Markdownlint
54-54: Punctuation: ':'
Trailing punctuation in heading(MD026, no-trailing-punctuation)
tests/e2e/tests/registrationFormsTestsLite.spec.ts (1)
18-28
: Enhance documentation with consistent formatting.The comments provide a good overview of the test scenarios. Consider using a consistent format for test scenario descriptions to improve readability and maintainability.
tests/e2e/tests/subscription.spec.ts (2)
14-27
: Enhance documentation with consistent formatting.The comments provide a good overview of the test scenarios. Consider using a consistent format for test scenario descriptions to improve readability and maintainability.
46-47
: InitializesubscriptionPackName
with meaningful value.The
subscriptionPackName
is initialized as an empty string. Consider initializing it with a meaningful default value or directly using it after assignment..github/workflows/playwright.yml (2)
23-26
: Remove or justify commented-out code.The checkout step contains commented-out code. Ensure that it is necessary or remove it for clarity.
79-90
: Clarify or remove "Remove Later" notes.The workflow contains notes indicating certain steps should be removed later. Ensure that these steps are necessary or remove them for clarity.
tests/e2e/tests/loginAndSetupTests.spec.ts (2)
1-8
: Consider removing unused imports.The
fs
module is imported but only used once. Consider removing the import if it's not necessary elsewhere.
38-41
: Improve test description clarity.The test description could be more concise. Consider removing redundant phrases like "Here, Admin is" to improve readability.
- test('001:[Login] Here, Admin is logging into Admin-Dashboard', async ({ page }) => { + test('001:[Login] Admin logs into Admin-Dashboard', async ({ page }) => {tests/e2e/pages/postFormsFrontend.ts (1)
36-66
: Improve method documentation and error handling.Consider adding comments to explain the purpose of each step in
createPostFormFrontend
. Additionally, implement error handling to manage potential failures during form submission.tests/e2e/playwright.config.ts (1)
8-8
: Consider enabling dotenv configuration.The dotenv configuration is commented out. If environment variables are needed, ensure this line is enabled, or remove it if unnecessary.
tests/e2e/utils/testData.ts (5)
1-13
: Enhance documentation and type safety.Consider adding comments to explain the purpose of each data set and use TypeScript interfaces for better type safety.
// Example of adding comments and using interfaces interface UrlConfig { baseUrl: string; } // Main Site URL configuration let Urls: UrlConfig = { baseUrl: process.env.QA_BASE_URL ? process.env.QA_BASE_URL : 'http://localhost:8889', };
20-42
: Enhance documentation and type safety.Consider adding comments to explain the purpose of each user credential and use TypeScript interfaces for better type safety.
// Example of adding comments and using interfaces interface UserCredentials { adminUsername: string; adminPassword: string; userName: string; userEmail: string; userFirstName: string; userLastName: string; userPassword: string; } // Admin and new user credentials let Users: UserCredentials = { adminUsername: process.env.QA_ADMIN_USERNAME ? process.env.QA_ADMIN_USERNAME : 'admin', adminPassword: process.env.QA_ADMIN_PASSWORD ? process.env.QA_ADMIN_PASSWORD : 'password', // New User Credentials... };
49-71
: Enhance documentation and type safety.Consider adding comments to explain the purpose of each post form field and use TypeScript interfaces for better type safety.
// Example of adding comments and using interfaces interface PostFormConfig { pfPostName1: string; pfPostName2: string; pfPostName3: string; pfPostName4: string; pfTitle: string; pfPostDescription: string; pfExcerpt: string; pfTags: string; } // Post form configuration let PostForm: PostFormConfig = { pfPostName1: faker.lorem.sentence(2), // Other fields... };
78-105
: Enhance documentation and type safety.Consider adding comments to explain the purpose of each registration form field and use TypeScript interfaces for better type safety.
// Example of adding comments and using interfaces interface RegistrationFormConfig { rfPostName1: string; rfPostName2: string; rfPostName3: string; rfPostName4: string; rfFirstName: string; rfLastName: string; rfUsername: string; rfEmail: string; rfPassword: string; } // Registration form configuration let RegistrationForm: RegistrationFormConfig = { rfPostName1: faker.lorem.sentence(2), // Other fields... };
112-132
: Enhance documentation and type safety.Consider adding comments to explain the purpose of each subscription pack field and use TypeScript interfaces for better type safety.
// Example of adding comments and using interfaces interface SubscriptionPackConfig { subscriptionPackName: string; subscriptionPackDescription: string; SubscriptionPackPrice: string; SubscriptionPackExpiration: number; subscriptionFeaturedCount: number; } // Subscription pack configuration let SubscriptionPack: SubscriptionPackConfig = { subscriptionPackName: faker.commerce.productName(), // Other fields... };tests/e2e/utils/testData-old.ts (3)
1-2
: Use ES6 import syntax consistently.Consider using ES6 import syntax for
dotenv
to maintain consistency with the rest of the imports.- require('dotenv').config(); + import dotenv from 'dotenv'; + dotenv.config();
45-52
: Ensure consistent naming conventions.The property
SubscriptionPackPrice
uses PascalCase, while others use camelCase. Consider using camelCase for consistency.- SubscriptionPackPrice: string; + subscriptionPackPrice: string;
128-169
: Avoid hardcoding default values.Consider using environment variables or configuration files to manage default values like URLs and credentials for better flexibility and security.
tests/e2e/pages/registrationForms.ts (1)
24-44
: Improve readability and error handling.Consider using more descriptive variable names and adding error handling to improve the robustness of the test. For example, handle cases where the page might not load correctly or elements might not be found.
- const validateWPUFProActivate = await this.page.isVisible(selectors.registrationForms.navigatePage_RF.checkAddButton_RF); + const isProFeatureButtonVisible = await this.page.isVisible(selectors.registrationForms.navigatePage_RF.checkAddButton_RF); if (!isProFeatureButtonVisible) { try { const proFeaturesText = await this.page.innerText(selectors.registrationForms.validateRegistrationFormsProFeatureLite.checkProFeaturesText); await expect(proFeaturesText).toContain("Unlock PRO Features"); const upgradeToProOption = await this.page.locator(selectors.registrationForms.validateRegistrationFormsProFeatureLite.checkUpgradeToProOption); expect(upgradeToProOption).toBeTruthy(); } catch (error) { console.error("Error validating Pro features:", error); } }tests/e2e/tests/postFormsTests.spec.ts (1)
34-54
: Implement abeforeAll
setup for login.The TODO comment suggests creating a
beforeAll
setup for login to avoid repetitive login steps in each test. This will improve test efficiency and readability.// Consider adding a beforeAll hook for login test.beforeAll(async ({ page }) => { const BasicLogin = new basicLoginPage(page); await BasicLogin.basicLoginAndPluginVisit(Users.adminUsername, Users.adminPassword); });tests/e2e/pages/settingsSetup.ts (6)
48-56
: Add logging for plugin activation status.Consider adding logging to confirm the activation status of the plugin, which can be helpful for debugging.
console.log("Checking WPUF-Lite plugin status..."); await this.activateWPUFLite(); console.log("WPUF-Lite plugin status check complete.");
60-68
: Add logging for plugin activation status.Consider adding logging to confirm the activation status of the Pro plugin, which can be helpful for debugging.
console.log("Checking WPUF-Pro plugin status..."); await this.activateWPUFPro(); console.log("WPUF-Pro plugin status check complete.");
79-95
: Add descriptive logging.Consider adding descriptive logging to provide more context about the actions being performed and their outcomes.
console.log("Navigating to WPUF plugin page..."); await this.page.goto(Urls.baseUrl + '/wp-admin/', { waitUntil: 'networkidle' }); console.log("Checking for Post Form menu option..."); if (availableText) { console.log("Post Form menu option is available."); const checkText = await this.page.innerText(selectors.settingsSetup.pluginVisit.wpufPostFormCheckAddButton); await expect(checkText).toContain("Add Form"); }
99-126
: Enhance logging for activation steps.Consider enhancing logging to track each step of the plugin activation process for better traceability.
console.log("Navigating to plugins page for WPUF-Lite activation..."); await this.page.goto(pluginsPage, { waitUntil: 'networkidle' }); console.log("Checking activation status..."); if (activateWPUFLite) { console.log("Activating WPUF-Lite plugin..."); await this.page.click(selectors.settingsSetup.pluginStatusCheck.clickWPUFPluginLite); await this.page.reload(); await this.page.goBack(); await this.page.goto(Urls.baseUrl + '/wp-admin/'); await this.page.isVisible(selectors.login.basicNavigation.clickWPUFSidebar); await this.page.click(selectors.login.basicNavigation.clickWPUFSidebar); console.log("WPUF-Lite plugin activated."); } else { console.log("WPUF-Lite plugin is already activated."); }
129-151
: Enhance logging for activation steps.Consider enhancing logging to track each step of the Pro plugin activation process for better traceability.
console.log("Navigating to plugins page for WPUF-Pro activation..."); await this.page.goto(pluginsPage, { waitUntil: 'networkidle' }); console.log("Checking activation status..."); if (activateWPUFPro) { console.log("Activating WPUF-Pro plugin..."); await this.page.click(selectors.settingsSetup.pluginStatusCheck.clickWPUFPluginPro); await this.page.isVisible(selectors.login.basicNavigation.clickWPUFSidebar); await this.page.click(selectors.login.basicNavigation.clickWPUFSidebar); console.log("WPUF-Pro plugin activated."); } else { console.log("WPUF-Pro plugin is already activated."); }
163-188
: Add logging to confirm actions.Consider adding logging to confirm each action taken in the method, which can help with debugging and traceability.
console.log("Navigating to WPUF post form page..."); await this.page.goto(wpufpostformpage, { waitUntil: 'networkidle' }); console.log("Changing settings to default login page..."); await this.page.click(selectors.settingsSetup.wpufSettingsPage.settingsTab); await this.page.reload(); expect(await this.page.isVisible(selectors.settingsSetup.wpufSettingsPage.settingsTabProfile1)).toBeTruthy(); console.log("Login/Registration tab is visible."); await this.page.waitForSelector(selectors.settingsSetup.wpufSettingsPage.settingsTabProfile2); await this.page.click(selectors.settingsSetup.wpufSettingsPage.settingsTabProfile2); console.log("Setting login page to default..."); await this.page.selectOption(selectors.settingsSetup.wpufSettingsPage.settingsTabProfileLoginPage, { label: '— Select —' }); await this.page.click(selectors.settingsSetup.wpufSettingsPage.settingsTabProfileSave); console.log("Login page settings updated.");tests/e2e/pages/selectors.ts (3)
9-30
: Remove commented-out code for clarity.The commented-out line for
clickWPUFSidebar
should be removed if it is no longer needed to improve code readability.// Remove this line if not needed // clickWPUFSidebar: '//div[text()="User Frontend"]/.',
59-116
: Address or track TODO comments.There are TODO comments in this section. Ensure these are addressed or tracked in an issue tracker.
// TODO: Ensure all TODO comments are addressed or tracked
213-278
: Address or track TODO comments.There are TODO comments in this section. Ensure these are addressed or tracked in an issue tracker.
// TODO: Ensure all TODO comments are addressed or tracked
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
package-lock.json
is excluded by!**/package-lock.json
tests/e2e/package-lock.json
is excluded by!**/package-lock.json
tests/e2e/uploadeditems/sample_image.jpeg
is excluded by!**/*.jpeg
Files selected for processing (30)
- .github/workflows/playwright.yml (1 hunks)
- package.json (1 hunks)
- state.json (1 hunks)
- tests/e2e/.env-example (1 hunks)
- tests/e2e/.gitignore (1 hunks)
- tests/e2e/.wp-env.json (1 hunks)
- tests/e2e/README.md (1 hunks)
- tests/e2e/package.json (1 hunks)
- tests/e2e/pages/base.ts (1 hunks)
- tests/e2e/pages/basicLogin.ts (1 hunks)
- tests/e2e/pages/basicLogout.ts (1 hunks)
- tests/e2e/pages/fieldOptionsCommon.ts (1 hunks)
- tests/e2e/pages/postForms.ts (1 hunks)
- tests/e2e/pages/postFormsFrontend.ts (1 hunks)
- tests/e2e/pages/registrationForms.ts (1 hunks)
- tests/e2e/pages/registrationFormsFrontEnd.ts (1 hunks)
- tests/e2e/pages/selectors.ts (1 hunks)
- tests/e2e/pages/settingsSetup.ts (1 hunks)
- tests/e2e/pages/subscription.ts (1 hunks)
- tests/e2e/pages/subscriptionFrontEnd (1 hunks)
- tests/e2e/playwright.config.ts (1 hunks)
- tests/e2e/state.json (1 hunks)
- tests/e2e/tests/e2eMain.spec.ts (1 hunks)
- tests/e2e/tests/loginAndSetupTests.spec.ts (1 hunks)
- tests/e2e/tests/postFormsTests.spec.ts (1 hunks)
- tests/e2e/tests/registrationFormsTestsLite.spec.ts (1 hunks)
- tests/e2e/tests/resetWordpressSite.spec.ts (1 hunks)
- tests/e2e/tests/subscription.spec.ts (1 hunks)
- tests/e2e/utils/testData-old.ts (1 hunks)
- tests/e2e/utils/testData.ts (1 hunks)
Files skipped from review due to trivial changes (7)
- package.json
- state.json
- tests/e2e/.env-example
- tests/e2e/.gitignore
- tests/e2e/.wp-env.json
- tests/e2e/package.json
- tests/e2e/state.json
Additional context used
Markdownlint
tests/e2e/README.md
54-54: Punctuation: ':'
Trailing punctuation in heading(MD026, no-trailing-punctuation)
40-40: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
46-46: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
40-40: Expected: indented; Actual: fenced
Code block style(MD046, code-block-style)
46-46: Expected: indented; Actual: fenced
Code block style(MD046, code-block-style)
9-9: null
Link fragments should be valid(MD051, link-fragments)
16-16: null
Link fragments should be valid(MD051, link-fragments)
Biome
tests/e2e/pages/subscription.ts
[error] 13-15: This constructor is unnecessary.
Unsafe fix: Remove the unnecessary constructor.
(lint/complexity/noUselessConstructor)
Additional comments not posted (20)
tests/e2e/tests/registrationFormsTestsLite.spec.ts (4)
31-38
: LGTM!The test for checking the registration forms' pro feature page is well-implemented.
55-62
: Verify the purpose of writing tostate.json
.The test writes an empty
state.json
file. Ensure that this step is necessary and correctly implemented.
65-74
: Verify the purpose of writing tostate.json
.The test writes an empty
state.json
file. Ensure that this step is necessary and correctly implemented.
41-52
: Verify the purpose of writing tostate.json
.The test writes an empty
state.json
file. Ensure that this step is necessary and correctly implemented.tests/e2e/tests/subscription.spec.ts (3)
28-36
: LGTM!The test for creating a subscription plan is well-implemented and logs the created subscription pack name.
48-56
: LGTM!The test for creating a subscription plan is well-implemented and logs the created subscription pack name.
58-63
: LGTM!The test for updating a subscription plan for featured posts is well-implemented.
.github/workflows/playwright.yml (7)
18-21
: LGTM!The PHP setup step is correctly implemented for version 7.3.
28-30
: LGTM!The Node.js setup step is correctly implemented for version 14.x.
34-38
: LGTM!The Composer install and build step for WPUF-lite is correctly implemented.
40-44
: LGTM!The npm install and build step for WPUF-lite is correctly implemented.
47-50
: LGTM!The step for installing dependencies for the e2e tests is correctly implemented.
52-55
: LGTM!The step for installing Playwright browsers is correctly implemented.
58-115
: LGTM!The steps for setting up WordPress, running Playwright tests, publishing test reports, and archiving artifacts are correctly implemented.
tests/e2e/tests/loginAndSetupTests.spec.ts (1)
16-16
: Ensure function is invoked.The
loginAndSetupTests
function is defined but not invoked. Ensure that this is intended, or consider invoking it to execute the tests.tests/e2e/pages/postFormsFrontend.ts (1)
14-16
: Clarify data usage for post creation.The
postExcerpt
andpostTags
are being set usingRegistrationForm
data. Ensure this is intentional, as it might lead to confusion if the data sources are not aligned with their intended use.tests/e2e/playwright.config.ts (2)
29-29
: Review retry settings for CI.The retry setting is set to
0
for CI. Consider whether retries are necessary to account for potential flakiness in tests.
72-72
: Ensure storage state file is managed properly.The
storageState
is set tostate.json
. Ensure this file is correctly managed and cleaned up as needed to prevent stale state issues.tests/e2e/pages/selectors.ts (2)
491-633
: LGTM!The registrationForms section is well-structured and complete.
645-651
: LGTM!The resetWordpreseSite section is straightforward and complete.
//Logout | ||
await BasicLogout.logOut(); | ||
|
||
fs.writeFile('state.json', '{"cookies":[],"origins": []}', function () { }); |
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.
Avoid hardcoding file paths.
The file path in fs.writeFile
is hardcoded. Consider using a configuration or environment variable to specify paths, improving flexibility and maintainability.
//Function | ||
const generateFakerData = () => { | ||
//Post Form Titles | ||
const pfPostName1: string = faker.lorem.sentence(2); | ||
const pfPostName2: string = faker.lorem.sentence(2); | ||
const pfPostName3: string = faker.lorem.sentence(2); | ||
const pfPostName4: string = faker.lorem.sentence(2); | ||
//Post Form Data | ||
const pfTitle: string = faker.lorem.words(2); | ||
const pfPostDescription: string = faker.lorem.sentence(4); | ||
const pfExcerpt: string = faker.lorem.word(3); | ||
const pfTags: string = faker.lorem.word(); | ||
|
||
//-----------------------------------------------------------------// | ||
//Registration Form Titles | ||
const rfPostName1: string = faker.lorem.sentence(2); | ||
const rfPostName2: string = faker.lorem.sentence(2); | ||
const rfPostName3: string = faker.lorem.sentence(2); | ||
const rfPostName4: string = faker.lorem.sentence(2); | ||
//Registration Form Data | ||
//Generate random user details | ||
const rfFirstName: string = faker.name.firstName(); | ||
const rfLastName: string = faker.name.lastName(); | ||
const rfUsername: string = faker.internet.userName(rfFirstName, rfLastName); | ||
const rfEmail: string = faker.internet.email(rfFirstName, rfLastName); | ||
const rfPassword: string = faker.internet.password(); | ||
|
||
return { | ||
//Post Form Titles | ||
pfPostName1, | ||
pfPostName2, | ||
pfPostName3, | ||
pfPostName4, | ||
//Post Form Data | ||
pfTitle, | ||
pfPostDescription, | ||
pfExcerpt, | ||
pfTags, | ||
|
||
//Reg Form Titles | ||
rfPostName1, | ||
rfPostName2, | ||
rfPostName3, | ||
rfPostName4, | ||
//Registration Form Data | ||
rfFirstName, | ||
rfLastName, | ||
rfUsername, | ||
rfEmail, | ||
rfPassword, | ||
}; | ||
}; |
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.
Consider parameterizing faker data generation.
The generateFakerData
function could be parameterized to allow more flexible data generation, which could be useful for testing different scenarios.
const generateFakerData = (numWords: number = 2, numSentences: number = 2) => {
const pfPostName1: string = faker.lorem.sentence(numSentences);
// ... other faker data generation
};
async buy_SubscriptionPack_Basic() { | ||
|
||
} |
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.
Implement the subscription methods.
The methods buy_SubscriptionPack_Basic
, buy_SubscriptionPack_PostPageRestriction
, and createMultipleposts
are placeholders without any implementation. Consider adding the necessary logic to fulfill their intended functionalities.
Would you like assistance in drafting the implementation for these methods or opening a GitHub issue to track this task?
Also applies to: 21-23, 40-42
import postFormsTests from './postFormsTests.spec'; | ||
import registrationFormsTestsLite from './registrationFormsTestsLite.spec'; | ||
import subscriptionsTests from './subscription.spec'; | ||
import * as fs from "fs"; //Clear Cookie |
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.
Consider using Playwright's context management for cookie handling.
Using fs.writeFile
to clear cookies is unconventional. Playwright provides context management capabilities that can handle cookies more effectively. Consider using browserContext.clearCookies()
instead.
- fs.writeFile('state.json', '{"cookies":[],"origins": []}', function () { });
+ await context.clearCookies();
Also applies to: 15-15, 29-29, 34-34, 39-39
//Second tab | ||
await this.page.isVisible('//a[@href="#wpuf-post-restriction"]'); | ||
//Third tab | ||
await this.page.isVisible('//a[@href="#taxonomy-restriction""]'); |
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.
Fix syntax error in selector.
There is an extra double quote in the selector string.
- await this.page.isVisible('//a[@href="#taxonomy-restriction""]');
+ await this.page.isVisible('//a[@href="#taxonomy-restriction"]');
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
await this.page.isVisible('//a[@href="#taxonomy-restriction""]'); | |
await this.page.isVisible('//a[@href="#taxonomy-restriction"]'); |
test('0016:[Post-Forms-FE] Here, Admin is creating a Preset Post Form - with Guest Enabled', async ({ page }) => { | ||
const PostForms = new postForms(page); | ||
const FieldOptionsCommon = new fieldOptionsCommon(page); | ||
|
||
//For Front-End | ||
//Create Post Form | ||
const postFormPresetFrontendTitle = 'FE PostForm'; | ||
//Post Preset Form | ||
await PostForms.createPresetPostFormWithGuestEnabled(postFormPresetFrontendTitle); | ||
//Validate | ||
await FieldOptionsCommon.validatePostFields_PF(); | ||
await FieldOptionsCommon.validateTaxonomiesPreset_PF(); | ||
|
||
//Save | ||
await FieldOptionsCommon.saveForm_Common(postFormPresetFrontendTitle); | ||
//Validate | ||
await FieldOptionsCommon.validatePostFormCreated(postFormPresetFrontendTitle); | ||
}); |
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.
Reuse shared setup and validation logic.
This test can be improved by reusing shared setup and validation logic to reduce redundancy.
// Example of reusing shared logic
await setupPostForm(page, postFormPresetFrontendTitle);
await validatePostForm(page, postFormPresetFrontendTitle);
Committable suggestion was skipped due to low confidence.
test('0011:[Post-Forms] Admin is creating Blank Form with > Taxonomies', async ({ page }) => { | ||
const PostForms = new postForms(page); | ||
const FieldOptionsCommon = new fieldOptionsCommon(page); | ||
|
||
//Post Blank Form | ||
await PostForms.createBlankFormPostForm(PostForm.pfPostName2); | ||
//PostFields | ||
await FieldOptionsCommon.addPostFields_PF(); | ||
//Taxonomies + Validate | ||
await FieldOptionsCommon.addTaxonomies_PF(); | ||
await FieldOptionsCommon.validateTaxonomies_PF(); | ||
|
||
//Save | ||
await FieldOptionsCommon.saveForm_Common(PostForm.pfPostName2); | ||
//Validate | ||
await FieldOptionsCommon.validatePostFormCreated(PostForm.pfPostName2); | ||
}); |
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.
Reuse common setup steps.
Consider reusing common setup steps across tests to reduce redundancy and improve maintainability. Extracting shared logic into helper functions or using beforeEach
can help.
// Example of reusing setup steps
test.beforeEach(async ({ page }) => {
const PostForms = new postForms(page);
const FieldOptionsCommon = new fieldOptionsCommon(page);
await PostForms.createBlankFormPostForm(PostForm.pfPostName);
await FieldOptionsCommon.addPostFields_PF();
});
Committable suggestion was skipped due to low confidence.
test('0013:[Post-Forms] Here, Admin is creating Blank Form with > Others', async ({ page }) => { | ||
const PostForms = new postForms(page); | ||
const FieldOptionsCommon = new fieldOptionsCommon(page); | ||
|
||
|
||
//Post Blank Form | ||
await PostForms.createBlankFormPostForm(PostForm.pfPostName4); | ||
//PostFields | ||
await FieldOptionsCommon.addPostFields_PF(); | ||
//Others + Validate | ||
await FieldOptionsCommon.addOthers_Common(); | ||
await FieldOptionsCommon.validateOthers_Common(); | ||
await FieldOptionsCommon.setMultiStepSettings_Common(); | ||
|
||
//Save | ||
await FieldOptionsCommon.saveForm_Common(PostForm.pfPostName4); | ||
//Validate | ||
await FieldOptionsCommon.validatePostFormCreated(PostForm.pfPostName4); | ||
}); |
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.
Implement shared setup and teardown logic.
Consider implementing shared setup and teardown logic to improve test maintainability and reduce redundancy.
// Example of shared setup and teardown
test.beforeEach(async ({ page }) => {
await setupPostForm(page, PostForm.pfPostName);
});
test.afterEach(async ({ page }) => {
// Optional: Add teardown logic if needed
});
Committable suggestion was skipped due to low confidence.
async createNewUserAdmin(userName, email, firstName, lastName, password) { | ||
const pluginsPage = Urls.baseUrl + '/wp-admin/'; | ||
await Promise.all([ | ||
this.page.goto(pluginsPage, { waitUntil: 'networkidle' }), | ||
]); | ||
|
||
//Go to Admin-Users | ||
await this.page.click(selectors.settingsSetup.createNewUser.clickUserMenuAdmin); | ||
//Add New User | ||
await this.page.click(selectors.settingsSetup.createNewUser.clickAddNewUserAdmin); | ||
await this.page.reload(); | ||
await this.page.waitForLoadState('domcontentloaded'); | ||
|
||
//New User creation flow | ||
//Enter Username | ||
await this.page.fill(selectors.settingsSetup.createNewUser.newUserName, userName); | ||
//Enter Email | ||
await this.page.fill(selectors.settingsSetup.createNewUser.newUserEmail, email); | ||
//Enter First Name | ||
await this.page.fill(selectors.settingsSetup.createNewUser.newUserFirstName, firstName); | ||
//Enter Last Name | ||
await this.page.fill(selectors.settingsSetup.createNewUser.newUserLastName, lastName); | ||
//Enter Password | ||
await this.page.fill(selectors.settingsSetup.createNewUser.newUserPassword, password); | ||
//Allow weak Password | ||
await this.page.check(selectors.settingsSetup.createNewUser.newUserWeakPasswordAllow); | ||
//Select Role | ||
await this.page.waitForLoadState('domcontentloaded'); | ||
await expect(await this.page.isVisible(selectors.settingsSetup.createNewUser.newUserSelectRole)).toBeTruthy(); | ||
await this.page.selectOption(selectors.settingsSetup.createNewUser.newUserSelectRole, { label: 'Subscriber' }); | ||
|
||
//Create User | ||
await this.page.click(selectors.settingsSetup.createNewUser.newUserSubmit); | ||
}; |
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.
Add logging and error handling for user creation.
Consider adding logging to confirm each action taken during user creation and error handling for form submissions to improve reliability.
console.log("Navigating to admin users page...");
await this.page.goto(pluginsPage, { waitUntil: 'networkidle' });
console.log("Adding a new user...");
await this.page.click(selectors.settingsSetup.createNewUser.clickUserMenuAdmin);
await this.page.click(selectors.settingsSetup.createNewUser.clickAddNewUserAdmin);
await this.page.reload();
await this.page.waitForLoadState('domcontentloaded');
try {
console.log("Filling out new user form...");
await this.page.fill(selectors.settingsSetup.createNewUser.newUserName, userName);
await this.page.fill(selectors.settingsSetup.createNewUser.newUserEmail, email);
await this.page.fill(selectors.settingsSetup.createNewUser.newUserFirstName, firstName);
await this.page.fill(selectors.settingsSetup.createNewUser.newUserLastName, lastName);
await this.page.fill(selectors.settingsSetup.createNewUser.newUserPassword, password);
await this.page.check(selectors.settingsSetup.createNewUser.newUserWeakPasswordAllow);
await this.page.selectOption(selectors.settingsSetup.createNewUser.newUserSelectRole, { label: 'Subscriber' });
await this.page.click(selectors.settingsSetup.createNewUser.newUserSubmit);
console.log("New user created successfully.");
} catch (error) {
console.error("Error during new user creation:", error);
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async createNewUserAdmin(userName, email, firstName, lastName, password) { | |
const pluginsPage = Urls.baseUrl + '/wp-admin/'; | |
await Promise.all([ | |
this.page.goto(pluginsPage, { waitUntil: 'networkidle' }), | |
]); | |
//Go to Admin-Users | |
await this.page.click(selectors.settingsSetup.createNewUser.clickUserMenuAdmin); | |
//Add New User | |
await this.page.click(selectors.settingsSetup.createNewUser.clickAddNewUserAdmin); | |
await this.page.reload(); | |
await this.page.waitForLoadState('domcontentloaded'); | |
//New User creation flow | |
//Enter Username | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserName, userName); | |
//Enter Email | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserEmail, email); | |
//Enter First Name | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserFirstName, firstName); | |
//Enter Last Name | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserLastName, lastName); | |
//Enter Password | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserPassword, password); | |
//Allow weak Password | |
await this.page.check(selectors.settingsSetup.createNewUser.newUserWeakPasswordAllow); | |
//Select Role | |
await this.page.waitForLoadState('domcontentloaded'); | |
await expect(await this.page.isVisible(selectors.settingsSetup.createNewUser.newUserSelectRole)).toBeTruthy(); | |
await this.page.selectOption(selectors.settingsSetup.createNewUser.newUserSelectRole, { label: 'Subscriber' }); | |
//Create User | |
await this.page.click(selectors.settingsSetup.createNewUser.newUserSubmit); | |
}; | |
async createNewUserAdmin(userName, email, firstName, lastName, password) { | |
const pluginsPage = Urls.baseUrl + '/wp-admin/'; | |
console.log("Navigating to admin users page..."); | |
await Promise.all([ | |
this.page.goto(pluginsPage, { waitUntil: 'networkidle' }), | |
]); | |
//Go to Admin-Users | |
console.log("Adding a new user..."); | |
await this.page.click(selectors.settingsSetup.createNewUser.clickUserMenuAdmin); | |
await this.page.click(selectors.settingsSetup.createNewUser.clickAddNewUserAdmin); | |
await this.page.reload(); | |
await this.page.waitForLoadState('domcontentloaded'); | |
try { | |
//New User creation flow | |
console.log("Filling out new user form..."); | |
//Enter Username | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserName, userName); | |
//Enter Email | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserEmail, email); | |
//Enter First Name | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserFirstName, firstName); | |
//Enter Last Name | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserLastName, lastName); | |
//Enter Password | |
await this.page.fill(selectors.settingsSetup.createNewUser.newUserPassword, password); | |
//Allow weak Password | |
await this.page.check(selectors.settingsSetup.createNewUser.newUserWeakPasswordAllow); | |
//Select Role | |
await this.page.selectOption(selectors.settingsSetup.createNewUser.newUserSelectRole, { label: 'Subscriber' }); | |
//Create User | |
await this.page.click(selectors.settingsSetup.createNewUser.newUserSubmit); | |
console.log("New user created successfully."); | |
} catch (error) { | |
console.error("Error during new user creation:", error); | |
} | |
}; |
async wpufSetup() { | ||
//WPUF Setup | ||
const wpufSetupPage = Urls.baseUrl + '/wp-admin/index.php?page=wpuf-setup'; | ||
await Promise.all([ | ||
this.page.goto(wpufSetupPage, { waitUntil: 'networkidle' }), | ||
]); | ||
|
||
const wpufSetup = await this.page.isVisible(selectors.settingsSetup.wpufSetup.validateWPUFSetupPage); | ||
if (wpufSetup == true) { | ||
//await this.page.click(SelectorsPage.settingsSetup.clickWPUFSetupSkip); | ||
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupLetsGo); | ||
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupContinue); | ||
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupEnd); | ||
} | ||
|
||
}; |
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.
Add error handling and logging.
Consider adding error handling and logging for each setup step to improve debugging and reliability.
try {
const wpufSetup = await this.page.isVisible(selectors.settingsSetup.wpufSetup.validateWPUFSetupPage);
if (wpufSetup) {
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupLetsGo);
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupContinue);
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupEnd);
}
} catch (error) {
console.error("Error during WPUF setup:", error);
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async wpufSetup() { | |
//WPUF Setup | |
const wpufSetupPage = Urls.baseUrl + '/wp-admin/index.php?page=wpuf-setup'; | |
await Promise.all([ | |
this.page.goto(wpufSetupPage, { waitUntil: 'networkidle' }), | |
]); | |
const wpufSetup = await this.page.isVisible(selectors.settingsSetup.wpufSetup.validateWPUFSetupPage); | |
if (wpufSetup == true) { | |
//await this.page.click(SelectorsPage.settingsSetup.clickWPUFSetupSkip); | |
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupLetsGo); | |
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupContinue); | |
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupEnd); | |
} | |
}; | |
async wpufSetup() { | |
//WPUF Setup | |
const wpufSetupPage = Urls.baseUrl + '/wp-admin/index.php?page=wpuf-setup'; | |
await Promise.all([ | |
this.page.goto(wpufSetupPage, { waitUntil: 'networkidle' }), | |
]); | |
try { | |
const wpufSetup = await this.page.isVisible(selectors.settingsSetup.wpufSetup.validateWPUFSetupPage); | |
if (wpufSetup) { | |
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupLetsGo); | |
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupContinue); | |
await this.page.click(selectors.settingsSetup.wpufSetup.clickWPUFSetupEnd); | |
} | |
} catch (error) { | |
console.error("Error during WPUF setup:", error); | |
} | |
}; |
Description:
This Automation Test suite covers basic test scenarios for Login, Setup, PostForms and RegistrationForms-with-shortcode
Test Suite:
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Chores