Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/brand-plugin-test-playwright.yml
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:
Comment on lines +15 to +26

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 12 days ago

To fix this issue, you should add a permissions block 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—set permissions: contents: read at the top of the file, just after name: (or after on: 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 with contents: read is safest for CI/test flows.

The change is a one-line insertion at the root of the YAML workflow, likely after the name or on block.


Suggested changeset 1
.github/workflows/brand-plugin-test-playwright.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/brand-plugin-test-playwright.yml b/.github/workflows/brand-plugin-test-playwright.yml
--- a/.github/workflows/brand-plugin-test-playwright.yml
+++ b/.github/workflows/brand-plugin-test-playwright.yml
@@ -1,4 +1,6 @@
 name: Build and Test Module Updates in Brand Plugins (Playwright tests)
+permissions:
+  contents: read
 on:
   pull_request:
     types: [ opened, reopened, ready_for_review, synchronize ]
EOF
@@ -1,4 +1,6 @@
name: Build and Test Module Updates in Brand Plugins (Playwright tests)
permissions:
contents: read
on:
pull_request:
types: [ opened, reopened, ready_for_review, synchronize ]
Copilot is powered by AI and may make mistakes. Always verify output.
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

10 changes: 0 additions & 10 deletions .github/workflows/brand-plugin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ jobs:
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

bluehost:
name: Bluehost Build and Test
needs: setup
uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main
with:
module-repo: ${{ github.repository }}
module-branch: ${{ needs.setup.outputs.branch }}
plugin-repo: "newfold-labs/wp-plugin-bluehost"
secrets: inherit

hostgator:
name: HostGator Build and Test
needs: setup
Expand Down
42 changes: 0 additions & 42 deletions tests/cypress/integration/wonder-blocks.cy.js

This file was deleted.

71 changes: 71 additions & 0 deletions tests/playwright/specs/wonder-blocks.spec.js
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();
});
});

Loading