Skip to content

Commit

Permalink
- Fixes issue with secrets from secrets files by changing order of lo…
Browse files Browse the repository at this point in the history
…ading dependencies (moved into main). #25

- Fix to issue with webhooks causing failing test
- Updated NotificationsParams test to remove unneeded time zone dependent string causing failing test
  • Loading branch information
Kevin Dolan committed May 14, 2024
1 parent 729ecb3 commit e8108e5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,6 @@ dist
.tern-port

# MacOS junk
.DS_Store
.DS_Store

.idea
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ const { program } = require('commander');
setupProgram();

const {checkLicense} = require("./util/licence");

const {toneDetector} = require('./bin/toneDetector');
const {csvToConfig} = require('./bin/csvToConfig');
const {fdToneNotify} = require('./bin/fdToneNotify');
const {testNotifications} = require('./bin/testNotifications');
const log = require('./util/logger');
const {populateSecretsEnvVar} = require("./util/config.secrets");

Expand Down Expand Up @@ -46,6 +41,11 @@ async function main(){
const options = program.opts();
populateSecretsEnvVar({secretsPath: options.secretsFile, forceSecretsFile: options.forceSecretsFile});

const {fdToneNotify} = require('./bin/fdToneNotify');
const {toneDetector} = require('./bin/toneDetector');
const {csvToConfig} = require('./bin/csvToConfig');
const {testNotifications} = require('./bin/testNotifications');

if(options.csvToConfig)
csvToConfig();
else if(options.allToneDetector)
Expand Down
4 changes: 2 additions & 2 deletions notifiers/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function postJson({address, headers={}, timestamp, tones, matchAverages, f
}

async function postMultiPartFormDataWithFile({address, headers={}, timestamp, tones=[], matchAverages=[], filename,
recordingRelPath, detectorName, custom={}, isTest}){
recordingRelPath, detectorName, custom={}, isTest=false}){

_fillEnvVarsHeaders(headers);
const form = new FormData();
Expand All @@ -40,7 +40,7 @@ async function postMultiPartFormDataWithFile({address, headers={}, timestamp, to
form.append('matchAverages', matchAverages.toString());
form.append('detectorName', detectorName);
form.append('custom', JSON.stringify(custom));
form.append(isTest, isTest);
form.append("isTest", isTest);

const buffer = fs.readFileSync(recordingRelPath);
form.append('file', buffer, {
Expand Down
8 changes: 4 additions & 4 deletions test/obj/NotificationParams.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ describe("NotificationParams", function() {

var emails = notificationParams.getEmails('PRE');
expect(emails).to.have.lengthOf(1);
expect(emails[0].text).to.have.string("August 1st 2022, 0:00:00");
expect(emails[0].subject).to.have.string("August 1st 2022, 0:00:00");
expect(emails[0].text).to.have.string("August 1st 2022,");
expect(emails[0].subject).to.have.string("August 1st 2022,");

var emails = notificationParams.getEmails('POST');
expect(emails).to.have.lengthOf(1);
expect(emails[0].text).to.have.string("August 1st 2022, 0:00:00");
expect(emails[0].subject).to.have.string("August 1st 2022, 0:00:00");
expect(emails[0].text).to.have.string("August 1st 2022,");
expect(emails[0].subject).to.have.string("August 1st 2022,");
});

it("should not modify the original email objects", function() {
Expand Down

0 comments on commit e8108e5

Please sign in to comment.