Skip to content

House Keeping#74

Merged
gin0115 merged 6 commits into
trunkfrom
fix/dirty-dates-on-resave
May 15, 2026
Merged

House Keeping#74
gin0115 merged 6 commits into
trunkfrom
fix/dirty-dates-on-resave

Conversation

@gin0115
Copy link
Copy Markdown
Collaborator

@gin0115 gin0115 commented May 15, 2026

Changes proposed in this Pull Request

This pull request introduces several infrastructure and configuration updates, alongside documentation for a planned fix to the event dates dirty-flag bug. The main highlights are the addition of an E2E test workflow using Playwright, updates to PHP version requirements, and a detailed technical plan for addressing a persistent editor dirty-state issue. No production code changes are included yet for the event dates fix; only the fix plan is documented.

Testing and CI improvements:

  • Added a new GitHub Actions workflow .github/workflows/e2e-tests.yml to automate end-to-end (E2E) testing with Playwright, including environment setup, dependency installation, and artifact upload on failure.
  • Updated package.json to add Playwright and related scripts for running E2E tests locally and in CI. [1] [2]

Environment and dependency updates:

  • Changed PHP version requirement from 8.2 to 8.3 in both .wp-env.json and composer.json, and set Composer's platform PHP version accordingly. [1] [2]
  • Minor cleanup in composer.json development dependencies section.
  • Enabled testdox output in PHPUnit configuration for improved test readability.

Permissions and configuration:

  • Added .claude/settings.json to explicitly allow web fetches from api.github.com.

Documentation:

  • Added event-dates-fix-plan.md, a comprehensive technical plan for fixing the event dates dirty-flag bug in the editor, including root cause analysis, rejected alternatives, proposed solution, edge cases, and testing strategy.

Testing instructions

Manual Testing — Event Dates Dirty-State Fix & Migration Version Stamp

End-user QA steps for the two fixes in this branch. Follow in a browser; check each ✅ expectation.

Prerequisites

  1. Build the JS (the dirty-flag fix lives in compiled build/):
    npm run build
    The PHP fix loads automatically — no build needed for that.
  2. Environment: wp-env site is http://localhost:8888 (login admin / password). If testing on devilbox instead, use that URL — behaviour is identical.

Fix #1 — Dirty-state leak (event-info block)

Test A — First publish + reload (the core repro)

  1. Events → Add New. The Event Information block loads in edit mode.
  2. Click Add Date, set a start/end time, click Done.
  3. Type a post title.
  4. Click Publish, confirm Publish in the panel.
  5. Wait for the "Event dates synced" snackbar.
  6. Expect: the top-bar button shows greyed-out "Saved"not an active "Save"/"Update".
  7. Reload the page (F5 / Cmd-R).
  8. Expect: no "Leave site? Changes you made may not be saved" browser prompt.
  9. Expect: after reload, the date is still shown and the post is not dirty.

Test B — Edit + save again (the "always dirty" repro)

  1. Open the event from Test A.
  2. Change the date's time (or Add Date again), click Done.
  3. Click Update, wait for the snackbar.
  4. Expect: button greys out, stays clean.
  5. Reload → ✅ no "Leave site?" prompt.
  6. (Optional, DevTools → Network): per save click you should see exactly one POST to …/event-dates/{id}/sync and one to …/wp/v2/se-event/{id} — not 3× and 2× like before.

Test C — Abandon changes (draft semantic must still hold)

  1. Events → Add New, Add Date, Done — but do NOT save.
  2. Close the tab / navigate away.
  3. Expect: nothing persisted — no stray child date created. Verify via the meta command below against any new auto-draft, or confirm no orphan event-date posts appear.

Fix #2 — Migration version stamping

Test D — New event is not flagged for migration

  1. Before: note whether the plugin currently shows an "events need migrating" admin notice.
  2. Events → Add New → add a title → Publish (you can skip adding a date entirely).
  3. Expect: this new event does not appear in / trigger the migration notice.

Test E — Save with NO date interaction (the original intermittent bug)

  1. Events → Add New → set only a title, do not add a date (so /sync never fires) → Publish.
  2. Expect: the event still gets stamped and is not flagged for migration — this is the exact case that used to slip through.

Verify the meta directly

For any event ID, check the stamped version:

npx wp-env run cli wp post meta get <EVENT_ID> se_event_version

Expect: prints 2.0.0 (the current SE_MIGRATION_VERSION) for any newly created event — including ones where you never added a date.

Test F — Legacy events still migrate (regression guard)

Hard to stage by hand (needs a genuine pre-2.0 event with no version meta). Covered by the automated test EventMigrationTest ("A genuinely legacy event…"). If you have a real legacy event: it should still show in the migration queue and migrate normally when run — the new stamp only affects events created after this fix.


If anything doesn't match the ✅ expectations, note the step number and what you saw.

Mentions #

Summary by CodeRabbit

  • New Features

    • Improved editor publish/save flow for the Event Info block to reduce stuck-unsaved states.
  • Bug Fixes

    • Ensure newly created events are stamped with a version to avoid misclassifying them for migration.
  • Tests

    • Added comprehensive Playwright end-to-end tests for editor workflows and regressions.
    • Added PHPUnit tests covering event migration/versioning.
  • Chores

    • CI workflow added to run E2E tests on pull requests; dev environment/tools updated (PHP 8.3, Playwright scripts).
  • Style

    • .gitignore updated to exclude E2E artifacts.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: acf1e6d4-97d5-414c-b4c8-14d0c3da67a4

📥 Commits

Reviewing files that changed from the base of the PR and between da7afa3 and 7ddea91.

📒 Files selected for processing (1)
  • tests/e2e/specs/editor/event-dates-regressions.spec.js

Walkthrough

This PR refactors the event-info block editor to run saveEventDates (the /sync call) before savePost via a document-level publish/update click interceptor, removes unused @wordpress/data imports, and adds a transition_post_status hook that stamps se_event_version for new events. It introduces Playwright-based E2E tests with fixtures, global setup, Playwright config, multiple specs, and a GitHub Actions workflow to run E2E on pull requests. Tooling updates include PHP 8.3 platform config, Composer helper scripts, Playwright dependency and npm scripts, .wp-env change, .gitignore entries, and PHPUnit TestDox enabled.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive Title is vague and generic, using a non-descriptive term 'House Keeping' that does not convey meaningful information about the changeset. Provide a more descriptive title that summarizes the primary changes, such as 'Add Playwright E2E testing infrastructure and PHP 8.3 support'.
Linked Issues check ❓ Inconclusive Linked issues lack specific coding requirements; they contain only titles and URLs without detailed objectives, making full compliance assessment impossible. Provide linked issues with detailed coding requirements or remove links if issues do not have specific technical objectives for this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Out of Scope Changes check ✅ Passed All changes are related to E2E testing infrastructure, PHP version updates, configuration, and testing documentation aligned with PR objectives; no unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/e2e-tests.yml (1)

31-31: ⚡ Quick win

Consider removing --force flag from npm ci.

The --force flag bypasses dependency conflict checks and can mask genuine dependency issues. Unless there's a specific reason to use it, prefer npm ci without --force for more reliable builds.

📦 Recommended change
-        run: npm ci --force
+        run: npm ci
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e-tests.yml at line 31, The CI step using the run
command currently invokes "npm ci --force"; remove the "--force" flag so the
workflow step runs "npm ci" instead to allow npm to surface dependency
conflicts; update the run: entry in the e2e-tests workflow (the run command
shown in the diff) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/e2e-tests.yml:
- Line 18: The PHP version in the GitHub Actions workflow is inconsistent with
the dev config: update the workflow's php-version key (the entry labeled
"php-version: '8.2'") to match the project's PHP requirement (8.3) so CI uses
PHP 8.3 like .wp-env.json and composer.json; ensure any other workflow matrix
entries referencing PHP are also changed to '8.3' to keep CI and local
environments synchronized.

In `@tests/e2e/specs/editor/event-dates-block.spec.js`:
- Around line 23-38: The test currently only checks lockState.blockCount so it
doesn't verify removal locking; update the assertion to also verify
lockState.templateLock to match the test intent (e.g.
expect(lockState.templateLock).toBeTruthy() or
expect(lockState.templateLock).toEqual('all') ) after calling
openNewEvent(page). Locate the lockState object gathered via
window.wp.data.select('core/block-editor').getSettings() in the test and add the
templateLock assertion (or an explicit non-removability check against the blocks
returned by window.wp.data.select('core/block-editor').getBlocks()) to ensure
the event-info block cannot be removed.

In `@tests/e2e/specs/editor/event-dates-save.spec.js`:
- Around line 72-79: The two assertions referencing net.counts.sync and
net.counts.postSave in the event-dates-save test are known failing repros;
quarantine them so CI stays green by skipping the containing test block (use
it.skip or describe.skip) or conditionally returning early based on a quarantine
flag, and add a short TODO comment pointing to the production fix; specifically
locate the assertions that call expect( net.counts.sync ).toBe( 1 ) and expect(
net.counts.postSave ).toBe( 1 ) and wrap/disable their enclosing it/describe so
they do not run until the fix is merged.

---

Nitpick comments:
In @.github/workflows/e2e-tests.yml:
- Line 31: The CI step using the run command currently invokes "npm ci --force";
remove the "--force" flag so the workflow step runs "npm ci" instead to allow
npm to surface dependency conflicts; update the run: entry in the e2e-tests
workflow (the run command shown in the diff) accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d421493-25d2-401a-aa20-fa89b8d0e0d3

📥 Commits

Reviewing files that changed from the base of the PR and between bc66c00 and 0bc1463.

⛔ Files ignored due to path filters (2)
  • composer.lock is excluded by !**/*.lock
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (23)
  • .claude/settings.json
  • .github/workflows/e2e-tests.yml
  • .gitignore
  • .wp-env.json
  • composer.json
  • package.json
  • phpunit.xml.dist
  • src/blocks/event-info/index.js
  • src/classes/class-se-event-post-type.php
  • tests/e2e/.env.example
  • tests/e2e/fixtures/event-editor.js
  • tests/e2e/fixtures/index.js
  • tests/e2e/global-setup.js
  • tests/e2e/playwright.config.js
  • tests/e2e/specs/editor/event-dates-block.spec.js
  • tests/e2e/specs/editor/event-dates-regressions.spec.js
  • tests/e2e/specs/editor/event-dates-reload.spec.js
  • tests/e2e/specs/editor/event-dates-save.spec.js
  • tests/phpunit/EventDates/EventDatesCleanupTest.php
  • tests/phpunit/Migration/EventMigrationTest.php
  • tests/phpunit/Query/EventQueryUtilsTest.php
  • tests/phpunit/Smoke/SampleTest.php
  • tests/phpunit/Templates/TemplateFunctionsTest.php

Comment thread .github/workflows/e2e-tests.yml Outdated
Comment thread tests/e2e/specs/editor/event-dates-block.spec.js
Comment thread tests/e2e/specs/editor/event-dates-save.spec.js
@gin0115 gin0115 merged commit 14b8a70 into trunk May 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can we improve ticket selling workflow? UI/UX Feedback

1 participant