-
Notifications
You must be signed in to change notification settings - Fork 79
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
MNT Behat test to test special characters in shortcode #1376
MNT Behat test to test special characters in shortcode #1376
Conversation
Require PR |
I've rerun the behat tests but they're failing. Have confirmed that behat is running against the recent changes, so there's either something wrong with the test or the new logic. |
244e294
to
90734a8
Compare
Fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this still isn't working as expected.
I would expect to see My alt updated & saved
in the HTML, but this test shows My alt updated & saved
which is incorrect.
We should also add to the behat test what happens on the front-end, to validate that the frontend markup has alt="My alt updated & saved"
and not alt="My alt updated & saved"
or alt="My alt updated & saved"
.
47e336b
to
21b1081
Compare
Follow [TinyMC documentation] (https://www.tiny.cloud/docs/tinymce/6/content-filtering/#entities) and this:
So my assumption, when we just start to work on content and add new special characters TinyMC will always encoded them into their named equivalents. So this we see this here. document.querySelector('textarea[name="Content"]').value
'<div class="captionImage leftAlone" style="width: 444px;">[image src="http://localhost:90/sink413x/assets/Uploads/GitHub-avatar-v2.jpeg" id="3" width="444" height="444" class="leftAlone ss-htmleditorfield-file image" alt="Batman & Robin"]\n<p class="caption leftAlone">Batman & Robin</p>\n</div>' Second string that I get after "Save" (entities): document.querySelector('textarea[name="Content"]').value
'<div class="captionImage leftAlone" style="width: 444px;">[image src="/sink413x/assets/Uploads/GitHub-avatar-v2.jpeg" id="3" width="444" height="444" class="leftAlone ss-htmleditorfield-file image" alt="Batman & Robin"]\n<p class="caption leftAlone">Batman & Robin</p>\n</div>' Third string that I get after I made some changes, but not "Save" yet (named equivalents): document.querySelector('textarea[name="Content"]').value
'<div class="captionImage leftAlone" style="width: 444px;">[image src="/sink413x/assets/Uploads/GitHub-avatar-v2.jpeg" id="3" width="444" height="444" class="leftAlone ss-htmleditorfield-file image" alt="Batman & Robin"]\n<p class="caption leftAlone">Batman & Robin & Co</p>\n</div>' This string we pass to the server from the client : <div class="captionImage leftAlone" style="width: 444px;">[image src="/sink413x/assets/Uploads/GitHub-avatar-v2.jpeg" id="3" width="444" height="444" class="leftAlone ss-htmleditorfield-file image" alt="Batman & Robin"]
<p class="caption leftAlone">Batman & Robin & Co</p>
</div> This string we store in DB: <div class="captionImage leftAlone" style="width: 444px;">[image src="/sink413x/assets/Uploads/GitHub-avatar-v2.jpeg" id="3" width="444" height="444" class="leftAlone ss-htmleditorfield-file image" alt="Batman & Robin"]
<p class="caption leftAlone">Batman & Robin & Co</p> It looks like TinyMC convert html entities into named equivalents in whole content every time when we edit it. When we return So for behat test we should expect that after "Save" we will get |
f600e84
to
5e321bb
Compare
And I should see an "img[alt='My alt updated & saved']" element | ||
And I should see an "img[title='My title text updated & saved']" element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not seem like it, but this actually means we're still double encoding. These should be queryable as img[alt='My alt updated & saved']
and img[title='My title text updated & saved']
I've gone back and re-run my manual tests. It turns out that the inspector in both firefox and chrome shows the decoded version of the string. So I saw this:
alt="some & thing"
But the actual value (seen by right clicking and selecting "Edit as HTML") was this:
alt="some &amp; thing"
So we're still double encoding. Sorry I didn't catch it before merging the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes that were made are correct, but they fixed problem in CMS itself. Current problem happens now when we display Content on a page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it and update Behat tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you, please review this PR
5e321bb
to
f9b11d7
Compare
Tests require this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - it's green now the changes are merged.
Parent issue