Merge branch 'master' of github.com:Mailtrain-org/mailtrain into access
Conflicts: package.json
This commit is contained in:
commit
f776170854
16 changed files with 395 additions and 172 deletions
|
@ -311,7 +311,7 @@ function addCustomField(listId, name, defaultValue, type, group, groupTemplate,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (module.exports.grouped.indexOf(type) < 0) {
|
if (module.exports.grouped.indexOf(type) < 0) {
|
||||||
column = ('custom_' + slugify(name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9\_]/g, '');
|
column = ('custom_' + slugify(name, '_') + '_' + shortid.generate()).toLowerCase().replace(/[^a-z0-9_]/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = 'INSERT INTO custom_fields (`list`, `name`, `key`,`default_value`, `type`, `group`, `group_template`, `column`, `visible`) VALUES(?,?,?,?,?,?,?,?,?)';
|
let query = 'INSERT INTO custom_fields (`list`, `name`, `key`,`default_value`, `type`, `group`, `group_template`, `column`, `visible`) VALUES(?,?,?,?,?,?,?,?,?)';
|
||||||
|
@ -398,6 +398,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
// ignore missing values
|
// ignore missing values
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/* eslint-disable indent */
|
||||||
switch (field.type) {
|
switch (field.type) {
|
||||||
case 'text':
|
case 'text':
|
||||||
case 'website':
|
case 'website':
|
||||||
|
@ -413,7 +414,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
visible: !!field.visible,
|
visible: !!field.visible,
|
||||||
mergeTag: field.key,
|
mergeTag: field.key,
|
||||||
mergeValue: (valueList[field.column] || '').toString().trim() || field.defaultValue,
|
mergeValue: (valueList[field.column] || '').toString().trim() || field.defaultValue,
|
||||||
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
||||||
};
|
};
|
||||||
row.push(item);
|
row.push(item);
|
||||||
break;
|
break;
|
||||||
|
@ -443,7 +444,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
visible: !!field.visible,
|
visible: !!field.visible,
|
||||||
mergeTag: field.key,
|
mergeTag: field.key,
|
||||||
mergeValue: value || field.defaultValue,
|
mergeValue: value || field.defaultValue,
|
||||||
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
||||||
};
|
};
|
||||||
row.push(item);
|
row.push(item);
|
||||||
break;
|
break;
|
||||||
|
@ -459,7 +460,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
visible: !!field.visible,
|
visible: !!field.visible,
|
||||||
mergeTag: field.key,
|
mergeTag: field.key,
|
||||||
mergeValue: (Number(valueList[field.column]) || Number(field.defaultValue) || 0).toString(),
|
mergeValue: (Number(valueList[field.column]) || Number(field.defaultValue) || 0).toString(),
|
||||||
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
||||||
};
|
};
|
||||||
row.push(item);
|
row.push(item);
|
||||||
break;
|
break;
|
||||||
|
@ -476,7 +477,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
key: 'group-g' + field.id,
|
key: 'group-g' + field.id,
|
||||||
mergeTag: field.key,
|
mergeTag: field.key,
|
||||||
mergeValue: field.defaultValue,
|
mergeValue: field.defaultValue,
|
||||||
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true,
|
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true,
|
||||||
groupTemplate: field.groupTemplate,
|
groupTemplate: field.groupTemplate,
|
||||||
options: (field.options || []).map(subField => {
|
options: (field.options || []).map(subField => {
|
||||||
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
|
if (onlyExisting && subField.column && !valueList.hasOwnProperty(subField.column)) {
|
||||||
|
@ -507,7 +508,7 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
case 'date-us':
|
case 'date-us':
|
||||||
case 'birthday-us':
|
case 'birthday-us':
|
||||||
{
|
{
|
||||||
let isUs = /\-us$/.test(field.type);
|
let isUs = /-us$/.test(field.type);
|
||||||
let isYear = field.type.indexOf('date-') === 0;
|
let isYear = field.type.indexOf('date-') === 0;
|
||||||
let value = valueList[field.column];
|
let value = valueList[field.column];
|
||||||
let day, month, year;
|
let day, month, year;
|
||||||
|
@ -568,12 +569,13 @@ module.exports.getRow = (fieldList, values, useDate, showAll, onlyExisting) => {
|
||||||
visible: !!field.visible,
|
visible: !!field.visible,
|
||||||
mergeTag: field.key,
|
mergeTag: field.key,
|
||||||
mergeValue: (useDate ? value : formatted) || field.defaultValue,
|
mergeValue: (useDate ? value : formatted) || field.defaultValue,
|
||||||
['type' + (field.type || '').toString().trim().replace(/(?:^|\-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
['type' + (field.type || '').toString().trim().replace(/(?:^|-)([a-z])/g, (m, c) => c.toUpperCase())]: true
|
||||||
};
|
};
|
||||||
row.push(item);
|
row.push(item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* eslint-enable indent */
|
||||||
});
|
});
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
|
|
|
@ -414,7 +414,7 @@ module.exports.update = (listId, cid, updates, allowEmail, callback) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
fields.getValues(fields.getRow(fieldList, updates, true, true), true).forEach(field => {
|
fields.getValues(fields.getRow(fieldList, updates, true, true, true), true).forEach(field => {
|
||||||
keys.push(field.key);
|
keys.push(field.key);
|
||||||
values.push(field.value);
|
values.push(field.value);
|
||||||
});
|
});
|
||||||
|
@ -495,7 +495,7 @@ module.exports.changeStatus = (listId, id, campaignId, status, callback) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// status change is not related to a campaign or it marks message as bounced etc.
|
// status change is not related to a campaign or it marks message as bounced etc.
|
||||||
if (!campaignId || status !== Status.SUBSCRIBED) {
|
if (!campaignId || status !== Status.SUBSCRIBED && status !== Status.UNSUBSCRIBED) {
|
||||||
return connection.commit(err => {
|
return connection.commit(err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return helpers.rollbackAndReleaseConnection(connection, () => callback(err));
|
return helpers.rollbackAndReleaseConnection(connection, () => callback(err));
|
||||||
|
|
|
@ -96,7 +96,7 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mailOpts.ignoreDisableConfirmations && configItems.disableConfirmations) {
|
if (!mailOpts.ignoreDisableConfirmations && configItems.disableConfirmations) {
|
||||||
return;
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -110,7 +110,22 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
||||||
data[relativeUrlKey] = urllib.resolve(configItems.serviceUrl, relativeUrls[relativeUrlKey]);
|
data[relativeUrlKey] = urllib.resolve(configItems.serviceUrl, relativeUrls[relativeUrlKey]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMail(html, text) {
|
let text = {
|
||||||
|
template: 'subscription/mail-' + template + '-text.hbs'
|
||||||
|
};
|
||||||
|
|
||||||
|
let html = {
|
||||||
|
template: 'subscription/mail-' + template + '-html.mjml.hbs',
|
||||||
|
layout: 'subscription/layout.mjml.hbs',
|
||||||
|
type: 'mjml'
|
||||||
|
};
|
||||||
|
|
||||||
|
helpers.injectCustomFormTemplates(list.defaultForm, { text, html }, (err, tmpl) => {
|
||||||
|
if (!err && tmpl) {
|
||||||
|
text = tmpl.text || text;
|
||||||
|
html = tmpl.html || html;
|
||||||
|
}
|
||||||
|
|
||||||
mailer.sendMail({
|
mailer.sendMail({
|
||||||
from: {
|
from: {
|
||||||
name: configItems.defaultFrom,
|
name: configItems.defaultFrom,
|
||||||
|
@ -131,27 +146,10 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
||||||
log.error('Subscription', err);
|
log.error('Subscription', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
let text = {
|
callback();
|
||||||
template: 'subscription/mail-' + template + '-text.hbs'
|
|
||||||
};
|
|
||||||
|
|
||||||
let html = {
|
|
||||||
template: 'subscription/mail-' + template + '-html.mjml.hbs',
|
|
||||||
layout: 'subscription/layout.mjml.hbs',
|
|
||||||
type: 'mjml'
|
|
||||||
};
|
|
||||||
|
|
||||||
helpers.injectCustomFormTemplates(list.defaultForm, { text, html }, (err, tmpl) => {
|
|
||||||
if (err) {
|
|
||||||
return sendMail(html, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMail(tmpl.html, tmpl.text);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return callback();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ module.exports = {
|
||||||
function toDbKey(key) {
|
function toDbKey(key) {
|
||||||
return key.
|
return key.
|
||||||
replace(/[^a-z0-9\-_]/gi, '').
|
replace(/[^a-z0-9\-_]/gi, '').
|
||||||
replace(/\-+/g, '_').
|
replace(/-+/g, '_').
|
||||||
replace(/[A-Z]/g, c => '_' + c.toLowerCase()).
|
replace(/[A-Z]/g, c => '_' + c.toLowerCase()).
|
||||||
replace(/^_+|_+$/g, '').
|
replace(/^_+|_+$/g, '').
|
||||||
replace(/_+/g, '_').
|
replace(/_+/g, '_').
|
||||||
|
@ -50,7 +50,7 @@ function fromDbKey(key) {
|
||||||
prefix = '_';
|
prefix = '_';
|
||||||
|
|
||||||
}
|
}
|
||||||
return prefix + key.replace(/[_\-]([a-z])/g, (m, c) => c.toUpperCase());
|
return prefix + key.replace(/[_-]([a-z])/g, (m, c) => c.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertKeys(obj, options) {
|
function convertKeys(obj, options) {
|
||||||
|
|
19
package.json
19
package.json
|
@ -29,15 +29,15 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^7.2.3",
|
"babel-eslint": "^7.2.3",
|
||||||
"chai": "^3.5.0",
|
"chai": "^4.0.2",
|
||||||
"eslint-config-nodemailer": "^1.0.0",
|
"eslint-config-nodemailer": "^1.2.0",
|
||||||
"grunt": "^1.0.1",
|
"grunt": "^1.0.1",
|
||||||
"grunt-cli": "^1.2.0",
|
"grunt-cli": "^1.2.0",
|
||||||
"grunt-contrib-nodeunit": "^1.0.0",
|
"grunt-contrib-nodeunit": "^1.0.0",
|
||||||
"grunt-eslint": "^19.0.0",
|
"grunt-eslint": "^20.0.0",
|
||||||
"jsxgettext-andris": "^0.9.0-patch.1",
|
"jsxgettext-andris": "^0.9.0-patch.1",
|
||||||
"mocha": "^3.3.0",
|
"mocha": "^3.3.0",
|
||||||
"phantomjs": "^2.1.7",
|
"phantomjs-prebuilt": "^2.1.14",
|
||||||
"selenium-webdriver": "^3.4.0",
|
"selenium-webdriver": "^3.4.0",
|
||||||
"url-pattern": "^1.0.3"
|
"url-pattern": "^1.0.3"
|
||||||
},
|
},
|
||||||
|
@ -61,13 +61,13 @@
|
||||||
"csv-generate": "^1.0.0",
|
"csv-generate": "^1.0.0",
|
||||||
"csv-parse": "^1.2.0",
|
"csv-parse": "^1.2.0",
|
||||||
"device": "^0.3.8",
|
"device": "^0.3.8",
|
||||||
"dompurify": "^0.8.5",
|
"dompurify": "^0.9.0",
|
||||||
"escape-html": "^1.0.3",
|
"escape-html": "^1.0.3",
|
||||||
"express": "^4.15.2",
|
"express": "^4.15.2",
|
||||||
"express-session": "^1.15.2",
|
"express-session": "^1.15.2",
|
||||||
"faker": "^4.1.0",
|
"faker": "^4.1.0",
|
||||||
"feedparser": "^2.1.0",
|
"feedparser": "^2.1.0",
|
||||||
"file-type": "^4.1.0",
|
"file-type": "^5.2.0",
|
||||||
"fs-extra": "^3.0.1",
|
"fs-extra": "^3.0.1",
|
||||||
"geoip-ultralight": "^0.1.5",
|
"geoip-ultralight": "^0.1.5",
|
||||||
"gettext-parser": "^1.2.2",
|
"gettext-parser": "^1.2.2",
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
"mailparser": "^2.0.5",
|
"mailparser": "^2.0.5",
|
||||||
"marked": "^0.3.6",
|
"marked": "^0.3.6",
|
||||||
"memory-cache": "^0.1.6",
|
"memory-cache": "^0.1.6",
|
||||||
"mjml": "3.3.0",
|
"mjml": "3.3.3",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"moment-timezone": "^0.5.12",
|
"moment-timezone": "^0.5.12",
|
||||||
"morgan": "^1.8.1",
|
"morgan": "^1.8.1",
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
"node-gettext": "^2.0.0-rc.1",
|
"node-gettext": "^2.0.0-rc.1",
|
||||||
"node-mocks-http": "^1.6.1",
|
"node-mocks-http": "^1.6.1",
|
||||||
"node-object-hash": "^1.2.0",
|
"node-object-hash": "^1.2.0",
|
||||||
"nodemailer": "^3.1.8",
|
"nodemailer": "^4.0.1",
|
||||||
"nodemailer-openpgp": "^1.0.2",
|
"nodemailer-openpgp": "^1.0.2",
|
||||||
"npmlog": "^4.0.2",
|
"npmlog": "^4.0.2",
|
||||||
"object-hash": "^1.1.7",
|
"object-hash": "^1.1.7",
|
||||||
|
@ -109,10 +109,11 @@
|
||||||
"redfour": "^1.0.0",
|
"redfour": "^1.0.0",
|
||||||
"redis": "^2.7.1",
|
"redis": "^2.7.1",
|
||||||
"request": "^2.81.0",
|
"request": "^2.81.0",
|
||||||
|
"request-promise": "^4.2.1",
|
||||||
"serve-favicon": "^2.4.2",
|
"serve-favicon": "^2.4.2",
|
||||||
"shortid": "^2.2.8",
|
"shortid": "^2.2.8",
|
||||||
"slugify": "^1.1.0",
|
"slugify": "^1.1.0",
|
||||||
"smtp-server": "^2.0.3",
|
"smtp-server": "^3.0.1",
|
||||||
"striptags": "^3.0.1",
|
"striptags": "^3.0.1",
|
||||||
"toml": "^2.3.2",
|
"toml": "^2.3.2",
|
||||||
"try-require": "^1.2.1"
|
"try-require": "^1.2.1"
|
||||||
|
|
|
@ -125,7 +125,12 @@ router.post('/subscribe/:listId', (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/^(yes|true|1)$/i.test(input.REQUIRE_CONFIRMATION)) {
|
if (/^(yes|true|1)$/i.test(input.REQUIRE_CONFIRMATION)) {
|
||||||
confirmations.addConfirmation(list.id, 'subscribe', req.ip, subscription, (err, confirmCid) => {
|
const data = {
|
||||||
|
email: subscription.email,
|
||||||
|
subscriptionData: subscription
|
||||||
|
};
|
||||||
|
|
||||||
|
confirmations.addConfirmation(list.id, 'subscribe', req.ip, data, (err, confirmCid) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('API', err);
|
log.error('API', err);
|
||||||
res.status(500);
|
res.status(500);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
let log = require('npmlog');
|
||||||
let config = require('config');
|
let config = require('config');
|
||||||
let express = require('express');
|
let express = require('express');
|
||||||
let router = new express.Router();
|
let router = new express.Router();
|
||||||
|
@ -70,19 +71,15 @@ let listImages = (dir, dirURL, callback) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let getStaticImageUrl = ({
|
const getStaticImageUrl = (dynamicUrl, staticDir, staticDirUrl, callback) => {
|
||||||
dynamicUrl,
|
|
||||||
staticDir,
|
|
||||||
staticDirUrl
|
|
||||||
}, callback) => {
|
|
||||||
mkdirp(staticDir, err => {
|
mkdirp(staticDir, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(dynamicUrl);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readdir(staticDir, (err, files) => {
|
fs.readdir(staticDir, (err, files) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(dynamicUrl);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash = crypto.createHash('md5').update(dynamicUrl).digest('hex');
|
let hash = crypto.createHash('md5').update(dynamicUrl).digest('hex');
|
||||||
|
@ -90,7 +87,7 @@ let getStaticImageUrl = ({
|
||||||
let headers = {};
|
let headers = {};
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
return callback(staticDirUrl + '/' + match);
|
return callback(null, staticDirUrl + '/' + match);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynamicUrl.includes('/editorapi/img?')) {
|
if (dynamicUrl.includes('/editorapi/img?')) {
|
||||||
|
@ -103,24 +100,27 @@ let getStaticImageUrl = ({
|
||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
if (res.status < 200 || res.status >= 300) {
|
||||||
|
throw new Error(`Received HTTP status code ${res.status} while fetching image ${dynamicUrl}`);
|
||||||
|
}
|
||||||
return res.buffer();
|
return res.buffer();
|
||||||
})
|
})
|
||||||
.then(buffer => {
|
.then(buffer => {
|
||||||
let ft = fileType(buffer);
|
let ft = fileType(buffer);
|
||||||
if (!ft) {
|
if (ft && ['image/jpeg', 'image/png', 'image/gif'].includes(ft.mime)) {
|
||||||
return callback(dynamicUrl);
|
|
||||||
}
|
|
||||||
if (['image/jpeg', 'image/png', 'image/gif'].includes(ft.mime)) {
|
|
||||||
fs.writeFile(path.join(staticDir, hash + '.' + ft.ext), buffer, err => {
|
fs.writeFile(path.join(staticDir, hash + '.' + ft.ext), buffer, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(dynamicUrl);
|
throw err;
|
||||||
}
|
}
|
||||||
let staticUrl = staticDirUrl + '/' + hash + '.' + ft.ext;
|
let staticUrl = staticDirUrl + '/' + hash + '.' + ft.ext;
|
||||||
callback(staticUrl);
|
callback(null, staticUrl);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callback(dynamicUrl);
|
throw new Error(`Unsupported image MIME type for ${dynamicUrl}`);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
callback(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -139,6 +139,7 @@ let prepareHtml = ({
|
||||||
let srcs = {};
|
let srcs = {};
|
||||||
let re = /<img[^>]+src="([^"]+)"/g;
|
let re = /<img[^>]+src="([^"]+)"/g;
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
while ((result = re.exec(html)) !== null) {
|
while ((result = re.exec(html)) !== null) {
|
||||||
srcs[result[1]] = result[1];
|
srcs[result[1]] = result[1];
|
||||||
}
|
}
|
||||||
|
@ -153,15 +154,26 @@ let prepareHtml = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const staticDir = path.join(__dirname, '..', 'public', editorName, 'uploads', 'static');
|
||||||
|
const staticDirUrl = url.resolve(serviceUrl, editorName + '/uploads/static');
|
||||||
|
|
||||||
Object.keys(srcs).forEach(src => {
|
Object.keys(srcs).forEach(src => {
|
||||||
jobs++;
|
jobs++;
|
||||||
let dynamicUrl = src.replace(/&/g, '&');
|
let dynamicUrl = src.replace(/&/g, '&');
|
||||||
dynamicUrl = /^https?:\/\/|^\/\//i.test(dynamicUrl) ? dynamicUrl : url.resolve(serviceUrl, dynamicUrl);
|
dynamicUrl = /^https?:\/\/|^\/\//i.test(dynamicUrl) ? dynamicUrl : url.resolve(serviceUrl, dynamicUrl);
|
||||||
getStaticImageUrl({
|
|
||||||
dynamicUrl,
|
getStaticImageUrl(dynamicUrl, staticDir, staticDirUrl, (err, staticUrl) => {
|
||||||
staticDir: path.join(__dirname, '..', 'public', editorName, 'uploads', 'static'),
|
if (err) {
|
||||||
staticDirUrl: url.resolve(serviceUrl, editorName + '/uploads/static'),
|
// TODO: Send a warning back to the editor. For now we just skip image resizing.
|
||||||
}, staticUrl => {
|
log.error('editorapi', err.message || err);
|
||||||
|
|
||||||
|
if (dynamicUrl.includes('/editorapi/img?')) {
|
||||||
|
staticUrl = url.parse(dynamicUrl, true).query.src || dynamicUrl;
|
||||||
|
} else {
|
||||||
|
staticUrl = dynamicUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
srcs[src] = staticUrl;
|
srcs[src] = staticUrl;
|
||||||
jobs--;
|
jobs--;
|
||||||
done();
|
done();
|
||||||
|
@ -329,7 +341,9 @@ router.get('/upload', passport.csrfProtection, (req, res) => {
|
||||||
|
|
||||||
if (req.query.type === 'campaign' && Number(req.query.id) > 0) {
|
if (req.query.type === 'campaign' && Number(req.query.id) > 0) {
|
||||||
listImages(path.join(baseDir, req.query.id), baseDirUrl + '/' + req.query.id, (err, campaignImages) => {
|
listImages(path.join(baseDir, req.query.id), baseDirUrl + '/' + req.query.id, (err, campaignImages) => {
|
||||||
err ? res.status(500).send(err.message || err) :
|
if (err) {
|
||||||
|
return res.status(500).send(err.message || err);
|
||||||
|
}
|
||||||
res.json({
|
res.json({
|
||||||
files: sharedImages.concat(campaignImages)
|
files: sharedImages.concat(campaignImages)
|
||||||
});
|
});
|
||||||
|
|
|
@ -77,6 +77,7 @@ router.get('/confirm/subscribe/:cid', (req, res, next) => {
|
||||||
let optInCountry = geoip.lookupCountry(confirmation.ip) || null;
|
let optInCountry = geoip.lookupCountry(confirmation.ip) || null;
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
|
cid: req.params.cid,
|
||||||
email: data.email,
|
email: data.email,
|
||||||
optInIp: confirmation.ip,
|
optInIp: confirmation.ip,
|
||||||
optInCountry,
|
optInCountry,
|
||||||
|
@ -438,7 +439,7 @@ router.post('/:cid/subscribe', passport.parseForm, corsOrCsrfProtection, (req, r
|
||||||
log.info('Subscription', 'Confirmation message for %s marked to be skipped (%s)', email, JSON.stringify(data));
|
log.info('Subscription', 'Confirmation message for %s marked to be skipped (%s)', email, JSON.stringify(data));
|
||||||
sendWebResponse();
|
sendWebResponse();
|
||||||
} else {
|
} else {
|
||||||
mailHelpers.sendConfirmSubscription(list, email, confirmCid, data, (err) => {
|
mailHelpers.sendConfirmSubscription(list, email, confirmCid, subscriptionData, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return req.xhr ? sendJsonError(err) : sendWebResponse(err);
|
return req.xhr ? sendJsonError(err) : sendWebResponse(err);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,8 @@
|
||||||
"strict": 0,
|
"strict": 0,
|
||||||
"no-console": 0,
|
"no-console": 0,
|
||||||
"comma-dangle": 0,
|
"comma-dangle": 0,
|
||||||
"arrow-body-style": 0
|
"arrow-body-style": 0,
|
||||||
|
"no-await-in-loop": 0
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"mocha": true
|
"mocha": true
|
||||||
|
|
|
@ -9,7 +9,9 @@ module.exports = {
|
||||||
users: {
|
users: {
|
||||||
admin: {
|
admin: {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: 'test'
|
password: 'test',
|
||||||
|
email: 'keep.admin@mailtrain.org',
|
||||||
|
accessToken: '7833d148e22c85474c314f43ae4591a7c9adec26'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lists: {
|
lists: {
|
||||||
|
@ -18,41 +20,59 @@ module.exports = {
|
||||||
cid: 'Hkj1vCoJb',
|
cid: 'Hkj1vCoJb',
|
||||||
publicSubscribe: 1,
|
publicSubscribe: 1,
|
||||||
unsubscriptionMode: 0, // (one-step, no form)
|
unsubscriptionMode: 0, // (one-step, no form)
|
||||||
|
customFields: [
|
||||||
|
{ type: 'text', key: 'MERGE_TEXT', column: 'custom_text_field_byiiqjrw' },
|
||||||
|
{ type: 'number', key: 'MERGE_NUMBER', column: 'custom_number_field_r1dd91awb' },
|
||||||
|
{ type: 'website', key: 'MERGE_WEBSITE', column: 'custom_website_field_rkq991cw' },
|
||||||
|
{ type: 'gpg', key: 'MERGE_GPG_PUBLIC_KEY', column: 'custom_gpg_public_key_ryvj51cz' },
|
||||||
|
{ type: 'longtext', key: 'MERGE_MULTILINE_TEXT', column: 'custom_multiline_text_bjbfojawb' },
|
||||||
|
{ type: 'json', key: 'MERGE_JSON', column: 'custom_json_skqjkcb' },
|
||||||
|
{ type: 'date-us', key: 'MERGE_DATE_MMDDYYYY', column: 'custom_date_mmddyy_rjkeojrzz' },
|
||||||
|
{ type: 'date-eur', key: 'MERGE_DATE_DDMMYYYY', column: 'custom_date_ddmmyy_ryedsk0wz' },
|
||||||
|
{ type: 'birthday-us', key: 'MERGE_BIRTHDAY_MMDD', column: 'custom_birthday_mmdd_h18coj0zz' },
|
||||||
|
{ type: 'birthday-eur', key: 'MERGE_BIRTHDAY_DDMM', column: 'custom_birthday_ddmm_r1g3s1czz' },
|
||||||
|
// TODO: Add remaining custom fields, dropdowns and checkboxes
|
||||||
|
]
|
||||||
},
|
},
|
||||||
l2: {
|
l2: {
|
||||||
id: 2,
|
id: 2,
|
||||||
cid: 'SktV4HDZ-',
|
cid: 'SktV4HDZ-',
|
||||||
publicSubscribe: 1,
|
publicSubscribe: 1,
|
||||||
unsubscriptionMode: 1, // (one-step, with form)
|
unsubscriptionMode: 1, // (one-step, with form)
|
||||||
|
customFields: []
|
||||||
},
|
},
|
||||||
l3: {
|
l3: {
|
||||||
id: 3,
|
id: 3,
|
||||||
cid: 'BkdvNBw-W',
|
cid: 'BkdvNBw-W',
|
||||||
publicSubscribe: 1,
|
publicSubscribe: 1,
|
||||||
unsubscriptionMode: 2, // (two-step, no form)
|
unsubscriptionMode: 2, // (two-step, no form)
|
||||||
|
customFields: []
|
||||||
},
|
},
|
||||||
l4: {
|
l4: {
|
||||||
id: 4,
|
id: 4,
|
||||||
cid: 'rJMKVrDZ-',
|
cid: 'rJMKVrDZ-',
|
||||||
publicSubscribe: 1,
|
publicSubscribe: 1,
|
||||||
unsubscriptionMode: 3, // (two-step, with form)
|
unsubscriptionMode: 3, // (two-step, with form)
|
||||||
|
customFields: []
|
||||||
},
|
},
|
||||||
l5: {
|
l5: {
|
||||||
id: 5,
|
id: 5,
|
||||||
cid: 'SJgoNSw-W',
|
cid: 'SJgoNSw-W',
|
||||||
publicSubscribe: 1,
|
publicSubscribe: 1,
|
||||||
unsubscriptionMode: 4, // (manual unsubscribe)
|
unsubscriptionMode: 4, // (manual unsubscribe)
|
||||||
|
customFields: []
|
||||||
},
|
},
|
||||||
l6: {
|
l6: {
|
||||||
id: 6,
|
id: 6,
|
||||||
cid: 'HyveEPvWW',
|
cid: 'HyveEPvWW',
|
||||||
publicSubscribe: 0,
|
publicSubscribe: 0,
|
||||||
unsubscriptionMode: 0, // (one-step, no form)
|
unsubscriptionMode: 0, // (one-step, no form)
|
||||||
|
customFields: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
'service-url': 'http://localhost:' + config.www.port + '/',
|
'service-url': 'http://localhost:' + config.www.port + '/',
|
||||||
'admin-email': 'admin@example.com',
|
'admin-email': 'keep.admin@mailtrain.org',
|
||||||
'default-homepage': 'https://mailtrain.org',
|
'default-homepage': 'https://mailtrain.org',
|
||||||
'smtp-hostname': config.testserver.host,
|
'smtp-hostname': config.testserver.host,
|
||||||
'smtp-port': config.testserver.port,
|
'smtp-port': config.testserver.port,
|
||||||
|
|
|
@ -14,7 +14,7 @@ module.exports = (...extras) => Object.assign({
|
||||||
elements: {},
|
elements: {},
|
||||||
|
|
||||||
async getElement(key) {
|
async getElement(key) {
|
||||||
return await driver.findElement(By.css(this.elements[key]));
|
return await driver.findElement(By.css(this.elements[key] || key));
|
||||||
},
|
},
|
||||||
|
|
||||||
async getLinkParams(key) {
|
async getLinkParams(key) {
|
||||||
|
|
|
@ -3,6 +3,49 @@
|
||||||
const config = require('../lib/config');
|
const config = require('../lib/config');
|
||||||
const web = require('../lib/web');
|
const web = require('../lib/web');
|
||||||
const mail = require('../lib/mail');
|
const mail = require('../lib/mail');
|
||||||
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
|
const fieldHelpers = list => ({
|
||||||
|
async fillFields(subscription) {
|
||||||
|
if (subscription.EMAIL && this.url === `/subscription/${list.cid}`) {
|
||||||
|
await this.setValue('emailInput', subscription.EMAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subscription.FIRST_NAME) {
|
||||||
|
await this.setValue('firstNameInput', subscription.FIRST_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subscription.LAST_NAME) {
|
||||||
|
await this.setValue('lastNameInput', subscription.LAST_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const field of list.customFields) {
|
||||||
|
if (field.key in subscription) {
|
||||||
|
await this.setValue(`[name="${field.column}"]`, subscription[field.key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async assertFields(subscription) {
|
||||||
|
if (subscription.EMAIL) {
|
||||||
|
expect(await this.getValue('emailInput')).to.equal(subscription.EMAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subscription.FIRST_NAME) {
|
||||||
|
expect(await this.getValue('firstNameInput')).to.equal(subscription.FIRST_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subscription.LAST_NAME) {
|
||||||
|
expect(await this.getValue('lastNameInput')).to.equal(subscription.LAST_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const field of list.customFields) {
|
||||||
|
if (field.key in subscription) {
|
||||||
|
expect(await this.getValue(`[name="${field.column}"]`)).to.equal(subscription[field.key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = list => ({
|
module.exports = list => ({
|
||||||
|
|
||||||
|
@ -17,7 +60,7 @@ module.exports = list => ({
|
||||||
lastNameInput: '#main-form input[name="last-name"]',
|
lastNameInput: '#main-form input[name="last-name"]',
|
||||||
submitButton: 'a[href="#submit"]'
|
submitButton: 'a[href="#submit"]'
|
||||||
}
|
}
|
||||||
}),
|
}, fieldHelpers(list)),
|
||||||
|
|
||||||
webSubscribeNonPublic: web({
|
webSubscribeNonPublic: web({
|
||||||
url: `/subscription/${list.cid}`,
|
url: `/subscription/${list.cid}`,
|
||||||
|
@ -83,7 +126,7 @@ module.exports = list => ({
|
||||||
links: {
|
links: {
|
||||||
manageAddressLink: `/subscription/${list.cid}/manage-address/:ucid`
|
manageAddressLink: `/subscription/${list.cid}/manage-address/:ucid`
|
||||||
}
|
}
|
||||||
}),
|
}, fieldHelpers(list)),
|
||||||
|
|
||||||
webManageAddress: web({
|
webManageAddress: web({
|
||||||
url: `/subscription/${list.cid}/manage-address/:ucid`,
|
url: `/subscription/${list.cid}/manage-address/:ucid`,
|
||||||
|
|
|
@ -7,6 +7,8 @@ const { useCase, step, precondition, driver } = require('../lib/mocha-e2e');
|
||||||
const shortid = require('shortid');
|
const shortid = require('shortid');
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
const createPage = require('../page-objects/subscription');
|
const createPage = require('../page-objects/subscription');
|
||||||
|
const faker = require('faker');
|
||||||
|
const request = require('request-promise');
|
||||||
|
|
||||||
function getPage(listConf) {
|
function getPage(listConf) {
|
||||||
return createPage(listConf);
|
return createPage(listConf);
|
||||||
|
@ -16,6 +18,59 @@ function generateEmail() {
|
||||||
return 'keep.' + shortid.generate() + '@mailtrain.org';
|
return 'keep.' + shortid.generate() + '@mailtrain.org';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateCustomFieldValue(field) {
|
||||||
|
// https://github.com/marak/Faker.js/#api-methods
|
||||||
|
switch (field.type) {
|
||||||
|
case 'text':
|
||||||
|
return faker.lorem.words();
|
||||||
|
case 'website':
|
||||||
|
return faker.internet.url();
|
||||||
|
case 'gpg':
|
||||||
|
return '';
|
||||||
|
case 'longtext':
|
||||||
|
return faker.lorem.lines();
|
||||||
|
case 'json':
|
||||||
|
return `{"say":"${faker.lorem.word()}"}`;
|
||||||
|
case 'number':
|
||||||
|
return faker.random.number().toString();
|
||||||
|
case 'option':
|
||||||
|
return Math.round(Math.random());
|
||||||
|
case 'date-us':
|
||||||
|
return '10/20/2017';
|
||||||
|
case 'date-eur':
|
||||||
|
return '20/10/2017';
|
||||||
|
case 'birthday-us':
|
||||||
|
return '10/20';
|
||||||
|
case 'birthday-eur':
|
||||||
|
return '20/10';
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateSubscriptionData(listConf) {
|
||||||
|
const data = {
|
||||||
|
EMAIL: generateEmail(),
|
||||||
|
FIRST_NAME: faker.name.firstName(),
|
||||||
|
LAST_NAME: faker.name.lastName(),
|
||||||
|
TIMEZONE: 'Europe/Tallinn',
|
||||||
|
};
|
||||||
|
|
||||||
|
listConf.customFields.forEach(field => {
|
||||||
|
data[field.key] = generateCustomFieldValue(field);
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeSubscriptionData(listConf, subscription) {
|
||||||
|
const data = generateSubscriptionData(listConf);
|
||||||
|
delete data.EMAIL;
|
||||||
|
const changedSubscription = Object.assign({}, subscription, data);
|
||||||
|
// TODO: Make sure values have actually changed.
|
||||||
|
return changedSubscription;
|
||||||
|
}
|
||||||
|
|
||||||
async function subscribe(listConf, subscription) {
|
async function subscribe(listConf, subscription) {
|
||||||
const page = getPage(listConf);
|
const page = getPage(listConf);
|
||||||
|
|
||||||
|
@ -24,16 +79,7 @@ async function subscribe(listConf, subscription) {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User submits a valid email and other subscription info.', async () => {
|
await step('User submits a valid email and other subscription info.', async () => {
|
||||||
await page.webSubscribe.setValue('emailInput', subscription.email);
|
await page.webSubscribe.fillFields(subscription);
|
||||||
|
|
||||||
if (subscription.firstName) {
|
|
||||||
await page.webSubscribe.setValue('firstNameInput', subscription.firstName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subscription.lastName) {
|
|
||||||
await page.webSubscribe.setValue('lastNameInput', subscription.lastName);
|
|
||||||
}
|
|
||||||
|
|
||||||
await page.webSubscribe.submit();
|
await page.webSubscribe.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -42,7 +88,7 @@ async function subscribe(listConf, subscription) {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with a link to confirm the subscription.', async () => {
|
await step('System sends an email with a link to confirm the subscription.', async () => {
|
||||||
await page.mailConfirmSubscription.fetchMail(subscription.email);
|
await page.mailConfirmSubscription.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks confirm subscription in the email', async () => {
|
await step('User clicks confirm subscription in the email', async () => {
|
||||||
|
@ -54,7 +100,7 @@ async function subscribe(listConf, subscription) {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with subscription confirmation.', async () => {
|
await step('System sends an email with subscription confirmation.', async () => {
|
||||||
await page.mailSubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailSubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
subscription.unsubscribeLink = await page.mailSubscriptionConfirmed.getHref('unsubscribeLink');
|
subscription.unsubscribeLink = await page.mailSubscriptionConfirmed.getHref('unsubscribeLink');
|
||||||
subscription.manageLink = await page.mailSubscriptionConfirmed.getHref('manageLink');
|
subscription.manageLink = await page.mailSubscriptionConfirmed.getHref('manageLink');
|
||||||
|
|
||||||
|
@ -79,7 +125,7 @@ suite('Subscription use-cases', () => {
|
||||||
|
|
||||||
useCase('Subscription to a public list (main scenario)', async () => {
|
useCase('Subscription to a public list (main scenario)', async () => {
|
||||||
await subscribe(config.lists.l1, {
|
await subscribe(config.lists.l1, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -105,7 +151,7 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l1);
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User navigates to list subscribe page', async () => {
|
await step('User navigates to list subscribe page', async () => {
|
||||||
|
@ -113,7 +159,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User submits the email which has been already registered.', async () => {
|
await step('User submits the email which has been already registered.', async () => {
|
||||||
await page.webSubscribe.setValue('emailInput', subscription.email);
|
await page.webSubscribe.setValue('emailInput', subscription.EMAIL);
|
||||||
await page.webSubscribe.submit();
|
await page.webSubscribe.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -122,7 +168,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email informing that the address has been already registered.', async () => {
|
await step('System sends an email informing that the address has been already registered.', async () => {
|
||||||
await page.mailAlreadySubscribed.fetchMail(subscription.email);
|
await page.mailAlreadySubscribed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -138,11 +184,7 @@ suite('Subscription use-cases', () => {
|
||||||
useCase('Change profile info', async () => {
|
useCase('Change profile info', async () => {
|
||||||
const page = getPage(config.lists.l1);
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
let subscription = await subscriptionExistsPrecondition(config.lists.l1, generateSubscriptionData(config.lists.l1));
|
||||||
email: generateEmail(),
|
|
||||||
firstName: 'John',
|
|
||||||
lastName: 'Doe'
|
|
||||||
});
|
|
||||||
|
|
||||||
await step('User clicks the manage subscription button.', async () => {
|
await step('User clicks the manage subscription button.', async () => {
|
||||||
await page.mailSubscriptionConfirmed.click('manageLink');
|
await page.mailSubscriptionConfirmed.click('manageLink');
|
||||||
|
@ -150,16 +192,12 @@ suite('Subscription use-cases', () => {
|
||||||
|
|
||||||
await step('Systems shows a form to change subscription details. The form contains data entered during subscription.', async () => {
|
await step('Systems shows a form to change subscription details. The form contains data entered during subscription.', async () => {
|
||||||
await page.webManage.waitUntilVisibleAfterRefresh();
|
await page.webManage.waitUntilVisibleAfterRefresh();
|
||||||
expect(await page.webManage.getValue('emailInput')).to.equal(subscription.email);
|
await page.webManage.assertFields(subscription);
|
||||||
expect(await page.webManage.getValue('firstNameInput')).to.equal(subscription.firstName);
|
|
||||||
expect(await page.webManage.getValue('lastNameInput')).to.equal(subscription.lastName);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User enters another name and submits the form.', async () => {
|
await step('User enters other values and submits the form.', async () => {
|
||||||
subscription.firstName = 'Adam';
|
subscription = changeSubscriptionData(config.lists.l1, subscription);
|
||||||
subscription.lastName = 'B';
|
await page.webManage.fillFields(subscription);
|
||||||
await page.webManage.setValue('firstNameInput', subscription.firstName);
|
|
||||||
await page.webManage.setValue('lastNameInput', subscription.lastName);
|
|
||||||
await page.webManage.submit();
|
await page.webManage.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -168,14 +206,11 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User navigates to manage subscription again.', async () => {
|
await step('User navigates to manage subscription again.', async () => {
|
||||||
// await page.webManage.navigate(subscription.manageLink);
|
|
||||||
await page.webManage.navigate({ ucid: subscription.ucid });
|
await page.webManage.navigate({ ucid: subscription.ucid });
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('Systems shows a form with the changes made previously.', async () => {
|
await step('Systems shows a form with the changes made previously.', async () => {
|
||||||
expect(await page.webManage.getValue('emailInput')).to.equal(subscription.email);
|
await page.webManage.assertFields(subscription);
|
||||||
expect(await page.webManage.getValue('firstNameInput')).to.equal(subscription.firstName);
|
|
||||||
expect(await page.webManage.getValue('lastNameInput')).to.equal(subscription.lastName);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,9 +218,9 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l1);
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
||||||
email: generateEmail(),
|
EMAIL: generateEmail(),
|
||||||
firstName: 'John',
|
FIRST_NAME: 'John',
|
||||||
lastName: 'Doe'
|
LAST_NAME: 'Doe'
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the manage subscription button.', async () => {
|
await step('User clicks the manage subscription button.', async () => {
|
||||||
|
@ -194,9 +229,7 @@ suite('Subscription use-cases', () => {
|
||||||
|
|
||||||
await step('Systems shows a form to change subscription details. The form contains data entered during subscription.', async () => {
|
await step('Systems shows a form to change subscription details. The form contains data entered during subscription.', async () => {
|
||||||
await page.webManage.waitUntilVisibleAfterRefresh();
|
await page.webManage.waitUntilVisibleAfterRefresh();
|
||||||
expect(await page.webManage.getValue('emailInput')).to.equal(subscription.email);
|
await page.webManage.fillFields(subscription);
|
||||||
expect(await page.webManage.getValue('firstNameInput')).to.equal(subscription.firstName);
|
|
||||||
expect(await page.webManage.getValue('lastNameInput')).to.equal(subscription.lastName);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the change address button.', async () => {
|
await step('User clicks the change address button.', async () => {
|
||||||
|
@ -208,8 +241,8 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User fills in a new email address and submits the form.', async () => {
|
await step('User fills in a new email address and submits the form.', async () => {
|
||||||
subscription.email = generateEmail();
|
subscription.EMAIL = generateEmail();
|
||||||
await page.webManageAddress.setValue('emailNewInput', subscription.email);
|
await page.webManageAddress.setValue('emailNewInput', subscription.EMAIL);
|
||||||
await page.webManageAddress.submit();
|
await page.webManageAddress.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -220,7 +253,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with a link to confirm the address change.', async () => {
|
await step('System sends an email with a link to confirm the address change.', async () => {
|
||||||
await page.mailConfirmAddressChange.fetchMail(subscription.email);
|
await page.mailConfirmAddressChange.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks confirm subscription in the email', async () => {
|
await step('User clicks confirm subscription in the email', async () => {
|
||||||
|
@ -231,11 +264,11 @@ suite('Subscription use-cases', () => {
|
||||||
await page.webManage.waitUntilVisibleAfterRefresh();
|
await page.webManage.waitUntilVisibleAfterRefresh();
|
||||||
await page.webManage.waitForFlash();
|
await page.webManage.waitForFlash();
|
||||||
expect(await page.webManage.getFlash()).to.contain('Email address changed');
|
expect(await page.webManage.getFlash()).to.contain('Email address changed');
|
||||||
expect(await page.webManage.getValue('emailInput')).to.equal(subscription.email);
|
expect(await page.webManage.getValue('emailInput')).to.equal(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with subscription confirmation.', async () => {
|
await step('System sends an email with subscription confirmation.', async () => {
|
||||||
await page.mailSubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailSubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -243,7 +276,7 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l1);
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -255,7 +288,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email that confirms unsubscription.', async () => {
|
await step('System sends an email that confirms unsubscription.', async () => {
|
||||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -263,7 +296,7 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l2);
|
const page = getPage(config.lists.l2);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l2, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l2, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -283,7 +316,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email that confirms unsubscription.', async () => {
|
await step('System sends an email that confirms unsubscription.', async () => {
|
||||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -291,7 +324,7 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l3);
|
const page = getPage(config.lists.l3);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l3, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l3, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -303,7 +336,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with a link to confirm unsubscription.', async () => {
|
await step('System sends an email with a link to confirm unsubscription.', async () => {
|
||||||
await page.mailConfirmUnsubscription.fetchMail(subscription.email);
|
await page.mailConfirmUnsubscription.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the confirm unsubscribe button in the email.', async () => {
|
await step('User clicks the confirm unsubscribe button in the email.', async () => {
|
||||||
|
@ -315,7 +348,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email that confirms unsubscription.', async () => {
|
await step('System sends an email that confirms unsubscription.', async () => {
|
||||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -323,7 +356,7 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l4);
|
const page = getPage(config.lists.l4);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l4, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l4, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -343,7 +376,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with a link to confirm unsubscription.', async () => {
|
await step('System sends an email with a link to confirm unsubscription.', async () => {
|
||||||
await page.mailConfirmUnsubscription.fetchMail(subscription.email);
|
await page.mailConfirmUnsubscription.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the confirm unsubscribe button in the email.', async () => {
|
await step('User clicks the confirm unsubscribe button in the email.', async () => {
|
||||||
|
@ -355,7 +388,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email that confirms unsubscription.', async () => {
|
await step('System sends an email that confirms unsubscription.', async () => {
|
||||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -363,7 +396,7 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l5);
|
const page = getPage(config.lists.l5);
|
||||||
|
|
||||||
await subscriptionExistsPrecondition(config.lists.l5, {
|
await subscriptionExistsPrecondition(config.lists.l5, {
|
||||||
email: generateEmail()
|
EMAIL: generateEmail()
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -379,9 +412,9 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l1);
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
const subscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
||||||
email: generateEmail(),
|
EMAIL: generateEmail(),
|
||||||
firstName: 'John',
|
FIRST_NAME: 'John',
|
||||||
lastName: 'Doe'
|
LAST_NAME: 'Doe'
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -393,7 +426,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email that confirms unsubscription.', async () => {
|
await step('System sends an email that confirms unsubscription.', async () => {
|
||||||
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailUnsubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the resubscribe button.', async () => {
|
await step('User clicks the resubscribe button.', async () => {
|
||||||
|
@ -402,9 +435,9 @@ suite('Subscription use-cases', () => {
|
||||||
|
|
||||||
await step('Systems shows the subscription form. The form contains data entered during initial subscription.', async () => {
|
await step('Systems shows the subscription form. The form contains data entered during initial subscription.', async () => {
|
||||||
await page.webSubscribe.waitUntilVisibleAfterRefresh();
|
await page.webSubscribe.waitUntilVisibleAfterRefresh();
|
||||||
expect(await page.webSubscribe.getValue('emailInput')).to.equal(subscription.email);
|
expect(await page.webSubscribe.getValue('emailInput')).to.equal(subscription.EMAIL);
|
||||||
expect(await page.webSubscribe.getValue('firstNameInput')).to.equal(subscription.firstName);
|
expect(await page.webSubscribe.getValue('firstNameInput')).to.equal(subscription.FIRST_NAME);
|
||||||
expect(await page.webSubscribe.getValue('lastNameInput')).to.equal(subscription.lastName);
|
expect(await page.webSubscribe.getValue('lastNameInput')).to.equal(subscription.LAST_NAME);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User submits the subscription form.', async () => {
|
await step('User submits the subscription form.', async () => {
|
||||||
|
@ -416,7 +449,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with a link to confirm the subscription.', async () => {
|
await step('System sends an email with a link to confirm the subscription.', async () => {
|
||||||
await page.mailConfirmSubscription.fetchMail(subscription.email);
|
await page.mailConfirmSubscription.fetchMail(subscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks confirm subscription in the email', async () => {
|
await step('User clicks confirm subscription in the email', async () => {
|
||||||
|
@ -428,7 +461,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with subscription confirmation. The manage and unsubscribe links are identical with the initial subscription.', async () => {
|
await step('System sends an email with subscription confirmation. The manage and unsubscribe links are identical with the initial subscription.', async () => {
|
||||||
await page.mailSubscriptionConfirmed.fetchMail(subscription.email);
|
await page.mailSubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
const unsubscribeLink = await page.mailSubscriptionConfirmed.getHref('unsubscribeLink');
|
const unsubscribeLink = await page.mailSubscriptionConfirmed.getHref('unsubscribeLink');
|
||||||
const manageLink = await page.mailSubscriptionConfirmed.getHref('manageLink');
|
const manageLink = await page.mailSubscriptionConfirmed.getHref('manageLink');
|
||||||
expect(subscription.unsubscribeLink).to.equal(unsubscribeLink);
|
expect(subscription.unsubscribeLink).to.equal(unsubscribeLink);
|
||||||
|
@ -440,9 +473,9 @@ suite('Subscription use-cases', () => {
|
||||||
const page = getPage(config.lists.l1);
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
const oldSubscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
const oldSubscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
||||||
email: generateEmail(),
|
EMAIL: generateEmail(),
|
||||||
firstName: 'old first name',
|
FIRST_NAME: 'old first name',
|
||||||
lastName: 'old last name'
|
LAST_NAME: 'old last name'
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the unsubscribe button.', async () => {
|
await step('User clicks the unsubscribe button.', async () => {
|
||||||
|
@ -454,12 +487,12 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email that confirms unsubscription.', async () => {
|
await step('System sends an email that confirms unsubscription.', async () => {
|
||||||
await page.mailUnsubscriptionConfirmed.fetchMail(oldSubscription.email);
|
await page.mailUnsubscriptionConfirmed.fetchMail(oldSubscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
const newSubscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
const newSubscription = await subscriptionExistsPrecondition(config.lists.l1, {
|
||||||
email: generateEmail(),
|
EMAIL: generateEmail(),
|
||||||
firstName: 'new first name'
|
FIRST_NAME: 'new first name'
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the manage subscription button.', async () => {
|
await step('User clicks the manage subscription button.', async () => {
|
||||||
|
@ -467,6 +500,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks the change address button.', async () => {
|
await step('User clicks the change address button.', async () => {
|
||||||
|
await page.webManage.waitUntilVisibleAfterRefresh();
|
||||||
await page.webManage.click('manageAddressLink');
|
await page.webManage.click('manageAddressLink');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -475,7 +509,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User fills in the email address of the original subscription and submits the form.', async () => {
|
await step('User fills in the email address of the original subscription and submits the form.', async () => {
|
||||||
await page.webManageAddress.setValue('emailNewInput', oldSubscription.email);
|
await page.webManageAddress.setValue('emailNewInput', oldSubscription.EMAIL);
|
||||||
await page.webManageAddress.submit();
|
await page.webManageAddress.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -486,7 +520,7 @@ suite('Subscription use-cases', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with a link to confirm the address change.', async () => {
|
await step('System sends an email with a link to confirm the address change.', async () => {
|
||||||
await page.mailConfirmAddressChange.fetchMail(oldSubscription.email);
|
await page.mailConfirmAddressChange.fetchMail(oldSubscription.EMAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('User clicks confirm subscription in the email', async () => {
|
await step('User clicks confirm subscription in the email', async () => {
|
||||||
|
@ -497,13 +531,117 @@ suite('Subscription use-cases', () => {
|
||||||
await page.webManage.waitUntilVisibleAfterRefresh();
|
await page.webManage.waitUntilVisibleAfterRefresh();
|
||||||
await page.webManage.waitForFlash();
|
await page.webManage.waitForFlash();
|
||||||
expect(await page.webManage.getFlash()).to.contain('Email address changed');
|
expect(await page.webManage.getFlash()).to.contain('Email address changed');
|
||||||
expect(await page.webManage.getValue('emailInput')).to.equal(oldSubscription.email);
|
expect(await page.webManage.getValue('emailInput')).to.equal(oldSubscription.EMAIL);
|
||||||
expect(await page.webManage.getValue('firstNameInput')).to.equal(newSubscription.firstName);
|
expect(await page.webManage.getValue('firstNameInput')).to.equal(newSubscription.FIRST_NAME);
|
||||||
expect(await page.webManage.getValue('lastNameInput')).to.equal('');
|
expect(await page.webManage.getValue('lastNameInput')).to.equal('');
|
||||||
});
|
});
|
||||||
|
|
||||||
await step('System sends an email with subscription confirmation.', async () => {
|
await step('System sends an email with subscription confirmation.', async () => {
|
||||||
await page.mailSubscriptionConfirmed.fetchMail(oldSubscription.email);
|
await page.mailSubscriptionConfirmed.fetchMail(oldSubscription.EMAIL);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
async function apiSubscribe(listConf, subscription) {
|
||||||
|
await step('Add subscription via API call.', async () => {
|
||||||
|
const response = await request({
|
||||||
|
uri: `${config.baseUrl}/api/subscribe/${listConf.cid}?access_token=${config.users.admin.accessToken}`,
|
||||||
|
method: 'POST',
|
||||||
|
json: subscription
|
||||||
|
});
|
||||||
|
expect(response.error).to.be.a('undefined');
|
||||||
|
expect(response.data.id).to.be.a('string');
|
||||||
|
subscription.ucid = response.data.id;
|
||||||
|
});
|
||||||
|
return subscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
suite('API Subscription use-cases', () => {
|
||||||
|
|
||||||
|
useCase('Subscription to list #1, without confirmation.', async () => {
|
||||||
|
const page = getPage(config.lists.l1);
|
||||||
|
const subscription = await apiSubscribe(config.lists.l1, generateSubscriptionData(config.lists.l1));
|
||||||
|
|
||||||
|
await step('User navigates to manage subscription.', async () => {
|
||||||
|
await page.webManage.navigate({ ucid: subscription.ucid });
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('Systems shows a form containing the data submitted with the API call.', async () => {
|
||||||
|
await page.webManage.assertFields(subscription);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
useCase('Subscription to list #1, with confirmation.', async () => {
|
||||||
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
|
const subscription = await apiSubscribe(config.lists.l1, Object.assign(generateSubscriptionData(config.lists.l1), {
|
||||||
|
REQUIRE_CONFIRMATION: 'yes'
|
||||||
|
}));
|
||||||
|
|
||||||
|
await step('System sends an email with a link to confirm the subscription.', async () => {
|
||||||
|
await page.mailConfirmSubscription.fetchMail(subscription.EMAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('User clicks confirm subscription in the email', async () => {
|
||||||
|
await page.mailConfirmSubscription.click('confirmLink');
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('System shows a notice that subscription has been confirmed.', async () => {
|
||||||
|
await page.webSubscribedNotice.waitUntilVisibleAfterRefresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('System sends an email with subscription confirmation.', async () => {
|
||||||
|
await page.mailSubscriptionConfirmed.fetchMail(subscription.EMAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('User navigates to manage subscription.', async () => {
|
||||||
|
await page.webManage.navigate({ ucid: subscription.ucid });
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('Systems shows a form containing the data submitted with the API call.', async () => {
|
||||||
|
await page.webManage.assertFields(subscription);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
useCase('Change profile info', async () => {
|
||||||
|
const page = getPage(config.lists.l1);
|
||||||
|
|
||||||
|
const initialSubscription = await apiSubscribe(config.lists.l1, generateSubscriptionData(config.lists.l1));
|
||||||
|
|
||||||
|
const update = changeSubscriptionData(config.lists.l1, initialSubscription);
|
||||||
|
delete update.FIRST_NAME;
|
||||||
|
|
||||||
|
const changedSubscription = await apiSubscribe(config.lists.l1, update);
|
||||||
|
changedSubscription.FIRST_NAME = initialSubscription.FIRST_NAME;
|
||||||
|
|
||||||
|
expect(changedSubscription.ucid).to.equal(initialSubscription.ucid);
|
||||||
|
|
||||||
|
await step('User navigates to manage subscription.', async () => {
|
||||||
|
await page.webManage.navigate({ ucid: changedSubscription.ucid });
|
||||||
|
});
|
||||||
|
|
||||||
|
await step('Systems shows a form containing the updated subscription data.', async () => {
|
||||||
|
await page.webManage.assertFields(changedSubscription);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
useCase('Unsubscribe', async () => {
|
||||||
|
const subscription = await apiSubscribe(config.lists.l1, generateSubscriptionData(config.lists.l1));
|
||||||
|
|
||||||
|
await step('Unsubsribe via API call.', async () => {
|
||||||
|
const response = await request({
|
||||||
|
uri: `${config.baseUrl}/api/unsubscribe/${config.lists.l1.cid}?access_token=${config.users.admin.accessToken}`,
|
||||||
|
method: 'POST',
|
||||||
|
json: {
|
||||||
|
EMAIL: subscription.EMAIL
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(response.error).to.be.a('undefined');
|
||||||
|
expect(response.data.id).to.be.a('number'); // FIXME Shouldn't data.id be the cid instead of the DB id?
|
||||||
|
expect(response.data.unsubscribed).to.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue