Repository navigation
Fixed attach cloud library listeners early - #1241
girishpanchal30 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟢 Approved
The Cloud Library script now loads in the head, and both iframe events are handled in a real browser.
Validation details
- Files reviewed: 4/4 changed files.
- The rendered Cloud Library page prints
admin-page.jsin the head, before the loader and the iframe (WordPress sandbox, PHP 8.3.36) [R11][R12]. - In Chromium, a stubbed DAM iframe sent
getUrlat once. The loader hid, the iframe showed, and the iframe gotsiteUrl. The console showed no errors. - The Jest test passed at HEAD
cd /repo && set -o pipefail; timeout 280 npx jest assets/src/media/__tests__/admin-page.test.js --verbose 2>&1 | tee /wo…(run R2, exit 0). Atpr-baseit failed on load, not on an assertionset -o pipefail; B=/workspace/checks/C6/base-jest; rm -rf $B; mkdir -p $B && cd /repo && git archive 3402c1e | tar -x -C…(run R3, exit 0). - The PHPUnit test passed at HEAD
cd /repo && set -o pipefail; timeout 280 vendor/bin/phpunit --do-not-cache-result -c phpunit.xml --filter 'Test_Dam::tes…(run R8, exit 0). Atpr-baseit failed on the footer group assertionset -o pipefail; cd /repo && B=/workspace/checks/C6/base-php; rm -rf $B; mkdir -p $B && git archive 3402c1e | tar -x -C …(run R9, exit 1). - The build output is git-ignored and is built at release, so no stale bundle ships
git grep -n -E 'assets/build|wp-scripts|npm run|dist|build' HEAD -- .gitignore .distignore package.json .github/workflow…(run R7, exit 0).
Untested areas
- The real Optimole DAM app was stubbed in the browser check.
- Image insertion from the Media Library modal was not exercised in a browser.
- The variant pass did not settle these places, where the fixed cause may still reach:
assets/src/media/modal/messageHandler.js:42-67,84-91— unverified: Both Select and Post modals defer the message listener until iframe load: "window.addEventListener( 'message', self.messageListener )" is inside that callback. A getUrl delivered e…assets/src/media/media-modal.js:11-15— unverified: Both Select and Post modals defer the message listener until iframe load: "window.addEventListener( 'message', self.messageListener )" is inside that callback. A getUrl delivered e…
🤖 Automated review · run code-review-agent_6afaf0d3b875f2.87831781.
🤖 Review agent — review posted ✅ on 3402c1e4 · approved · 0 findings · 13 min
Run code-review-agent_6afaf0d3b875f2.87831781 · trail
There was a problem hiding this comment.
🟢 Approved
This approves the test update since the last review, and the note asks for one Elementor Image Box check.
Validation details
- Files reviewed: 4/4 changed files. Only
tests/test-dam.phpchanged since the prior review. - The new PHPUnit test passed at HEAD without built assets
set -o pipefail; P=/var/www/html/wp-content/plugins/optimole-wp; H=/tmp/C1-head; cd /repo; git worktree add --quiet --de…printedOK (1 test, 3 assertions)(run R2). - The whole
Test_Damclass passed at HEADset -o pipefail; P=/var/www/html/wp-content/plugins/optimole-wp; H=/tmp/C1-head; cd /repo; git worktree add --quiet --de…printedOK (12 tests, 138 assertions)(run R2). - The test failed at
pr-baseon the order assertionset -o pipefail; P=/var/www/html/wp-content/plugins/optimole-wp; cd /tmp/C1-base; ln -sfn /tmp/C1-base $P && ls -la $P; …printedFailed asserting that 345 is less than 108.(run R1). - Source and browser checks of run code-review-agent_6afaf0d3b875f2.87831781 were reused, not rerun. The source is unchanged since then.
Untested areas
- No PHPUnit test covers the head enqueue. It needs a built asset file that CI does not build.
- The variant pass and requirements check were not rerun. The Media Library modal listener stays unverified.
- Issue #828 (closed): Fatal Error with "Image Box" Widget Using Optimole DAM in Elementor. It was not exercised in a browser.
🤖 Automated review · run code-review-agent_6afaf8c84da032.24086749.
🤖 Review agent — review posted ✅ on b516245b · approved · 0 findings · 9 min
Run code-review-agent_6afaf8c84da032.24086749 · trail
| display: none !important; | ||
| } | ||
| </style> | ||
| <iframe id="om-dam" style="display: none;" src="<?php echo( $this->build_iframe_url() ); ?>" allow="clipboard-read; clipboard-write"></iframe> | ||
| <div class="om-dam-loader"> | ||
| <img src="<?php echo esc_url( OPTML_URL . 'assets/img/logo.png' ); ?>" alt="Optimole Logo" | ||
| class="om-dam-logo"> | ||
| <p><?php echo esc_html__( 'Loading', 'optimole-wp' ); ?>...</p> | ||
| </div> | ||
| <iframe id="om-dam" style="display: none;" src="<?php echo( $this->build_iframe_url() ); ?>" allow="clipboard-read; clipboard-write"></iframe> |
There was a problem hiding this comment.
note The DAM markup this change reorders is also printed inside the media modal template, which Elementor's editor loads. Issue #828 crashed when a Cloud Library image was picked for the Elementor "Image Box" widget. The fix for that lookup is untouched. Please pick a Cloud Library image in an Image Box widget once. Safe: the widget renders the image. Broken: the editor shows a TypeError or a fatal error.
All Submissions:
Changes proposed in this Pull Request:
The Cloud Library page could stay on "Loading..." forever.
admin-page.jswas loaded in the footer, so on heavy admin pages the DAM iframe could finish loading and sendgetUrlbefore the script attached its listeners. Both events were missed.admin-page.jsin the head, so the listeners are attached before the iframe exists.loadevent ondocumentin the capture phase, and look up#om-damwhengetUrlarrives.The Media Library modal is not affected. The retry/timeout in Dam.vue belongs to optimole-service and is not part of this PR.
Closes #1211.
How to test the changes in this Pull Request:
Other information: