From d3323c9c2e53438187ba78b0a916ca99a3f5a30f Mon Sep 17 00:00:00 2001 From: Florian Treml Date: Thu, 20 May 2021 09:37:24 +0200 Subject: [PATCH 1/2] BOT-2317 skip empty lines in excel utterances --- src/scripting/CompilerXlsx.js | 3 ++- test/compiler/compilerxlsx.spec.js | 17 +++++++++++++++++ .../xlsx/convos_2utterances_emptylines.xlsx | Bin 0 -> 5567 bytes 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/compiler/convos/xlsx/convos_2utterances_emptylines.xlsx diff --git a/src/scripting/CompilerXlsx.js b/src/scripting/CompilerXlsx.js index ab0d00fe..544c69b6 100644 --- a/src/scripting/CompilerXlsx.js +++ b/src/scripting/CompilerXlsx.js @@ -41,6 +41,7 @@ module.exports = class CompilerXlsx extends CompilerBase { const workbook = XLSX.read(scriptBuffer, { type: 'buffer' }) if (!workbook) throw new Error('Workbook not readable') + debug(`Loaded XLSX with Props: ${workbook.Props ? JSON.stringify(workbook.Props) : ''}`) const eol = this.caps[Capabilities.SCRIPTING_XLSX_EOL_WRITE] const maxEmptyRowCount = 10 @@ -278,7 +279,7 @@ module.exports = class CompilerXlsx extends CompilerBase { } rowindex++ - if (emptylines > 1) break + if (emptylines > maxEmptyRowCount) break } } diff --git a/test/compiler/compilerxlsx.spec.js b/test/compiler/compilerxlsx.spec.js index 84479cec..16cb29f6 100644 --- a/test/compiler/compilerxlsx.spec.js +++ b/test/compiler/compilerxlsx.spec.js @@ -99,6 +99,23 @@ describe('compiler.compilerxlsx', function () { assert.equal(context.utterances[0].name, 'TESTUTT1') assert.equal(context.utterances[1].name, 'TESTUTT2') }) + it('should read 2 utterances separated by empty lines', async function () { + const scriptBuffer = fs.readFileSync(path.resolve(__dirname, CONVOS_DIR, 'convos_2utterances_emptylines.xlsx')) + const context = buildContext() + + const caps = { + SCRIPTING_XLSX_SHEETNAMES_UTTERANCES: 'Utterances' + } + const compiler = new Compiler(context, Object.assign({}, DefaultCapabilities, caps)) + + compiler.Compile(scriptBuffer, 'SCRIPTING_TYPE_UTTERANCES') + assert.lengthOf(context.convos, 0) + assert.lengthOf(context.utterances, 2) + assert.equal(context.utterances[0].name, 'TESTUTT1') + assert.equal(context.utterances[0].utterances.length, 2) + assert.equal(context.utterances[1].name, 'TESTUTT2') + assert.equal(context.utterances[1].utterances.length, 3) + }) it('should read 2 convos from given region by letter', async function () { const scriptBuffer = fs.readFileSync(path.resolve(__dirname, CONVOS_DIR, 'convos_2convos_middle.xlsx')) const context = buildContext() diff --git a/test/compiler/convos/xlsx/convos_2utterances_emptylines.xlsx b/test/compiler/convos/xlsx/convos_2utterances_emptylines.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..4537ff4903d72125ae38887435f2bbc06b3044e9 GIT binary patch literal 5567 zcmaJ_by!q;w;p1ck#0dkP)b0$8%Mf_X6WugLb^jxI+T)56$c5)0V$;!Ql+ItS`ZMa z%bauW2cP#I*M6Sa^T%FmKYP9JTI>BSO%*I`asU_%1`tZrKmk__@8Z9iyN$C4Hy8T1 zBDqbyg9krq+y629q2P=RIKQMxRk4Xtfc_nmD@|=oVQ2X6!F@7P{J5%)_yiORUE zdul4f7+nFv(pnofc z@nN^JYGFXBNHZycO%$&0tW97;-`sX8AvHdaq8iCF#+9vZ%F()b#?#ckZ|Uh|jSVaA zZk9iA2AWADc02SwQ~`k_GX*lYE|M^a2>@vRYnq5I zp73$z_J+GVS;FB?Ts|(&aoRn}Svtjo4ogGWqVR3e%c=oZDj9O5C z754KS`ShNmWC&r1-|+g!nS`#*hNrV6u@pvKoU}OoSZV9`%1rum=ttXPeJLB*>&I{{ zA7b>mKHH{bbvekG@K4y{psB`vlX2WKz){vfw}wM5r|jYwZ=LxZPJ`84NdcG`NeDAv z`)JHI!Pq}=ZoXPYF8azVs7%%ZWGUm$bnuom&ZbZ94wHm8fp4>e)Ly1NtMN*|Sc1cs*!sqw{-F~cnc{^X0tW6e%``;Wgj{^ z>^yzEC9}aE``Gw^BMM`+>mzKoZe0`o~6t4xj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j-lz zQMre37k$wzEF2-C7g|K%zQm;iO{81{)#mUiJx)OV^`M)d*aY8QmbnZF~{v z-g@mrg=J~pDPYtu<`{v5s9ldV ze3m&m4Zd zE};BbUH2uBNGddNOX?&2^nTP6MOeDwf@ULRbV<%K4?aK2n7{O)>HIH6Bim*$7_pZETs^VaWCu8It_ z$htHn?q5;k< K7>;-T^7 Date: Tue, 25 May 2021 13:54:59 +0200 Subject: [PATCH 2/2] Version Bump --- package-lock.json | 8 ++++---- package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 79fafcd2..ab2d8f4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "botium-core", - "version": "1.11.3", + "version": "1.11.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -9106,9 +9106,9 @@ "dev": true }, "xlsx": { - "version": "0.16.9", - "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.16.9.tgz", - "integrity": "sha512-gxi1I3EasYvgCX1vN9pGyq920Ron4NO8PNfhuoA3Hpq6Y8f0ECXiy4OLrK4QZBnj1jx3QD+8Fq5YZ/3mPZ5iXw==", + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.0.tgz", + "integrity": "sha512-bZ36FSACiAyjoldey1+7it50PMlDp1pcAJrZKcVZHzKd8BC/z6TQ/QAN8onuqcepifqSznR6uKnjPhaGt6ig9A==", "requires": { "adler-32": "~1.2.0", "cfb": "^1.1.4", diff --git a/package.json b/package.json index 90a2ff38..8d99e7d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "botium-core", - "version": "1.11.3", + "version": "1.11.4", "description": "The Selenium for Chatbots", "main": "index.js", "module": "dist/botium-es.js", @@ -67,7 +67,7 @@ "uuid": "^8.3.2", "vm2": "^3.9.3", "write-yaml": "^1.0.0", - "xlsx": "^0.16.9", + "xlsx": "^0.17.0", "xregexp": "^5.0.2", "yaml": "^1.10.2" },