Closes #925 [Smoke test] Test should be able to delete plugin successfully#231
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds smoke tests for verifying BackWPup plugin deletion by introducing step definitions and feature scenarios, and extends onboarding steps with backup frequency controls and job card assertions.
- Introduced new Cucumber steps to delete and assert deletion of BackWPup plugin.
- Added new feature file
delete-plugin.featureoutlining scenarios for plugin deletion. - Enhanced
onboarding.tswith backup frequency configuration and job card visibility steps.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/backwpup/steps/onboarding.ts | Added steps for setting backup frequencies and asserting job card visibility |
| src/backwpup/steps/delete.ts | Added step to assert plugin deletion success |
| src/backwpup/delete-plugin.feature | New feature file with plugin deletion test scenarios |
Comments suppressed due to low confidence (2)
src/backwpup/steps/onboarding.ts:75
- This doc comment is incomplete; consider updating it to clearly describe the purpose of the 'I should see {string} job cards' step, e.g., 'Verifies visibility of job cards for the given data type'.
* See data type in
src/backwpup/steps/delete.ts:18
- [nitpick] To make this step reusable for other plugins, consider parameterizing the plugin slug, e.g.,
When('I delete {string} plugin', ...), so you don't need separate definitions for each plugin.
When('I delete backwpup plugin', async function (this: ICustomWorld) {
| if(dataType === 'files') { | ||
| await expect(this.page.locator('div.backwpup-job-files')).toBeVisible(); | ||
| } | ||
|
|
||
| if(dataType === 'database') { | ||
| await expect(this.page.locator('div.backwpup-job-database')).toBeVisible(); | ||
| } | ||
|
|
||
| if(dataType === 'both') { | ||
| await expect(this.page.locator('div.backwpup-job-database')).toBeVisible(); | ||
| await expect(this.page.locator('div.backwpup-job-files')).toBeVisible(); | ||
| } | ||
|
|
||
| if(dataType === 'mixed') { | ||
| await expect(this.page.locator('div.backwpup-job-mixed')).toBeVisible(); | ||
| } |
There was a problem hiding this comment.
[nitpick] The series of if statements for different data types can be refactored into a mapping between dataType values and selectors to reduce duplication and improve maintainability.
| if(dataType === 'files') { | |
| await expect(this.page.locator('div.backwpup-job-files')).toBeVisible(); | |
| } | |
| if(dataType === 'database') { | |
| await expect(this.page.locator('div.backwpup-job-database')).toBeVisible(); | |
| } | |
| if(dataType === 'both') { | |
| await expect(this.page.locator('div.backwpup-job-database')).toBeVisible(); | |
| await expect(this.page.locator('div.backwpup-job-files')).toBeVisible(); | |
| } | |
| if(dataType === 'mixed') { | |
| await expect(this.page.locator('div.backwpup-job-mixed')).toBeVisible(); | |
| } | |
| const jobCardSelectors = { | |
| files: ['div.backwpup-job-files'], | |
| database: ['div.backwpup-job-database'], | |
| both: ['div.backwpup-job-database', 'div.backwpup-job-files'], | |
| mixed: ['div.backwpup-job-mixed'], | |
| }; | |
| const selectors = jobCardSelectors[dataType]; | |
| if (selectors) { | |
| for (const selector of selectors) { | |
| await expect(this.page.locator(selector)).toBeVisible(); | |
| } | |
| } else { | |
| throw new Error(`Unsupported dataType: ${dataType}`); | |
| } |
| await this.page.locator('button[data-content="frequency"][data-job-id="2"]').click(); | ||
| await this.page.selectOption('select[name="frequency"]#backwpup_frequency', period); | ||
| } | ||
|
|
||
| if(dataType === 'database') { | ||
| await this.page.locator('button[data-content="frequency"][data-job-id="3"]').click(); |
There was a problem hiding this comment.
After clicking to open the advanced frequency dropdown, consider waiting for the <select> element to be visible (e.g., await this.page.waitForSelector('select#backwpup_frequency')) before calling selectOption to avoid potential flakiness.
| await this.page.locator('button[data-content="frequency"][data-job-id="2"]').click(); | |
| await this.page.selectOption('select[name="frequency"]#backwpup_frequency', period); | |
| } | |
| if(dataType === 'database') { | |
| await this.page.locator('button[data-content="frequency"][data-job-id="3"]').click(); | |
| await this.page.locator('button[data-content="frequency"][data-job-id="2"]').click(); | |
| await this.page.waitForSelector('select[name="frequency"]#backwpup_frequency', { state: 'visible', timeout: 10000 }); | |
| await this.page.selectOption('select[name="frequency"]#backwpup_frequency', period); | |
| } | |
| if(dataType === 'database') { | |
| await this.page.locator('button[data-content="frequency"][data-job-id="3"]').click(); | |
| await this.page.waitForSelector('select[name="frequency"]#backwpup_frequency', { state: 'visible', timeout: 10000 }); |
Co-authored-by: Michael Lee <38788055+jeawhanlee@users.noreply.github.com>
Description
Fixes 925
Type of change
Detailed scenario
Check the issue.
What was tested
Tested plugin deletion in different scenarios.
How to test
Run the
node ./node_modules/@cucumber/cucumber/bin/cucumber-js -p default --tags @bwpplugindeletionto for this specific testTechnical description
Documentation
Added some scenarios to test plugin deletion
Mandatory Checklist
Code validation
Code style
Unticked items justification
n/a