diff --git a/tests/cypress/plugins/functions.js b/tests/cypress/plugins/functions.js index 014016904..fbb9d8fa3 100644 --- a/tests/cypress/plugins/functions.js +++ b/tests/cypress/plugins/functions.js @@ -3,7 +3,6 @@ import * as chatgptData from '../../test-plugin/chatgpt.json'; import * as chatgptCustomExcerptData from '../../test-plugin/chatgpt-custom-excerpt-prompt.json'; import * as chatgptCustomTitleData from '../../test-plugin/chatgpt-custom-title-prompt.json'; import * as dalleData from '../../test-plugin/dalle.json'; -import * as ocrData from '../../test-plugin/ocr.json'; import * as whisperData from '../../test-plugin/whisper.json'; import * as imageData from '../../test-plugin/image_analyze.json'; import * as pdfData from '../../test-plugin/pdf.json'; @@ -99,7 +98,7 @@ export const getWhisperData = () => { */ export const getOCRData = () => { const words = []; - ocrData.regions.forEach( ( el ) => { + imageData.readResult.blocks.forEach( ( el ) => { el.lines.forEach( ( el2 ) => { el2.words.forEach( ( el3 ) => { words.push( el3.text ); @@ -116,10 +115,8 @@ export const getOCRData = () => { */ export const getImageData = () => { const data = { - altText: imageData.description.captions.filter( - ( el ) => el.confidence > 0.75 - )[ 0 ].text, - tags: imageData.tags + altText: imageData.captionResult.text, + tags: imageData.tagsResult.values .filter( ( el ) => el.confidence > 0.7 ) .map( ( el ) => el.name ), }; diff --git a/tests/test-plugin/e2e-test-plugin.php b/tests/test-plugin/e2e-test-plugin.php index 6753215d3..3659f1ffd 100644 --- a/tests/test-plugin/e2e-test-plugin.php +++ b/tests/test-plugin/e2e-test-plugin.php @@ -80,10 +80,8 @@ function classifai_test_mock_http_requests( $preempt, $parsed_args, $url ) { strpos( $url, 'https://e2e-test-azure-openai-embeddings.test/openai/deployments' ) !== false ) { $response = file_get_contents( __DIR__ . '/embeddings.json' ); - } elseif ( strpos( $url, 'http://e2e-test-image-processing.test/vision/v3.2/analyze' ) !== false ) { + } elseif ( strpos( $url, 'http://e2e-test-image-processing.test/computervision/imageanalysis:analyze?api-version=2024-02-01' ) !== false ) { $response = file_get_contents( __DIR__ . '/image_analyze.json' ); - } elseif ( strpos( $url, 'http://e2e-test-image-processing.test/vision/v3.2/ocr' ) !== false ) { - $response = file_get_contents( __DIR__ . '/ocr.json' ); } elseif ( strpos( $url, 'http://e2e-test-image-processing.test/vision/v3.2/generateThumbnail' ) !== false ) { $response = file_get_contents( __DIR__ . '../classifai/assets/img/icon256x256.png' ); } elseif ( strpos( $url, 'http://e2e-test-image-processing.test/pdf-read-result' ) !== false ) { diff --git a/tests/test-plugin/image_analyze.json b/tests/test-plugin/image_analyze.json index 5e0e58943..d2dbcb351 100644 --- a/tests/test-plugin/image_analyze.json +++ b/tests/test-plugin/image_analyze.json @@ -1,81 +1,173 @@ { - "tags": [ - { - "name": "text", - "confidence": 0.9854570031166077 - }, - { - "name": "design", - "confidence": 0.9676092863082886 - }, - { - "name": "screenshot", - "confidence": 0.9044408798217773 - }, - { - "name": "graphic", - "confidence": 0.8791931867599487 - }, - { - "name": "red", - "confidence": 0.8448371887207031 - }, - { - "name": "font", - "confidence": 0.8189171552658081 - }, - { - "name": "graphics", - "confidence": 0.7044017314910889 - }, - { - "name": "logo", - "confidence": 0.6639798283576965 - }, - { - "name": "typography", - "confidence": 0.6407877802848816 - }, - { - "name": "maroon", - "confidence": 0.6387392282485962 - }, - { - "name": "illustration", - "confidence": 0.6350329518318176 - }, - { - "name": "carmine", - "confidence": 0.6345877647399902 - }, - { - "name": "abstract", - "confidence": 0.624541163444519 - }, - { - "name": "vector graphics", - "confidence": 0.21607014536857605 - }, - { - "name": "clipart", - "confidence": 0.20682862401008606 - } - ], - "description": { - "tags": [ - "text" - ], - "captions": [ - { - "text": "text", - "confidence": 0.8448402285575867 + "modelVersion": "2023-10-01", + "metadata": { + "height": 250, + "width": 772 + }, + "tagsResult": { + "values": [ + { + "name": "text", + "confidence": 0.9854570031166077 + }, + { + "name": "design", + "confidence": 0.9676092863082886 + }, + { + "name": "screenshot", + "confidence": 0.9044408798217773 + }, + { + "name": "graphic", + "confidence": 0.8791931867599487 + }, + { + "name": "red", + "confidence": 0.8448371887207031 + }, + { + "name": "font", + "confidence": 0.8189171552658081 + }, + { + "name": "graphics", + "confidence": 0.7044017314910889 + }, + { + "name": "logo", + "confidence": 0.6639798283576965 + }, + { + "name": "typography", + "confidence": 0.6407877802848816 + }, + { + "name": "maroon", + "confidence": 0.6387392282485962 + }, + { + "name": "illustration", + "confidence": 0.6350329518318176 + }, + { + "name": "carmine", + "confidence": 0.6345877647399902 + }, + { + "name": "abstract", + "confidence": 0.624541163444519 + }, + { + "name": "vector graphics", + "confidence": 0.21607014536857605 + }, + { + "name": "clipart", + "confidence": 0.20682862401008606 } ] }, - "requestId": "50fdeac0-9ef5-4e81-9e05-d392d15907ca", - "metadata": { - "height": 250, - "width": 772, - "format": "Png" + "captionResult": { + "text": "Text", + "confidence": 0.8448402285575867 + }, + "readResult": { + "blocks": [ + { + "lines": [ + { + "text": "CLASSIFAI_", + "boundingPolygon": [ + { + "x": 193, + "y": 337 + }, + { + "x": 614, + "y": 348 + }, + { + "x": 617, + "y": 507 + }, + { + "x": 187, + "y": 510 + } + ], + "words": [ + { + "text": "CLASSIFAI_", + "boundingPolygon": [ + { + "x": 188, + "y": 337 + }, + { + "x": 600, + "y": 341 + }, + { + "x": 599, + "y": 511 + }, + { + "x": 187, + "y": 510 + } + ], + "confidence": 0.991 + } + ] + }, + { + "text": "Test", + "boundingPolygon": [ + { + "x": 193, + "y": 337 + }, + { + "x": 614, + "y": 348 + }, + { + "x": 617, + "y": 507 + }, + { + "x": 187, + "y": 510 + } + ], + "words": [ + { + "text": "Test", + "boundingPolygon": [ + { + "x": 188, + "y": 337 + }, + { + "x": 600, + "y": 341 + }, + { + "x": 599, + "y": 511 + }, + { + "x": 187, + "y": 510 + } + ], + "confidence": 0.991 + } + ] + } + ] + } + ] } } diff --git a/tests/test-plugin/ocr.json b/tests/test-plugin/ocr.json deleted file mode 100644 index 1b98a7e05..000000000 --- a/tests/test-plugin/ocr.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "language": "en", - "textAngle": 0.0, - "orientation": "Up", - "regions": [ - { - "boundingBox": "319,188,904,146", - "lines": [ - { - "boundingBox": "319,188,899,59", - "words": [ - { - "boundingBox": "319,188,250,48", - "text": "ClassifAI" - }, - { - "boundingBox": "588,188,180,59", - "text": "Brings" - }, - { - "boundingBox": "783,191,56,44", - "text": "Al" - }, - { - "boundingBox": "856,190,104,46", - "text": "and" - }, - { - "boundingBox": "979,188,239,48", - "text": "Machine" - } - ] - }, - { - "boundingBox": "320,275,903,59", - "words": [ - { - "boundingBox": "320,275,245,59", - "text": "Learning" - }, - { - "boundingBox": "582,275,245,48", - "text": "Services" - }, - { - "boundingBox": "841,281,56,42", - "text": "to" - }, - { - "boundingBox": "912,277,311,46", - "text": "WordPress" - } - ] - } - ] - } - ], - "modelVersion": "2021-04-01" -}