-
Notifications
You must be signed in to change notification settings - Fork 140
Add admin pointers to promote new Performance Lab features #2122
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 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0423288
Add View Transitions to upgrade notice
westonruter 3296195
Add admin pointers for new features
westonruter 3187e8c
Add admin pointer for new Speculative Loading feature
westonruter 695ea71
Refactor wp-pointer logic to use inline script
westonruter 99dfe2d
Remove re-obtaining pointer IDs
westonruter 511d71e
Improve pointer wording for reading flow.
felixarntz 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,37 @@ public function test_perflab_render_settings_page(): void { | |
| $this->assertStringNotContainsString( "<input type='hidden' name='option_page' value='" . PERFLAB_SCREEN . "' />", $output ); | ||
| } | ||
|
|
||
| /** | ||
| * @covers ::perflab_get_dismissed_admin_pointer_ids | ||
| */ | ||
| public function test_perflab_get_dismissed_admin_pointer_ids(): void { | ||
| $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); | ||
| wp_set_current_user( $user_id ); | ||
|
|
||
| // No dismissed pointers. | ||
| $this->assertSame( array(), perflab_get_dismissed_admin_pointer_ids() ); | ||
|
|
||
| // Dismiss a single pointer. | ||
| update_user_meta( $user_id, 'dismissed_wp_pointers', 'perflab-admin-pointer' ); | ||
| $this->assertSame( array( 'perflab-admin-pointer' ), perflab_get_dismissed_admin_pointer_ids() ); | ||
|
|
||
| // Dismiss multiple pointers. | ||
| update_user_meta( $user_id, 'dismissed_wp_pointers', 'perflab-admin-pointer,another-pointer' ); | ||
| $this->assertSame( array( 'perflab-admin-pointer', 'another-pointer' ), perflab_get_dismissed_admin_pointer_ids() ); | ||
|
|
||
| // Dismiss all pointers. | ||
| update_user_meta( $user_id, 'dismissed_wp_pointers', implode( ',', array_keys( perflab_get_admin_pointers() ) ) ); | ||
| $this->assertSame( array_keys( perflab_get_admin_pointers() ), perflab_get_dismissed_admin_pointer_ids() ); | ||
| } | ||
|
|
||
| /** | ||
| * @covers ::perflab_get_admin_pointers | ||
| */ | ||
| public function test_perflab_get_admin_pointers(): void { | ||
| $pointers = perflab_get_admin_pointers(); | ||
| $this->assertArrayHasKey( 'perflab-admin-pointer', $pointers ); | ||
| } | ||
|
Comment on lines
+89
to
+118
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: I'm happy to say that Gemini Code Assist was actually able to write most of this for me. In PhpStorm, I just did Cmd+\ and then entered |
||
|
|
||
| /** | ||
| * @return array<string, array{ hook_suffix: string|null, expected: bool }> | ||
| */ | ||
|
|
@@ -119,23 +150,32 @@ public function data_provider_test_perflab_admin_pointer(): array { | |
| 'assert' => null, | ||
| 'dismissed_wp_pointers' => '', | ||
| ), | ||
| 'dashboard_yes_dismissed' => array( | ||
| 'dashboard_new_dismissed' => array( | ||
| 'set_up' => static function (): void { | ||
| update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', 'perflab-admin-pointer' ); | ||
| }, | ||
| 'hook_suffix' => 'index.php', | ||
| 'expected' => false, | ||
| 'expected' => true, | ||
| 'assert' => null, | ||
| 'dismissed_wp_pointers' => 'perflab-admin-pointer', | ||
| ), | ||
| 'dashboard_all_dismissed' => array( | ||
| 'set_up' => static function (): void { | ||
| update_user_meta( wp_get_current_user()->ID, 'dismissed_wp_pointers', implode( ',', array_keys( perflab_get_admin_pointers() ) ) ); | ||
| }, | ||
| 'hook_suffix' => 'index.php', | ||
| 'expected' => false, | ||
| 'assert' => null, | ||
| 'dismissed_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ), | ||
| ), | ||
| 'perflab_screen_first_time' => array( | ||
| 'set_up' => static function (): void { | ||
| $_GET['page'] = PERFLAB_SCREEN; | ||
| }, | ||
| 'hook_suffix' => 'options-general.php', | ||
| 'expected' => false, | ||
| 'assert' => null, | ||
| 'dismissed_wp_pointers' => 'perflab-admin-pointer', | ||
| 'dismissed_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ), | ||
| ), | ||
| 'perflab_screen_second_time' => array( | ||
| 'set_up' => static function (): void { | ||
|
|
@@ -145,7 +185,7 @@ public function data_provider_test_perflab_admin_pointer(): array { | |
| 'hook_suffix' => 'options-general.php', | ||
| 'expected' => false, | ||
| 'assert' => null, | ||
| 'dismissed_wp_pointers' => 'perflab-admin-pointer', | ||
| 'dismissed_wp_pointers' => implode( ',', array_keys( perflab_get_admin_pointers() ) ), | ||
| ), | ||
| ); | ||
| } | ||
|
|
@@ -168,7 +208,17 @@ public function test_perflab_admin_pointer( ?Closure $set_up, ?string $hook_suff | |
| } | ||
| $this->assertFalse( is_network_admin() || is_user_admin() ); | ||
| perflab_admin_pointer( $hook_suffix ); | ||
| $this->assertSame( $expected ? 10 : false, has_action( 'admin_print_footer_scripts', 'perflab_render_pointer' ) ); | ||
|
|
||
| $after_script = ''; | ||
| $script_dependency = wp_scripts()->query( 'wp-pointer' ); | ||
| if ( $script_dependency instanceof _WP_Dependency ) { | ||
| $after_script = implode( "\n", array_filter( $script_dependency->extra['after'] ?? array() ) ); | ||
| } | ||
| if ( $expected ) { | ||
| $this->assertStringContainsString( 'pointerIdsToDismiss', $after_script ); | ||
| } else { | ||
| $this->assertStringNotContainsString( 'pointerIdsToDismiss', $after_script ); | ||
| } | ||
| $this->assertSame( $expected, wp_script_is( 'wp-pointer', 'enqueued' ) ); | ||
| $this->assertSame( $expected, wp_style_is( 'wp-pointer', 'enqueued' ) ); | ||
| $this->assertSame( $dismissed_wp_pointers, get_user_meta( $user_id, 'dismissed_wp_pointers', true ) ); | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.