Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Mar 29, 2024
1 parent ebec598 commit 78bc9f3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/OpenAI/APIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function get_result( $response ) {
$body = wp_remote_retrieve_body( $response );
$code = wp_remote_retrieve_response_code( $response );

if ( $content_type && false !== strpos( $content_type, 'application/json' ) ) {
if ( false === $content_type || false !== strpos( $content_type, 'application/json' ) ) {
$json = json_decode( $body, true );

if ( json_last_error() === JSON_ERROR_NONE ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe( 'Image Generation (OpenAI DALL·E) Tests', () => {
).check();

cy.get( '#submit' ).click();
cy.get( '.notice' ).contains( 'Settings saved.' );
} );

it( 'Can generate images in the media modal', () => {
Expand Down
7 changes: 5 additions & 2 deletions tests/test-plugin/e2e-test-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ function classifai_test_mock_http_requests( $preempt, $parsed_args, $url ) {
|| strpos( $url, 'https://api.openai.com/v1/audio/speech' ) !== false
) {
return array(
'response' => array(
'response' => array(
'code' => 200,
),
'body' => file_get_contents( __DIR__ . '/text-to-speech.txt' ),
'headers' => array(
'content-type' => 'audio/mpeg',
),
'body' => file_get_contents( __DIR__ . '/text-to-speech.txt' ),
);
} elseif ( strpos( $url, 'https://api.openai.com/v1/embeddings' ) !== false ) {
$response = file_get_contents( __DIR__ . '/embeddings.json' );
Expand Down

0 comments on commit 78bc9f3

Please sign in to comment.