Skip to content

Commit f291b49

Browse files
committed
Fix bug where config is not updated after load.
1 parent 12ee82c commit f291b49

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/embed.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export abstract class Embed {
170170

171171
return this.service.hpm.post<void>('/report/load', config, { uid: this.config.uniqueId }, this.iframe.contentWindow)
172172
.then(response => {
173+
utils.assign(this.config, config);
173174
return response.body;
174175
},
175176
response => {

test/test.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,30 @@ describe('SDK-to-HPM', function () {
18331833
done();
18341834
});
18351835
});
1836+
1837+
it('report.load() updates the internal configuration if the load request was successful', function (done) {
1838+
// Arrange
1839+
const testData = {
1840+
loadConfiguration: {
1841+
id: 'newFakeId',
1842+
accessToken: 'newFakeToken'
1843+
},
1844+
response: {
1845+
body: null
1846+
}
1847+
};
1848+
1849+
spyHpm.post.and.returnValue(Promise.resolve(testData.response));
1850+
1851+
// Act
1852+
report.load(testData.loadConfiguration)
1853+
.then(response => {
1854+
expect(report.config).toEqual(jasmine.objectContaining(testData.loadConfiguration));
1855+
expect(response).toEqual(null);
1856+
// Assert
1857+
done();
1858+
});
1859+
});
18361860
});
18371861

18381862
describe('pages', function () {

0 commit comments

Comments
 (0)