Fixing worker test cases.
This commit is contained in:
parent
7d3169e5e1
commit
12bbe19ed0
|
@ -30,7 +30,7 @@ describe("/api/admin/auth", () => {
|
||||||
expect(sendMailMock).toHaveBeenCalled()
|
expect(sendMailMock).toHaveBeenCalled()
|
||||||
const emailCall = sendMailMock.mock.calls[0][0]
|
const emailCall = sendMailMock.mock.calls[0][0]
|
||||||
// after this URL there should be a code
|
// after this URL there should be a code
|
||||||
const parts = emailCall.html.split("http://localhost:10000/reset?code=")
|
const parts = emailCall.html.split("http://localhost:10000/builder/auth/reset?code=")
|
||||||
code = parts[1].split("\"")[0]
|
code = parts[1].split("\"")[0]
|
||||||
expect(code).toBeDefined()
|
expect(code).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,7 +13,7 @@ describe("/api/admin/configs/checklist", () => {
|
||||||
let config = setup.getConfig()
|
let config = setup.getConfig()
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await config.init()
|
await config.init(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterAll(setup.afterAll)
|
afterAll(setup.afterAll)
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe("/api/admin/users", () => {
|
||||||
expect(sendMailMock).toHaveBeenCalled()
|
expect(sendMailMock).toHaveBeenCalled()
|
||||||
const emailCall = sendMailMock.mock.calls[0][0]
|
const emailCall = sendMailMock.mock.calls[0][0]
|
||||||
// after this URL there should be a code
|
// after this URL there should be a code
|
||||||
const parts = emailCall.html.split("http://localhost:10000/invite?code=")
|
const parts = emailCall.html.split("http://localhost:10000/builder/invite?code=")
|
||||||
code = parts[1].split("\"")[0]
|
code = parts[1].split("\"")[0]
|
||||||
expect(code).toBeDefined()
|
expect(code).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
|
@ -38,7 +38,8 @@ class TestConfiguration {
|
||||||
return request.body
|
return request.body
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init(createUser = true) {
|
||||||
|
if (createUser) {
|
||||||
// create a test user
|
// create a test user
|
||||||
await this._req(
|
await this._req(
|
||||||
{
|
{
|
||||||
|
@ -48,11 +49,15 @@ class TestConfiguration {
|
||||||
builder: {
|
builder: {
|
||||||
global: true,
|
global: true,
|
||||||
},
|
},
|
||||||
|
admin: {
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
controllers.users.save
|
controllers.users.save
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async end() {
|
async end() {
|
||||||
if (this.server) {
|
if (this.server) {
|
||||||
|
|
|
@ -155,10 +155,12 @@ exports.sendEmail = async (
|
||||||
const context = await getSettingsTemplateContext(purpose, code)
|
const context = await getSettingsTemplateContext(purpose, code)
|
||||||
const message = {
|
const message = {
|
||||||
from: from || config.from,
|
from: from || config.from,
|
||||||
subject: await processString(subject || config.subject, context),
|
|
||||||
to: email,
|
to: email,
|
||||||
html: await buildEmail(purpose, email, context, { user, contents }),
|
html: await buildEmail(purpose, email, context, { user, contents }),
|
||||||
}
|
}
|
||||||
|
if (subject || config.subject) {
|
||||||
|
message.subject = await processString(subject || config.subject, context)
|
||||||
|
}
|
||||||
const response = await transport.sendMail(message)
|
const response = await transport.sendMail(message)
|
||||||
if (TEST_MODE) {
|
if (TEST_MODE) {
|
||||||
console.log("Test email URL: " + nodemailer.getTestMessageUrl(response))
|
console.log("Test email URL: " + nodemailer.getTestMessageUrl(response))
|
||||||
|
|
Loading…
Reference in New Issue