Repository navigation
Connectors: Add logo URL support for custom AI providers #76190
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
6 commits
Select commit
Hold shift + click to select a range
8be6b0c
Connectors: Add logo URL support for custom AI providers
gziolo abc0eb9
Connectors: Use file path instead of URL for provider logos
gziolo 95d33dc
Tests: Hardcode expected URLs in connector logo URL tests
gziolo 54705b8
Tests: Use localhost:8889 for hardcoded URLs in connector logo tests
gziolo 58775e2
Address review feedback for connector logo URL support
gziolo 5aaba79
Connectors: Simplify default connector logo design
gziolo 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
64 changes: 64 additions & 0 deletions
64
phpunit/experimental/connectors/resolve-ai-provider-logo-url-test.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,64 @@ | ||
| <?php | ||
| /** | ||
| * Unit tests for _gutenberg_resolve_ai_provider_logo_url(). | ||
| * | ||
| * @package Gutenberg | ||
| */ | ||
| class Tests_Resolve_AI_Provider_Logo_URL extends WP_UnitTestCase { | ||
|
|
||
| public function test_returns_null_when_path_is_empty() { | ||
| $this->assertNull( _gutenberg_resolve_ai_provider_logo_url( '' ) ); | ||
| } | ||
|
|
||
| public function test_resolves_plugin_dir_path_to_url() { | ||
| $logo_path = WP_PLUGIN_DIR . '/my-plugin/logo.svg'; | ||
|
|
||
| // Create the file so file_exists() passes. | ||
| wp_mkdir_p( dirname( $logo_path ) ); | ||
| file_put_contents( $logo_path, '<svg></svg>' ); | ||
|
|
||
| try { | ||
| $result = _gutenberg_resolve_ai_provider_logo_url( $logo_path ); | ||
| $this->assertSame( site_url( '/wp-content/plugins/my-plugin/logo.svg' ), $result ); | ||
| } finally { | ||
| unlink( $logo_path ); | ||
| rmdir( dirname( $logo_path ) ); | ||
| } | ||
| } | ||
|
|
||
| public function test_resolves_mu_plugin_dir_path_to_url() { | ||
| $logo_path = WPMU_PLUGIN_DIR . '/my-mu-plugin/logo.svg'; | ||
|
|
||
| // Create the file so file_exists() passes. | ||
| wp_mkdir_p( dirname( $logo_path ) ); | ||
| file_put_contents( $logo_path, '<svg></svg>' ); | ||
|
|
||
| try { | ||
| $result = _gutenberg_resolve_ai_provider_logo_url( $logo_path ); | ||
| $this->assertSame( site_url( '/wp-content/mu-plugins/my-mu-plugin/logo.svg' ), $result ); | ||
| } finally { | ||
| unlink( $logo_path ); | ||
| rmdir( dirname( $logo_path ) ); | ||
| } | ||
| } | ||
|
|
||
| public function test_returns_null_when_file_does_not_exist() { | ||
| $result = _gutenberg_resolve_ai_provider_logo_url( WP_PLUGIN_DIR . '/nonexistent/logo.svg' ); | ||
| $this->assertNull( $result ); | ||
| } | ||
|
|
||
| /** | ||
| * @expectedIncorrectUsage _gutenberg_resolve_ai_provider_logo_url | ||
| */ | ||
| public function test_returns_null_and_triggers_doing_it_wrong_for_path_outside_plugin_dirs() { | ||
| $tmp_file = tempnam( sys_get_temp_dir(), 'logo_' ); | ||
| file_put_contents( $tmp_file, '<svg></svg>' ); | ||
|
|
||
| try { | ||
| $result = _gutenberg_resolve_ai_provider_logo_url( $tmp_file ); | ||
| $this->assertNull( $result ); | ||
| } finally { | ||
| unlink( $tmp_file ); | ||
| } | ||
| } | ||
| } |
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
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.