1
0
Fork 0
mirror of synced 2024-09-28 15:21:28 +12:00

Fixing worker test cases.

This commit is contained in:
mike12345567 2021-05-19 16:39:17 +01:00
parent 0db486d4e8
commit 584f7c2403
5 changed files with 24 additions and 17 deletions

View file

@ -30,7 +30,7 @@ describe("/api/admin/auth", () => {
expect(sendMailMock).toHaveBeenCalled()
const emailCall = sendMailMock.mock.calls[0][0]
// 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]
expect(code).toBeDefined()
})

View file

@ -13,7 +13,7 @@ describe("/api/admin/configs/checklist", () => {
let config = setup.getConfig()
beforeAll(async () => {
await config.init()
await config.init(false)
})
afterAll(setup.afterAll)

View file

@ -30,7 +30,7 @@ describe("/api/admin/users", () => {
expect(sendMailMock).toHaveBeenCalled()
const emailCall = sendMailMock.mock.calls[0][0]
// 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]
expect(code).toBeDefined()
})

View file

@ -38,20 +38,25 @@ class TestConfiguration {
return request.body
}
async init() {
// create a test user
await this._req(
{
email: "test@test.com",
password: "test",
_id: "us_uuid1",
builder: {
global: true,
async init(createUser = true) {
if (createUser) {
// create a test user
await this._req(
{
email: "test@test.com",
password: "test",
_id: "us_uuid1",
builder: {
global: true,
},
admin: {
global: true,
},
},
},
null,
controllers.users.save
)
null,
controllers.users.save
)
}
}
async end() {

View file

@ -155,10 +155,12 @@ exports.sendEmail = async (
const context = await getSettingsTemplateContext(purpose, code)
const message = {
from: from || config.from,
subject: await processString(subject || config.subject, context),
to: email,
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)
if (TEST_MODE) {
console.log("Test email URL: " + nodemailer.getTestMessageUrl(response))