Release v2.11.1
This commit is contained in:
@@ -118,3 +118,57 @@ test('settings route renders the overview', async () => {
|
||||
});
|
||||
assert.equal(Number(videoInsert.params[1]), 1024 * 1024 * 1024);
|
||||
});
|
||||
|
||||
test('email settings can send a test email to the logged-in user', async () => {
|
||||
const handlers = {};
|
||||
const sentMessages = [];
|
||||
const app = {
|
||||
get(path, ...routeHandlers) {
|
||||
handlers[path] = routeHandlers;
|
||||
},
|
||||
post(path, ...routeHandlers) {
|
||||
handlers['POST ' + path] = routeHandlers;
|
||||
}
|
||||
};
|
||||
|
||||
registerSettingsRoutes(app, {
|
||||
pages: {},
|
||||
pool: {
|
||||
async query(sql) {
|
||||
if (/SELECT id, setting_key, setting_value FROM o_app_settings/.test(sql)) {
|
||||
return [[
|
||||
{ setting_key: 'email.smtp_enabled', setting_value: 'true' },
|
||||
{ setting_key: 'email.smtp_host', setting_value: 'smtp.example.test' },
|
||||
{ setting_key: 'email.from_address', setting_value: 'pulse@example.test' }
|
||||
]];
|
||||
}
|
||||
throw new Error('Unexpected settings write during test email action.');
|
||||
}
|
||||
},
|
||||
requirePermission() {
|
||||
return function (_req, _res, next) {
|
||||
next();
|
||||
};
|
||||
},
|
||||
sendAccountEmail(settings, message) {
|
||||
sentMessages.push({ settings, message });
|
||||
}
|
||||
});
|
||||
|
||||
const response = {
|
||||
redirect(url) {
|
||||
this.redirectedTo = url;
|
||||
}
|
||||
};
|
||||
await handlers['POST /settings/system'][1]({
|
||||
body: { settings_section: 'email', settings_action: 'test_email' },
|
||||
currentUser: { id: 7, email: 'admin@example.test' }
|
||||
}, response, function (error) {
|
||||
throw error;
|
||||
});
|
||||
|
||||
assert.equal(sentMessages.length, 1);
|
||||
assert.equal(sentMessages[0].message.to, 'admin@example.test');
|
||||
assert.equal(sentMessages[0].message.subject, 'Pulse Signage SMTP test email');
|
||||
assert.match(response.redirectedTo, /Test%20email%20sent%20to%20admin%40example\.test/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user