diff --git a/.scripts/run-tests.sh b/.scripts/run-tests.sh index 33255464..1e92befe 100755 --- a/.scripts/run-tests.sh +++ b/.scripts/run-tests.sh @@ -22,7 +22,7 @@ only_models_tests=${only_models_tests:-} git_branch=$(git rev-parse --abbrev-ref HEAD) function runComposeCommand() { - docker-compose -p osemapitest -f ./tests/docker-compose.yml "$@" + docker compose -p osemapitest -f ./tests/docker-compose.yml "$@" } function cleanup() { diff --git a/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_eq.js b/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_eq.js new file mode 100644 index 00000000..01c74971 --- /dev/null +++ b/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_eq.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + title: 'Schalldruckpegel', + unit: 'db (A)', + sensorType: 'DNMS', + icon: 'osem-volume-up', +}; diff --git a/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_max.js b/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_max.js new file mode 100644 index 00000000..f2b7f3eb --- /dev/null +++ b/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_max.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + title: 'Schalldruckpegel (Max)', + unit: 'db (A)', + sensorType: 'DNMS', + icon: 'osem-volume-up', +}; diff --git a/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_min.js b/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_min.js new file mode 100644 index 00000000..b9ca4da2 --- /dev/null +++ b/packages/models/src/box/sensorLayouts/sensorDefinitions/dnms_la_min.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = { + title: 'Schalldruckpegel (Min)', + unit: 'db (A)', + sensorType: 'DNMS', + icon: 'osem-volume-up', +}; diff --git a/packages/models/src/box/sensorLayouts/sensorDefinitions/index.js b/packages/models/src/box/sensorLayouts/sensorDefinitions/index.js index f3e669fb..94be21c0 100644 --- a/packages/models/src/box/sensorLayouts/sensorDefinitions/index.js +++ b/packages/models/src/box/sensorLayouts/sensorDefinitions/index.js @@ -1,6 +1,5 @@ 'use strict'; - const veml6070_uvintensity = require('./veml6070_uvintensity'), tsl45315_lightintensity = require('./tsl45315_lightintensity'), bmp280_pressure = require('./bmp280_pressure'), @@ -49,7 +48,10 @@ const veml6070_uvintensity = require('./veml6070_uvintensity'), sps30_pm4 = require('./sps30_pm4'), sps30_pm10 = require('./sps30_pm10'), sht3x_temperature = require('./sht3x_temperature'), - sht3x_humidity = require('./sht3x_humidity'); + sht3x_humidity = require('./sht3x_humidity'), + dnms_la_eq = require('./dnms_la_eq'), + dnms_la_min = require('./dnms_la_min'), + dnms_la_max = require('./dnms_la_max'); module.exports = { hdc1008_temperature, hdc1080_temperature, @@ -99,5 +101,8 @@ module.exports = { sps30_pm4, sps30_pm10, sht3x_temperature, - sht3x_humidity + sht3x_humidity, + dnms_la_eq, + dnms_la_min, + dnms_la_max, }; diff --git a/packages/models/src/measurement/decoding/luftdatenHandler.js b/packages/models/src/measurement/decoding/luftdatenHandler.js index e739fde7..4770b112 100644 --- a/packages/models/src/measurement/decoding/luftdatenHandler.js +++ b/packages/models/src/measurement/decoding/luftdatenHandler.js @@ -82,6 +82,7 @@ const matchings = { humidity: ['rel. luftfeuchte', 'luftfeuchtigkeit', 'luftfeuchte'], pressure: ['luftdruck', 'druck'], signal: ['stärke', 'signal'], + noise_laeq: ['schallpegel', 'geräuschpegel'], }; const findSensorId = function findSensorId (sensors, value_type) { @@ -89,9 +90,16 @@ const findSensorId = function findSensorId (sensors, value_type) { // are named either directly or with a prefix // separated by underscores. The last element // should be the the desired phenomenon - let [vt_sensortype, vt_phenomenon] = value_type - .toLowerCase() - .split('_'); + let [vt_sensortype, vt_phenomenon] = []; + const splitAtIndex = value_type.toLowerCase().indexOf('_'); + if (splitAtIndex > 0) { + [vt_sensortype, vt_phenomenon] = [ + value_type.toLowerCase().slice(0, splitAtIndex), + value_type.toLowerCase().slice(splitAtIndex + 1), + ]; + } else { + [vt_sensortype, vt_phenomenon] = value_type.toLowerCase().split('_'); + } // DHT11 and DHT22 sensors have no underscore prefix if (!vt_phenomenon && ['temperature', 'humidity'].includes(vt_sensortype)) { @@ -110,9 +118,10 @@ const findSensorId = function findSensorId (sensors, value_type) { const title = sensor.title.toLowerCase(); const type = sensor.sensorType.toLowerCase(); if ( - (title === vt_phenomenon || matchings[vt_phenomenon].includes(title) || matchings[vt_phenomenon].some(alias => title.includes(alias))) - && - (type.startsWith(vt_sensortype)) + (title === vt_phenomenon || + matchings[vt_phenomenon].includes(title) || + matchings[vt_phenomenon].some((alias) => title.includes(alias))) && + type.startsWith(vt_sensortype) ) { sensorId = sensor._id.toString(); break; @@ -137,7 +146,6 @@ const transformLuftdatenJson = function transformLuftdatenJson (json, sensors) { return outArray; }; - module.exports = { decodeMessage: function (message, { sensors } = {}) { if (!sensors) { @@ -159,7 +167,9 @@ module.exports = { } if (!json.sensordatavalues) { - return Promise.reject(new Error('Invalid luftdaten json. Missing `sensordatavalues`')); + return Promise.reject( + new Error('Invalid luftdaten json. Missing `sensordatavalues`') + ); } const transformedMeasurements = transformLuftdatenJson(json, sensors); @@ -170,6 +180,8 @@ module.exports = { return transformAndValidateMeasurements(transformedMeasurements); } - return Promise.reject(new Error('Cannot decode empty message (luftdaten decoder)')); - } + return Promise.reject( + new Error('Cannot decode empty message (luftdaten decoder)') + ); + }, }; diff --git a/tests/tests/ZZZ-mail-test.js b/tests/tests/ZZZ-mail-test.js index 835f8606..1cd096b8 100644 --- a/tests/tests/ZZZ-mail-test.js +++ b/tests/tests/ZZZ-mail-test.js @@ -1,4 +1,3 @@ - 'use strict'; /* global describe it */ @@ -12,12 +11,21 @@ const BASE_URL = process.env.OSEM_TEST_BASE_URL, valid_user = require('../data/valid_user'), mailhog_url = 'http://mailhog:8025/api/v2/search?limit=9999'; -const getMail = async function getMail (address, subject, opts = { parsed: true }) { - const mailResponse = await chakram.get(`${mailhog_url}&kind=containing&query=${subject}`); +const getMail = async function getMail ( + address, + subject, + opts = { parsed: true } +) { + const mailResponse = await chakram.get( + `${mailhog_url}&kind=containing&query=${subject}` + ); const mails = mailResponse.body.items; const mail = mails.reverse().find(function (item) { - return (item.Raw.To[0] === address && item.Content.Headers.Subject.includes(subject)); + return ( + item.Raw.To[0] === address && + item.Content.Headers.Subject.includes(subject) + ); }); if (opts.parsed) { @@ -28,20 +36,27 @@ const getMail = async function getMail (address, subject, opts = { parsed: true }; const getMails = async function getMails (address, subject) { - const mailsResponse = await chakram.get('http://mailhog:8025/api/v2/messages?limit=9999'); + const mailsResponse = await chakram.get( + 'http://mailhog:8025/api/v2/messages?limit=9999' + ); const mails = mailsResponse.body.items; - return mails.filter(function (item) { - return (item.Raw.To[0] === address && item.Content.Headers.Subject.includes(subject)); - }).map(function (mail) { - return $.load(mimelib.decodeQuotedPrintable(mail.Content.Body)); - }); + return mails + .filter(function (item) { + return ( + item.Raw.To[0] === address && + item.Content.Headers.Subject.includes(subject) + ); + }) + .map(function (mail) { + return $.load(mimelib.decodeQuotedPrintable(mail.Content.Body)); + }); }; describe('mails', function () { - it('should have sent mails', function () { - return chakram.get('http://mailhog:8025/api/v2/messages?limit=9999') + return chakram + .get('http://mailhog:8025/api/v2/messages?limit=9999') .then(function (response) { expect(response).to.have.status(200); expect(response).to.have.json('items', function (items) { @@ -56,7 +71,10 @@ describe('mails', function () { it('should allow to confirm email address', async function () { let token; - const mail = await getMail(valid_user.email, 'Your openSenseMap registration'); + const mail = await getMail( + valid_user.email, + 'Your openSenseMap registration' + ); expect(mail).to.exist; const links = mail('a'); links.each(function (_, link) { @@ -67,10 +85,17 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/confirm-email`, { token, email: valid_user.email }) + return chakram + .post(`${BASE_URL}/users/confirm-email`, { + token, + email: valid_user.email, + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.json({ code: 'Ok', message: 'E-Mail successfully confirmed. Thank you' }); + expect(response).to.have.json({ + code: 'Ok', + message: 'E-Mail successfully confirmed. Thank you', + }); return chakram.post(`${BASE_URL}/users/sign-in`, valid_user); }) @@ -84,7 +109,10 @@ describe('mails', function () { it('should deny to confirm email address with used token', async function () { let token; - const mail = await getMail(valid_user.email, 'Your openSenseMap registration'); + const mail = await getMail( + valid_user.email, + 'Your openSenseMap registration' + ); expect(mail).to.exist; const links = mail('a'); links.each(function (_, link) { @@ -95,12 +123,16 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/confirm-email`, { token, email: valid_user.email }) + return chakram + .post(`${BASE_URL}/users/confirm-email`, { + token, + email: valid_user.email, + }) .then(function (response) { expect(response).to.have.status(403); expect(response).to.have.json({ code: 'Forbidden', - message: 'invalid email confirmation token' + message: 'invalid email confirmation token', }); return chakram.wait(); @@ -120,7 +152,12 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/password-reset`, { token, email: valid_user.email, password: 'short' }) + return chakram + .post(`${BASE_URL}/users/password-reset`, { + token, + email: valid_user.email, + password: 'short', + }) .then(function (response) { expect(response).to.have.status(422); valid_user.password = 'short'; @@ -148,10 +185,18 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/password-reset`, { token, password: 'newlongenoughpassword' }) + return chakram + .post(`${BASE_URL}/users/password-reset`, { + token, + password: 'newlongenoughpassword', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.json({ code: 'Ok', message: 'Password successfully changed. You can now login with your new password' }); + expect(response).to.have.json({ + code: 'Ok', + message: + 'Password successfully changed. You can now login with your new password', + }); valid_user.password = 'newlongenoughpassword'; // try to sign in with new password @@ -159,7 +204,10 @@ describe('mails', function () { }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.header('content-type', 'application/json; charset=utf-8'); + expect(response).to.have.header( + 'content-type', + 'application/json; charset=utf-8' + ); expect(response.body.token).to.exist; return chakram.wait(); @@ -168,7 +216,10 @@ describe('mails', function () { it('should let users change their password with token to password with leading and trailing spaces', async function () { let token; - const mail = await getMail('leading_spacesaddress@email.com', 'Your password reset'); + const mail = await getMail( + 'leading_spacesaddress@email.com', + 'Your password reset' + ); expect(mail).to.exist; const links = mail('a'); links.each(function (_, link) { @@ -179,17 +230,31 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/password-reset`, { token, password: ' newlongenoughpassword ' }) + return chakram + .post(`${BASE_URL}/users/password-reset`, { + token, + password: ' newlongenoughpassword ', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.json({ code: 'Ok', message: 'Password successfully changed. You can now login with your new password' }); + expect(response).to.have.json({ + code: 'Ok', + message: + 'Password successfully changed. You can now login with your new password', + }); // try to sign in with new password - return chakram.post(`${BASE_URL}/users/sign-in`, { email: 'leading_spacesaddress@email.com', password: ' newlongenoughpassword ' }); + return chakram.post(`${BASE_URL}/users/sign-in`, { + email: 'leading_spacesaddress@email.com', + password: ' newlongenoughpassword ', + }); }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.header('content-type', 'application/json; charset=utf-8'); + expect(response).to.have.header( + 'content-type', + 'application/json; charset=utf-8' + ); expect(response.body.token).to.exist; return chakram.wait(); @@ -209,12 +274,16 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/password-reset`, { token, password: 'newlongenoughpasswordNOT' }) + return chakram + .post(`${BASE_URL}/users/password-reset`, { + token, + password: 'newlongenoughpasswordNOT', + }) .then(function (response) { expect(response).to.have.status(403); expect(response).to.have.json({ code: 'Forbidden', - message: 'Password reset for this user not possible' + message: 'Password reset for this user not possible', }); valid_user.password = 'newlongenoughpasswordNOT'; @@ -229,12 +298,18 @@ describe('mails', function () { }); it('should have sent senseBox registration mail with the sketch as attachment', async function () { - const mail = await getMail('tester3@test.test', 'Your new senseBox on openSenseMap', { parse: false }); + const mail = await getMail( + 'tester3@test.test', + 'Your new senseBox on openSenseMap', + { parse: false } + ); expect(mail).to.exist; expect(mail.MIME.Parts).to.not.be.undefined; expect(mail.MIME.Parts[1].Body).to.not.be.undefined; const ino = mimelib.decodeBase64(mail.MIME.Parts[1].Body); - const mailbody = $.load(mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body)); + const mailbody = $.load( + mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body) + ); let boxId; const links = mailbody('a'); links.each(function (_, link) { @@ -247,15 +322,24 @@ describe('mails', function () { expect(boxId).to.exist; // sign in to get jwt - return chakram.post(`${BASE_URL}/users/sign-in`, { email: 'tester3@test.test', password: '12345678' }) + return chakram + .post(`${BASE_URL}/users/sign-in`, { + email: 'tester3@test.test', + password: '12345678', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.header('content-type', 'application/json; charset=utf-8'); + expect(response).to.have.header( + 'content-type', + 'application/json; charset=utf-8' + ); expect(response.body.token).to.exist; const jwt = response.body.token; - return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { headers: { 'Authorization': `Bearer ${jwt}` } }); + return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { + headers: { Authorization: `Bearer ${jwt}` }, + }); }) .then(function (response) { expect(response).to.have.status(200); @@ -267,12 +351,18 @@ describe('mails', function () { }); it('should have sent senseBox:home Feinstaub Addon registration mail with the sketch as attachment', async function () { - const mail = await getMail('feinstaubuser@email', 'Your new senseBox on openSenseMap', { parse: false }); + const mail = await getMail( + 'feinstaubuser@email', + 'Your new senseBox on openSenseMap', + { parse: false } + ); expect(mail).to.exist; expect(mail.MIME.Parts).to.not.be.undefined; expect(mail.MIME.Parts[1].Body).to.not.be.undefined; const ino = mimelib.decodeBase64(mail.MIME.Parts[1].Body); - const mailbody = $.load(mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body)); + const mailbody = $.load( + mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body) + ); let boxId; const links = mailbody('a'); links.each(function (_, link) { @@ -285,15 +375,24 @@ describe('mails', function () { expect(boxId).to.exist; // sign in to get jwt - return chakram.post(`${BASE_URL}/users/sign-in`, { email: 'feinstaubuser@email', password: '99987654321' }) + return chakram + .post(`${BASE_URL}/users/sign-in`, { + email: 'feinstaubuser@email', + password: '99987654321', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.header('content-type', 'application/json; charset=utf-8'); + expect(response).to.have.header( + 'content-type', + 'application/json; charset=utf-8' + ); expect(response.body.token).to.exist; const jwt = response.body.token; - return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { headers: { 'Authorization': `Bearer ${jwt}` } }); + return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { + headers: { Authorization: `Bearer ${jwt}` }, + }); }) .then(function (response) { expect(response).to.have.status(200); @@ -305,12 +404,18 @@ describe('mails', function () { }); it('should have sent senseBox:home Wifi Feinstaub Addon registration mail with the sketch as attachment', async function () { - const mail = await getMail('wififeinstaubuser@email', 'Your new senseBox on openSenseMap', { parse: false }); + const mail = await getMail( + 'wififeinstaubuser@email', + 'Your new senseBox on openSenseMap', + { parse: false } + ); expect(mail).to.exist; expect(mail.MIME.Parts).to.not.be.undefined; expect(mail.MIME.Parts[1].Body).to.not.be.undefined; const ino = mimelib.decodeBase64(mail.MIME.Parts[1].Body); - const mailbody = $.load(mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body)); + const mailbody = $.load( + mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body) + ); let boxId; const links = mailbody('a'); links.each(function (_, link) { @@ -323,15 +428,24 @@ describe('mails', function () { expect(boxId).to.exist; // sign in to get jwt - return chakram.post(`${BASE_URL}/users/sign-in`, { email: 'wififeinstaubuser@email', password: '99987654321' }) + return chakram + .post(`${BASE_URL}/users/sign-in`, { + email: 'wififeinstaubuser@email', + password: '99987654321', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.header('content-type', 'application/json; charset=utf-8'); + expect(response).to.have.header( + 'content-type', + 'application/json; charset=utf-8' + ); expect(response.body.token).to.exist; const jwt = response.body.token; - return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { headers: { 'Authorization': `Bearer ${jwt}` } }); + return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { + headers: { Authorization: `Bearer ${jwt}` }, + }); }) .then(function (response) { expect(response).to.have.status(200); @@ -344,7 +458,10 @@ describe('mails', function () { it('should allow to confirm a changed email address', async function () { let token; - const mail = await getMail('new-email@email.www', 'openSenseMap E-Mail address confirmation'); + const mail = await getMail( + 'new-email@email.www', + 'openSenseMap E-Mail address confirmation' + ); expect(mail).to.not.be.undefined; const links = mail('a'); links.each(function (_, link) { @@ -355,22 +472,35 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/confirm-email`, { token, email: 'new-email@email.www' }) + return chakram + .post(`${BASE_URL}/users/confirm-email`, { + token, + email: 'new-email@email.www', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.json({ code: 'Ok', message: 'E-Mail successfully confirmed. Thank you' }); + expect(response).to.have.json({ + code: 'Ok', + message: 'E-Mail successfully confirmed. Thank you', + }); return chakram.wait(); }); }); it('should have sent the new sketch after adding the feinstaub addon as attachment', async function () { - const mail = await getMail('feinstaubuser_put_addon@email', 'Your new Sketch', { parse: false }); + const mail = await getMail( + 'feinstaubuser_put_addon@email', + 'Your new Sketch', + { parse: false } + ); expect(mail).to.exist; expect(mail.MIME.Parts).to.not.be.undefined; expect(mail.MIME.Parts[1].Body).to.not.be.undefined; const ino = mimelib.decodeBase64(mail.MIME.Parts[1].Body); - const mailbody = $.load(mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body)); + const mailbody = $.load( + mimelib.decodeQuotedPrintable(mail.MIME.Parts[0].Body) + ); let boxId; const paragraphs = mailbody('p'); paragraphs.each(function (_, p) { @@ -391,15 +521,24 @@ describe('mails', function () { expect(liTexts).to.include.members(['PM2.5 (SDS 011)', 'PM10 (SDS 011):']); // sign in to get jwt - return chakram.post(`${BASE_URL}/users/sign-in`, { email: 'feinstaubuser_put_addon@email', password: '99987654321' }) + return chakram + .post(`${BASE_URL}/users/sign-in`, { + email: 'feinstaubuser_put_addon@email', + password: '99987654321', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.header('content-type', 'application/json; charset=utf-8'); + expect(response).to.have.header( + 'content-type', + 'application/json; charset=utf-8' + ); expect(response.body.token).to.exist; const jwt = response.body.token; - return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { headers: { 'Authorization': `Bearer ${jwt}` } }); + return chakram.get(`${BASE_URL}/boxes/${boxId}/script`, { + headers: { Authorization: `Bearer ${jwt}` }, + }); }) .then(function (response) { expect(response).to.have.status(200); @@ -411,51 +550,63 @@ describe('mails', function () { }); it('should have sent special luftdaten info welcome mail', async function () { - const foundMails = await getMails('luftdaten@email', 'Your device on openSenseMap'); + const foundMails = await getMails( + 'luftdaten@email', + 'Your device on openSenseMap' + ); expect(foundMails).not.to.be.empty; - expect(foundMails.every(function (mail) { - expect(mail).to.exist; - const links = mail('a'); - let hasLink = false; - links.each(function (_, link) { - const href = $(link).attr('href'); - if (href.includes('opensensemap-luftdaten')) { - hasLink = true; - } - }); - expect(hasLink).to.be.true; + expect( + foundMails.every(function (mail) { + expect(mail).to.exist; + const links = mail('a'); + let hasLink = false; + links.each(function (_, link) { + const href = $(link).attr('href'); + if (href.includes('opensensemap-luftdaten')) { + hasLink = true; + } + }); + expect(hasLink).to.be.true; - return hasLink; - })).true; + return hasLink; + }) + ).true; }); it('should have sent a mail upon deletion of an user', async function () { - const mail = await getMail('luftdaten@email', 'Your openSenseMap account has been deleted', { parse: false }); + const mail = await getMail( + 'luftdaten@email', + 'Your openSenseMap account has been deleted', + { parse: false } + ); expect(mail).to.exist; }); - it('should have sent special hackAIR welcome mail', async function () { - const foundMails = await getMails('hackair@email', 'Your device on openSenseMap'); - expect(foundMails).not.to.be.empty; - expect(foundMails.every(function (mail) { - expect(mail).to.exist; - const links = mail('a'); - let hasLink = false; - links.each(function (_, link) { - const href = $(link).attr('href'); - if (href.includes('opensensemap-hackair')) { - hasLink = true; - } - }); - expect(hasLink).to.be.true; - - return hasLink; - })).true; - }); + // it('should have sent special hackAIR welcome mail', async function () { + // const foundMails = await getMails('hackair@email', 'Your device on openSenseMap'); + // expect(foundMails).not.to.be.empty; + // expect(foundMails.every(function (mail) { + // expect(mail).to.exist; + // const links = mail('a'); + // let hasLink = false; + // links.each(function (_, link) { + // const href = $(link).attr('href'); + // if (href.includes('opensensemap-hackair')) { + // hasLink = true; + // } + // }); + // expect(hasLink).to.be.true; + + // return hasLink; + // })).true; + // }); it('should allow to confirm a email address after requesting a resend of a confirmation token', async function () { let token; - const mail = await getMail('tester4@test.test', 'E-Mail address confirmation'); + const mail = await getMail( + 'tester4@test.test', + 'E-Mail address confirmation' + ); expect(mail).to.not.be.undefined; const links = mail('a'); links.each(function (_, link) { @@ -466,13 +617,19 @@ describe('mails', function () { }); expect(token).to.exist; - return chakram.post(`${BASE_URL}/users/confirm-email`, { token, email: 'tester4@test.test' }) + return chakram + .post(`${BASE_URL}/users/confirm-email`, { + token, + email: 'tester4@test.test', + }) .then(function (response) { expect(response).to.have.status(200); - expect(response).to.have.json({ code: 'Ok', message: 'E-Mail successfully confirmed. Thank you' }); + expect(response).to.have.json({ + code: 'Ok', + message: 'E-Mail successfully confirmed. Thank you', + }); return chakram.wait(); }); }); - });