diff --git a/test/integration/api/admin/api_spec.js b/test/integration/api/admin/api_spec.js index e50bbb9a..6f9d84ae 100644 --- a/test/integration/api/admin/api_spec.js +++ b/test/integration/api/admin/api_spec.js @@ -8,6 +8,8 @@ const helper = require("../../../spechelper"); const describe = require('../../../testUtils/suite'); const wait = require('../../../testUtils/helpers/wait'); const uploadImage = helper.uploadImage; +const shouldTestAddOn = helper.shouldTestAddOn; +const ADDON_OCR = helper.ADDON_OCR; const callReusableTest = require('../../../testUtils/reusableTests/reusableTests').callReusableTest; const testConstants = require('../../../testUtils/testConstants'); const API_V2 = cloudinary.v2.api; @@ -861,6 +863,9 @@ describe("api", function () { }) }); it("should support requesting ocr when updating", async function () { + if (!shouldTestAddOn(ADDON_OCR)) { + this.skip(); + } // Update an image with ocr parameter const ocrType = "adv_ocr"; const updateResult = await API_V2.update(PUBLIC_ID_OCR_1, { ocr: ocrType }); @@ -872,6 +877,9 @@ describe("api", function () { expect(updateResult.info.ocr).to.have.property(ocrType); }); it("should return 'Illegal value' errors for unknown ocr types", function () { + if (!shouldTestAddOn(ADDON_OCR)) { + this.skip(); + } this.timeout(TIMEOUT.MEDIUM); return API_V2.update(PUBLIC_ID_OCR_1, {ocr: 'illegal'}) .then( diff --git a/test/integration/api/uploader/uploader_spec.js b/test/integration/api/uploader/uploader_spec.js index 3611aded..7d1b23ff 100644 --- a/test/integration/api/uploader/uploader_spec.js +++ b/test/integration/api/uploader/uploader_spec.js @@ -18,6 +18,8 @@ const LARGE_VIDEO = helper.LARGE_VIDEO; const EMPTY_IMAGE = helper.EMPTY_IMAGE; const RAW_FILE = helper.RAW_FILE; const uploadImage = helper.uploadImage; +const shouldTestAddOn = helper.shouldTestAddOn; +const ADDON_OCR = helper.ADDON_OCR; const TEST_ID = Date.now(); const METADATA_FIELD_UNIQUE_EXTERNAL_ID = 'metadata_field_external_id_' + TEST_ID; @@ -1120,6 +1122,9 @@ describe("uploader", function () { const ocrType = "adv_ocr"; it("should support requesting ocr when uploading", async function () { + if (!shouldTestAddOn(ADDON_OCR)) { + this.skip(); + } // Upload an image and request ocr details in the response const result = await UPLOADER_V2.upload(IMAGE_FILE, {ocr: ocrType, tags: [TEST_TAG]}); @@ -1133,6 +1138,9 @@ describe("uploader", function () { }); it("should support ocr parameter in explicit", async function () { + if (!shouldTestAddOn(ADDON_OCR)) { + this.skip(); + } // Upload an image const uploadResult = await UPLOADER_V2.upload(IMAGE_FILE, { tags: [TEST_TAG] diff --git a/test/spechelper.js b/test/spechelper.js index de4f5b64..9021b730 100644 --- a/test/spechelper.js +++ b/test/spechelper.js @@ -27,6 +27,32 @@ exports.ICON_FILE = "test/.resources/favicon.ico"; exports.VIDEO_URL = "http://res.cloudinary.com/demo/video/upload/dog.mp4"; exports.IMAGE_URL = "http://res.cloudinary.com/demo/image/upload/sample"; +exports.ADDON_ALL = 'all'; // Test all addons. +exports.ADDON_ASPOSE = 'aspose'; // Aspose document conversion. +exports.ADDON_AZURE = 'azure'; // Microsoft azure video indexer. +exports.ADDON_BG_REMOVAL = 'bgremoval'; // Cloudinary AI background removal. +exports.ADDON_FACIAL_ATTRIBUTES_DETECTION = 'facialattributesdetection'; // Advanced facial attributes detection. +exports.ADDON_GOOGLE = 'google'; /* Google AI video moderation, google AI + video transcription, google auto tagging, + google automatic video tagging, + google translation. + */ +exports.ADDON_IMAGGA = 'imagga'; // Imagga auto tagging, crop and scale. +exports.ADDON_JPEGMINI = 'jpegmini'; // JPEGmini image optimization. +exports.ADDON_LIGHTROOM = 'lightroom'; // Adobe photoshop lightroom (BETA). +exports.ADDON_METADEFENDER = 'metadefender'; // MetaDefender anti-malware protection. +exports.ADDON_NEURAL_ARTWORK = 'neuralartwork'; // Neural artwork style transfer. +exports.ADDON_OBJECT_AWARE_CROPPING = 'objectawarecropping'; // Cloudinary object-aware cropping. +exports.ADDON_OCR = 'ocr'; // OCR text detection and extraction. +exports.ADDON_PIXELZ = 'pixelz'; // Remove the background. +exports.ADDON_REKOGNITION = 'rekognition'; /* Amazon rekognition AI moderation, + amazon rekognition auto tagging, + amazon rekognition celebrity detection. + */ +exports.ADDON_URL2PNG = 'url2png'; // URL2PNG website screenshots. +exports.ADDON_VIESUS = 'viesus'; // VIESUS automatic image enhancement. +exports.ADDON_WEBPURIFY = 'webpurify'; // WebPurify image moderation. + const { TEST_TAG } = require('./testUtils/testConstants').TAGS; exports.SAMPLE_VIDEO_SOURCES = [ @@ -259,4 +285,18 @@ exports.toISO8601DateOnly = function (timestamp) { return date.toISOString().split('T')[0]; }; +/** + * Checks if tests for an addon should be executed. + * + * @param {string} addOn + * @returns {boolean} + */ +exports.shouldTestAddOn = function (addOn) { + const cldTestAddons = (process.env.CLD_TEST_ADDONS || '').toLowerCase(); + if (cldTestAddons === this.ADDON_ALL) { + return true; + } + return cldTestAddons.trim().split(',').includes(addOn.toLowerCase()) +} +