Skip to content

Commit

Permalink
Fix #30 tags regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
boly38 committed May 28, 2024
1 parent 3817d4f commit d3f6709
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/plugins/Plantnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export default class Plantnet {
config.pluginName = plugin.getName();
}
if (pluginTags === undefined) {
config.pluginTags = plugin.getPluginTags();
pluginTags = plugin.getPluginTags();
}
if (pluginMoreTags !== undefined) {
config.pluginTags = [pluginTags, pluginMoreTags].join(' ');
pluginTags = [pluginTags, pluginMoreTags].join(' ');
}
// if at least one want to simulate then simulate
const doSimulateIdentify = plugin.plantnetSimulate || isSet(simulateIdentifyCase);
Expand Down
17 changes: 11 additions & 6 deletions tests/30_plugin-plantnet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {_expectNoError, initEnv, testLogger} from "./libTest.js";
initEnv();
const appConfig = ApplicationConfig.getInstance();
const pluginConfigDoSimulate = {doSimulate: true};
const defaultTags = "#BeSPlantnet #IndentificationDePlantes";
let plugin;

// v2 tests example : https://github.com/PLhery/node-twitter-api-v2/blob/master/test/tweet.v2.test.ts
Expand All @@ -19,25 +20,27 @@ describe("🧪🧪 30 - Pl@ntNet plugin", function () {

it("simulate plantnet identification with good score and images", async () => {
await verifyPlantnetProcessResult(pluginConfigDoSimulate,
": Pl@ntNet identifie (à 85.09%) Pancratium SIMULATINIUM");
[": Pl@ntNet identifie (à 85.09%) Pancratium SIMULATINIUM", defaultTags]);
}).timeout(60 * 1000);

it("simulate plantnet identification with good score no image", async () => {
await verifyPlantnetProcessResult({...pluginConfigDoSimulate, simulateIdentifyCase: "GoodScoreNoImage"},
": Pl@ntNet identifie (à 82.23%) NoImagium SIMULATINIUM");
[": Pl@ntNet identifie (à 82.23%) NoImagium SIMULATINIUM", defaultTags]);
}).timeout(60 * 1000);

it("simulate plantnet identification with bad score", async () => {
await verifyPlantnetProcessResult({...pluginConfigDoSimulate, simulateIdentifyCase: "BadScore"},
"identification par Pl@ntNet n'a pas donné de résultat assez concluant");
["identification par Pl@ntNet n'a pas donné de résultat assez concluant"]);
}).timeout(60 * 1000);

});

async function verifyPlantnetProcessResult(config, expectedResultText) {
async function verifyPlantnetProcessResult(config, expectedResultTexts) {
const result = await plugin.process(config).catch(err => {
if (err.status === 202) {
testLogger.debug("plugin.process : no result");
const notice = "we may improve test by simulating bluesky candidate search, when (live) 0 candidate, coverage is poor";
// workaround: add "fleur" to questionsPlantnet
testLogger.info(`plugin.process : no result - ${notice}`);
} else {
_expectNoError(err);
}
Expand All @@ -48,6 +51,8 @@ async function verifyPlantnetProcessResult(config, expectedResultText) {
expect(result.html).not.to.be.empty;
expect(result.text).not.to.be.empty;
// testLogger.debug(result.text)
expect(result.text, `expected: ${result.text}`).to.contains(expectedResultText);
for (const text of expectedResultTexts) {
expect(result.text, `expected: ${result.text}`).to.contains(text);
}
}
}

0 comments on commit d3f6709

Please sign in to comment.