forked from erxes/erxes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send engage content to single email address to test (erxes#2586)
- Loading branch information
1 parent
f6b26c4
commit 695c77c
Showing
11 changed files
with
219 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -774,20 +774,6 @@ describe('engage message mutation tests', () => { | |
{ email: '[email protected]' } | ||
); | ||
|
||
mock = sinon.stub(api, 'engagesSendTestEmail').callsFake(() => { | ||
return Promise.resolve('true'); | ||
}); | ||
|
||
await check( | ||
` | ||
mutation engageMessageSendTestEmail($from: String!, $to: String!, $content: String!) { | ||
engageMessageSendTestEmail(from: $from, to: $to, content: $content) | ||
} | ||
`, | ||
'engageMessageSendTestEmail', | ||
{ from: '[email protected]', to: '[email protected]', content: 'content' } | ||
); | ||
|
||
mock.restore(); | ||
}); | ||
|
||
|
@@ -827,4 +813,60 @@ describe('engage message mutation tests', () => { | |
|
||
expect(response.fromIntegration._id).toBe(integration._id); | ||
}); | ||
|
||
test('Test engageMessageSendTestEmail()', async () => { | ||
const sendRequest = args => { | ||
return graphqlRequest( | ||
` | ||
mutation engageMessageSendTestEmail( | ||
$from: String!, | ||
$to: String!, | ||
$content: String!, | ||
$title: String! | ||
) { | ||
engageMessageSendTestEmail(from: $from, to: $to, content: $content, title: $title) | ||
} | ||
`, | ||
'engageMessageSendTestEmail', | ||
args, | ||
{ dataSources } | ||
); | ||
}; | ||
|
||
const mock = sinon | ||
.stub(dataSources.EngagesAPI, 'engagesSendTestEmail') | ||
.callsFake(() => { | ||
return Promise.resolve('true'); | ||
}); | ||
|
||
const params = { | ||
from: '[email protected]', | ||
to: '[email protected]', | ||
content: 'content', | ||
title: 'hello' | ||
}; | ||
|
||
const response = await sendRequest(params); | ||
|
||
expect(response).toBe('true'); | ||
|
||
// check missing title | ||
try { | ||
params.title = ''; | ||
|
||
await sendRequest(params); | ||
} catch (e) { | ||
expect(e[0].message).toBe( | ||
'Email content, title, from address or to address is missing' | ||
); | ||
} | ||
|
||
// check with valid customer | ||
params.to = _customer.primaryEmail; | ||
params.title = 'hello'; | ||
|
||
await sendRequest(params); | ||
|
||
mock.restore(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.