-
Notifications
You must be signed in to change notification settings - Fork 3
Migrate to playwright for e2e testing #394
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
circlecube
wants to merge
4
commits into
main
Choose a base branch
from
update/playwright-tests
base: main
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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,35 @@ | ||
| name: Build and Test Module Updates in Brand Plugins (Playwright tests) | ||
| on: | ||
| pull_request: | ||
| types: [ opened, reopened, ready_for_review, synchronize ] | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| setup: | ||
| name: Setup | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| branch: ${{ steps.extract_branch.outputs.branch }} | ||
| steps: | ||
|
|
||
| - name: Extract branch name | ||
| shell: bash | ||
| run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | ||
| id: extract_branch | ||
|
|
||
| bluehost: | ||
| name: Bluehost Build and Test Playwright | ||
| needs: setup | ||
| uses: newfold-labs/workflows/.github/workflows/module-plugin-test-playwright.yml@add/playwright-module-test | ||
| with: | ||
| module-repo: ${{ github.repository }} | ||
| module-branch: ${{ needs.setup.outputs.branch }} | ||
| plugin-repo: 'newfold-labs/wp-plugin-bluehost' | ||
| secrets: inherit | ||
|
|
||
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
This file was deleted.
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,71 @@ | ||
| const { test, expect } = require('@playwright/test'); | ||
| const path = require('path'); | ||
|
|
||
| // Use environment variable to resolve plugin helpers | ||
| const pluginDir = process.env.PLUGIN_DIR || path.resolve(__dirname, '../../../../../../'); | ||
| const { auth } = require(path.join(pluginDir, 'tests/playwright/helpers')); | ||
|
|
||
| test.describe('WonderBlocks', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| // Login to WordPress | ||
| await auth.loginToWordPress(page); | ||
|
|
||
| // Navigate to new post page | ||
| await page.goto('/wp-admin/post-new.php'); | ||
|
|
||
| // Wait for page to load | ||
| await page.waitForLoadState('domcontentloaded'); | ||
| }); | ||
|
|
||
| test('WonderBlocks button present and modal functions', async ({ page }) => { | ||
| // Verify toolbar button exists | ||
| const toolbarButton = page.locator('#nfd-wba-toolbar-button'); | ||
| await expect(toolbarButton).toBeVisible(); | ||
|
|
||
| // Wait a bit for initialization | ||
| await page.waitForTimeout(1000); | ||
|
|
||
| // Disable welcome guide if it's active (using WordPress data API) | ||
| await page.evaluate(() => { | ||
| if (window.wp?.data?.select('core/edit-post')?.isFeatureActive('welcomeGuide')) { | ||
| window.wp.data.dispatch('core/edit-post').toggleFeature('welcomeGuide'); | ||
| } | ||
| }); | ||
|
|
||
| await page.waitForTimeout(100); | ||
|
|
||
| // Click the toolbar button to open modal | ||
| await toolbarButton.locator('button').click(); | ||
| await page.waitForTimeout(100); | ||
|
|
||
| // Verify body has modal-open class | ||
| await expect(page.locator('body')).toHaveClass(/modal-open/); | ||
|
|
||
| // Verify modal window exists and is visible | ||
| const modal = page.locator('.nfd-wba-modal[role="dialog"]'); | ||
| await expect(modal).toBeVisible(); | ||
|
|
||
| // Test close button functionality | ||
| const closeButton = modal.locator('.nfd-wba-modal__header button[aria-label="Close dialog"]'); | ||
| await expect(closeButton).toBeVisible(); | ||
| await closeButton.click(); | ||
| await page.waitForTimeout(100); | ||
|
|
||
| // Verify modal is closed | ||
| await expect(page.locator('body')).not.toHaveClass(/modal-open/); | ||
| await expect(modal).not.toBeVisible(); | ||
|
|
||
| // Test ESC key functionality | ||
| await toolbarButton.locator('button').click(); | ||
| await page.waitForTimeout(100); | ||
| await expect(modal).toBeVisible(); | ||
|
|
||
| // Press ESC key | ||
| await page.keyboard.press('Escape'); | ||
| await page.waitForTimeout(100); | ||
|
|
||
| // Verify modal is closed | ||
| await expect(modal).not.toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
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.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 12 days ago
To fix this issue, you should add a
permissionsblock to the workflow file, ideally at the top/root so it applies to all jobs, and grant the minimal necessary privileges. Given the jobs as shown only extract a branch name and call another workflow—actions that typically only require read access to repository content—setpermissions: contents: readat the top of the file, just aftername:(or afteron:if you prefer), to follow least-privilege principles. If later you find specific jobs need more, you can override at the job level, but starting withcontents: readis safest for CI/test flows.The change is a one-line insertion at the root of the YAML workflow, likely after the
nameoronblock.