-
Notifications
You must be signed in to change notification settings - Fork 324
Enhancement/10475 siwg block options #11683
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7fdce6c
Update block.json.
zutigrm 8eb1494
Update edit.js to include inspector controls.
zutigrm 7e0a92a
Add attributes to the block.
zutigrm a910cfd
Add block tests.
zutigrm 71f8667
Simplify attributes extraction.
zutigrm f77d0d0
Remove deprication notices.
zutigrm 73c5fbb
Update per CR feedback.
zutigrm 6ecef77
Merge remote-tracking branch 'origin/develop' into enhancement/10475-…
zutigrm bf37ad6
Update comment.
zutigrm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
94 changes: 94 additions & 0 deletions
94
tests/phpunit/integration/Modules/Sign_In_With_Google/Sign_In_With_Google_BlockTest.php
This file contains hidden or 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,94 @@ | ||
| <?php | ||
| /** | ||
| * Class Google\Site_Kit\Tests\Modules\Sign_In_With_Google\Sign_In_With_Google_BlockTest | ||
| * | ||
| * @package Google\Site_Kit\Tests\Modules\Sign_In_With_Google | ||
| * @copyright 2025 Google LLC | ||
| * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
| * @link https://sitekit.withgoogle.com | ||
| */ | ||
|
|
||
| namespace Google\Site_Kit\Tests\Modules\Sign_In_With_Google; | ||
|
|
||
| use Google\Site_Kit\Context; | ||
| use Google\Site_Kit\Modules\Sign_In_With_Google; | ||
| use Google\Site_Kit\Modules\Sign_In_With_Google\Sign_In_With_Google_Block; | ||
| use Google\Site_Kit\Tests\TestCase; | ||
|
|
||
| class Sign_In_With_Google_BlockTest extends TestCase { | ||
|
|
||
| /** | ||
| * Block instance. | ||
| * | ||
| * @var Sign_In_With_Google_Block | ||
| */ | ||
| private $block; | ||
|
|
||
| /** | ||
| * Module instance. | ||
| * | ||
| * @var Sign_In_With_Google | ||
| */ | ||
| private $module; | ||
|
|
||
| public function set_up() { | ||
| parent::set_up(); | ||
|
|
||
| $context = new Context( GOOGLESITEKIT_PLUGIN_MAIN_FILE ); | ||
|
|
||
| $this->block = new Sign_In_With_Google_Block( $context ); | ||
| $this->module = new Sign_In_With_Google( $context ); | ||
|
|
||
| add_action( | ||
| 'googlesitekit_render_sign_in_with_google_button', | ||
| array( $this->module, 'render_sign_in_with_google_button' ), | ||
| 10, | ||
| 1 | ||
| ); | ||
| } | ||
|
|
||
| public function tear_down() { | ||
| remove_action( | ||
| 'googlesitekit_render_sign_in_with_google_button', | ||
| array( $this->module, 'render_sign_in_with_google_button' ), | ||
| 10 | ||
| ); | ||
|
|
||
| parent::tear_down(); | ||
| } | ||
|
|
||
| public function test_render_callback_with_overrides() { | ||
| wp_set_current_user( 0 ); | ||
|
|
||
| $output = $this->block->render_callback( | ||
| array( | ||
| 'shape' => 'pill', | ||
| 'text' => 'signin_with', | ||
| 'theme' => 'filled_black', | ||
| 'buttonClassName' => 'custom-class another-class invalid@class', | ||
| ) | ||
| ); | ||
|
|
||
| $this->assertStringContainsString( 'data-googlesitekit-siwg-shape="pill"', $output, 'Expected shape data attribute to be present.' ); | ||
| $this->assertStringContainsString( 'data-googlesitekit-siwg-text="signin_with"', $output, 'Expected text data attribute to be present.' ); | ||
| $this->assertStringContainsString( 'data-googlesitekit-siwg-theme="filled_black"', $output, 'Expected theme data attribute to be present.' ); | ||
| $this->assertStringContainsString( 'class="googlesitekit-sign-in-with-google__frontend-output-button custom-class another-class invalidclass"', $output, 'Expected sanitized classes to be present.' ); | ||
| } | ||
|
|
||
| public function test_render_callback_with_defaults_outputs_no_overrides() { | ||
| wp_set_current_user( 0 ); | ||
|
|
||
| $output = $this->block->render_callback( | ||
| array( | ||
| 'shape' => '', | ||
| 'text' => '', | ||
| 'theme' => '', | ||
| ) | ||
| ); | ||
|
|
||
| $this->assertStringNotContainsString( 'data-googlesitekit-siwg-shape', $output, 'Default selection should not add shape data attribute.' ); | ||
| $this->assertStringNotContainsString( 'data-googlesitekit-siwg-text', $output, 'Default selection should not add text data attribute.' ); | ||
| $this->assertStringNotContainsString( 'data-googlesitekit-siwg-theme', $output, 'Default selection should not add theme data attribute.' ); | ||
| $this->assertStringContainsString( 'class="googlesitekit-sign-in-with-google__frontend-output-button"', $output, 'Default output should include the base class only.' ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
SelectControlandTextControlare getting depricated php notices unless these props are includedThere 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.
Let's add some documentation for that in the actual component then, preferably with links to the props or the code you found this in, since without any context these look strange/unintuitive.
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 extracted it from the deprication notice that was raised in CI e2e. Added as short inline comment