-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed issue of HTML code appearing on the front-end by allowing partial HTML tag rendering for Multiple Choice Label - Fix fatal crash in Block Conditions when rendering condition is set to `false` - Fixed issue with multiple instances of Pattern Upsell appearing on the same page - Updated internal dependencies
- Loading branch information
Showing
7 changed files
with
135 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 contains 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 contains 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 contains 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,49 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { test, expect } from '@wordpress/e2e-test-utils-playwright'; | ||
import { tryLoginIn } from '../utils'; | ||
|
||
test.describe( 'Block Conditions', () => { | ||
test.beforeEach( async({ admin, requestUtils, page }) => { | ||
await tryLoginIn( page, 'admin', 'password' ); | ||
await admin.createNewPost(); | ||
}); | ||
|
||
test.afterEach( async({ page }) => { | ||
|
||
/** | ||
* Because some conditions require an user to be logged in, we need to log in the user after each test so that we do not break the next test. | ||
*/ | ||
await tryLoginIn( page, 'admin', 'password' ); | ||
}); | ||
|
||
test( 'check logged out users', async({ editor, page, admin, requestUtils }) => { | ||
await editor.insertBlock({ | ||
name: 'core/image', | ||
attributes: { | ||
url: 'https://mllj2j8xvfl0.i.optimole.com/cb:jC7e.37109/w:794/h:397/q:mauto/dpr:2.0/f:best/https://themeisle.com/blog/wp-content/uploads/2021/01/How-to-Change-Font-in-WordPress-Theme.png', | ||
otterConditions: [ | ||
[ | ||
{ | ||
type: 'loggedInUser' | ||
} | ||
] | ||
] | ||
} | ||
}); | ||
|
||
const postId = await editor.publishPost(); | ||
|
||
// Check the block for logged in users. | ||
await page.goto( `/?p=${postId}` ); | ||
await expect( page.locator( '#wp--skip-link--target img' ) ).toBeVisible(); | ||
|
||
// Check the block for logged out users. | ||
await page.getByRole( 'menuitem', { name: 'Howdy, admin' }).hover(); | ||
await page.waitForTimeout( 200 ); | ||
await page.getByRole( 'menuitem', { name: 'Log Out' }).click(); | ||
await page.goto( `/?p=${postId}` ); | ||
await expect( page.locator( '#wp--skip-link--target img' ) ).toBeHidden(); | ||
}); | ||
}); |
This file contains 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 contains 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,37 @@ | ||
<?php | ||
/** | ||
* Test Multiple Choice Field Block. | ||
* | ||
* @package otter-blocks | ||
*/ | ||
|
||
use ThemeIsle\GutenbergBlocks\Render\Form_Multiple_Choice_Block; | ||
|
||
/** | ||
* Class Test Multiple Choices Block | ||
*/ | ||
class Test_Multiple_Choices_Block extends WP_UnitTestCase { | ||
|
||
public function test_label_sanitization_render() { | ||
$block_render = new Form_Multiple_Choice_Block(); | ||
|
||
$expected = '<div class="o-form-multiple-choice-field">'; | ||
$expected .= '<input type="checkbox" name="otter-blocks" id="otter-blocks" value="otter-blocks" />'; | ||
$expected .= '<label for="otter-blocks" class="o-form-choice-label">Option with <a href="www.example.com">link</a></label>'; | ||
$expected .= '</div>'; | ||
|
||
$output = $block_render->render_field( 'checkbox', 'Option with <a href="www.example.com">link</a>', 'otter-blocks', 'otter-blocks', 'otter-blocks' ); | ||
|
||
$this->assertEquals( $expected, $output ); | ||
|
||
$malicious_label = 'Option with <a href="www.example.com">link</a><script></script>'; | ||
$output = $block_render->render_field( 'checkbox', $malicious_label, 'otter-blocks', 'otter-blocks', 'otter-blocks' ); | ||
|
||
$this->assertEquals( $expected, $output ); | ||
|
||
$malicious_label = 'Option with <a href="www.example.com" onclick="alert(123)">link</a>'; | ||
$output = $block_render->render_field( 'checkbox', $malicious_label, 'otter-blocks', 'otter-blocks', 'otter-blocks' ); | ||
|
||
$this->assertEquals( $expected, $output ); | ||
} | ||
} |