Skip to content

Commit

Permalink
Use settings for extra prechat info and form details
Browse files Browse the repository at this point in the history
  • Loading branch information
bobisjan committed May 17, 2023
1 parent 2db97ca commit bbd1afd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
4 changes: 2 additions & 2 deletions addon/services/liveagent.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export default class LiveAgentService extends Service {
svc.settings.storageDomain = domain;
}

svc.snippetSettingsFile.extraPrechatFormDetails = extraPrechatFormDetails;
svc.snippetSettingsFile.extraPrechatInfo = extraPrechatInfo;
svc.settings.extraPrechatFormDetails = extraPrechatFormDetails;
svc.settings.extraPrechatInfo = extraPrechatInfo;

svc.init(
salesforceURL,
Expand Down
16 changes: 3 additions & 13 deletions tests/unit/services/liveagent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ module('Unit | Service | liveagent', function (hooks) {
hooks.afterEach(clear);

test('it boots', function (assert) {
assert.expect(9);
assert.expect(8);

window.embedded_svc = {
settings: {},
snippetSettingsFile: {},
init() {
assert.strictEqual(arguments.length, 6);
assert.strictEqual(arguments[0], 'test://salesforceURL');
Expand Down Expand Up @@ -48,20 +47,16 @@ module('Unit | Service | liveagent', function (hooks) {
loadingText: 'Loading',
offlineSupportMinimizedText: 'Contact Us',
prepopulatedPrechatFields: {},
});

assert.deepEqual(window.embedded_svc.snippetSettingsFile, {
extraPrechatFormDetails: [],
extraPrechatInfo: [],
});
});

test('it boots with custom options', function (assert) {
assert.expect(9);
assert.expect(8);

window.embedded_svc = {
settings: {},
snippetSettingsFile: {},
init() {
assert.strictEqual(arguments.length, 6);
assert.strictEqual(arguments[0], 'test://salesforceURL');
Expand Down Expand Up @@ -109,20 +104,16 @@ module('Unit | Service | liveagent', function (hooks) {
field: 'custom://prepopulatedPrechatFields',
},
storageDomain: 'custom://domain',
});

assert.deepEqual(window.embedded_svc.snippetSettingsFile, {
extraPrechatFormDetails: ['custom://extraPrechatFormDetails'],
extraPrechatInfo: ['custom://extraPrechatInfo'],
});
});

test('it does not boot in FastBoot', function (assert) {
assert.expect(2);
assert.expect(1);

window.embedded_svc = {
settings: {},
snippetSettingsFile: {},
init() {
assert.ok(false);
},
Expand All @@ -134,6 +125,5 @@ module('Unit | Service | liveagent', function (hooks) {
service.boot();

assert.deepEqual(window.embedded_svc.settings, {});
assert.deepEqual(window.embedded_svc.snippetSettingsFile, {});
});
});

0 comments on commit bbd1afd

Please sign in to comment.