Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/integration/api/admin/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 });
Expand All @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions test/integration/api/uploader/uploader_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]});

Expand All @@ -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]
Expand Down
40 changes: 40 additions & 0 deletions test/spechelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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())
}