@thoughtspot/visual-embed-sdk
Version:
ThoughtSpot Embed SDK
968 lines • 65 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
* Unit tests for HostEvents that had no prior coverage.
* Covers: postMessage type correctness, !isRendered guard (returns null + handleError),
* and vizId injection on LiveboardEmbed when viewConfig.vizId is set.
*/
const index_1 = require("../index");
const test_utils_1 = require("../test/test-utils");
const authInstance = tslib_1.__importStar(require("../auth"));
const thoughtSpotHost = 'https://tshost';
const liveboardId = 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0';
const vizId = '6e73f724-660e-11eb-ae93-0242ac130002';
beforeAll(() => {
(0, index_1.init)({ thoughtSpotHost, authType: index_1.AuthType.None });
jest.spyOn(authInstance, 'postLoginService').mockImplementation(() => Promise.resolve(true));
});
beforeEach(() => {
document.body.innerHTML = (0, test_utils_1.getDocumentBody)();
});
// ---------------------------------------------------------------------------
// Helper: render a LiveboardEmbed and return it with the iframe spy
// ---------------------------------------------------------------------------
async function renderLiveboard(extraConfig = {}) {
const lb = new index_1.LiveboardEmbed((0, test_utils_1.getRootEl)(), {
frameParams: { width: '100%', height: '100%' },
liveboardId,
...extraConfig,
});
await lb.render();
const iframe = (0, test_utils_1.getIFrameEl)();
jest.spyOn(iframe.contentWindow, 'postMessage');
return { lb, iframe };
}
// Helper: create a LiveboardEmbed that has NOT been rendered, with handleError
// mocked to prevent the jest-setup console.error → throw.
function unrenderedLiveboard() {
const lb = new index_1.LiveboardEmbed((0, test_utils_1.getRootEl)(), {
frameParams: { width: '100%', height: '100%' },
liveboardId,
});
jest.spyOn(lb, 'handleError').mockImplementation(() => { });
return lb;
}
// ---------------------------------------------------------------------------
// 3 – Filter
// ---------------------------------------------------------------------------
describe('HostEvent.Filter', () => {
test('postMessage type is filter (all lowercase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Filter, { columnName: 'col', operator: 'EQ', values: ['v'] });
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'filter' }), thoughtSpotHost, expect.anything());
});
});
test('returns null and calls handleError when !isRendered', async () => {
const lb = unrenderedLiveboard();
const handleErrorSpy = lb.handleError;
const result = await lb.trigger(index_1.HostEvent.Filter, {});
expect(result).toBeNull();
expect(handleErrorSpy).toHaveBeenCalledWith(expect.objectContaining({ code: index_1.EmbedErrorCodes.RENDER_NOT_CALLED }));
});
});
// ---------------------------------------------------------------------------
// 8 – UpdateRuntimeFilters
// ---------------------------------------------------------------------------
describe('HostEvent.UpdateRuntimeFilters', () => {
test('postMessage type is UpdateRuntimeFilters (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.UpdateRuntimeFilters, []);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'UpdateRuntimeFilters' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.UpdateRuntimeFilters, []);
expect(result).toBeNull();
});
test('vizId is injected when viewConfig.vizId is set and payload is object', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard({ vizId });
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.UpdateRuntimeFilters, [{}]);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'UpdateRuntimeFilters' }), thoughtSpotHost, expect.anything());
});
});
});
// ---------------------------------------------------------------------------
// 10 – OpenFilter
// ---------------------------------------------------------------------------
describe('HostEvent.OpenFilter', () => {
test('postMessage type is openFilter (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.OpenFilter, { columnId: 'col1' });
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'openFilter' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.OpenFilter, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 11 – AddColumns
// ---------------------------------------------------------------------------
describe('HostEvent.AddColumns', () => {
test('postMessage type is addColumns (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.AddColumns, { columnIds: ['c1'] });
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'addColumns' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.AddColumns, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 12 – RemoveColumn
// ---------------------------------------------------------------------------
describe('HostEvent.RemoveColumn', () => {
test('postMessage type is removeColumn (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.RemoveColumn, { columnId: 'c1' });
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'removeColumn' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.RemoveColumn, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 15 – LiveboardInfo
// ---------------------------------------------------------------------------
describe('HostEvent.LiveboardInfo', () => {
test('postMessage type is pinboardInfo', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.LiveboardInfo);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'pinboardInfo' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.LiveboardInfo);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 16 – Schedule
// ---------------------------------------------------------------------------
describe('HostEvent.Schedule', () => {
test('postMessage type is subscription', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Schedule);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'subscription' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Schedule);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 17 – SchedulesList
// ---------------------------------------------------------------------------
describe('HostEvent.SchedulesList', () => {
test('postMessage type is schedule-list (hyphenated)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SchedulesList);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'schedule-list' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SchedulesList);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 18 – ExportTML
// ---------------------------------------------------------------------------
describe('HostEvent.ExportTML', () => {
test('postMessage type is exportTSL (uses TSL abbreviation)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.ExportTML);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'exportTSL' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.ExportTML);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 19 – EditTML
// ---------------------------------------------------------------------------
describe('HostEvent.EditTML', () => {
test('postMessage type is editTSL', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.EditTML);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'editTSL' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.EditTML);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 20 – UpdateTML
// ---------------------------------------------------------------------------
describe('HostEvent.UpdateTML', () => {
test('postMessage type is updateTSL', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.UpdateTML);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'updateTSL' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.UpdateTML);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 21 – DownloadAsPdf
// ---------------------------------------------------------------------------
describe('HostEvent.DownloadAsPdf', () => {
test('postMessage type is downloadAsPdf (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.DownloadAsPdf);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'downloadAsPdf' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.DownloadAsPdf);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 22 – DownloadLiveboardAsContinuousPDF
// ---------------------------------------------------------------------------
describe('HostEvent.DownloadLiveboardAsContinuousPDF', () => {
test('postMessage type is downloadLiveboardAsContinuousPDF', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.DownloadLiveboardAsContinuousPDF);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'downloadLiveboardAsContinuousPDF' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.DownloadLiveboardAsContinuousPDF);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 23 – AIHighlights
// ---------------------------------------------------------------------------
describe('HostEvent.AIHighlights', () => {
test('postMessage type is AIHighlights (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.AIHighlights);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'AIHighlights' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.AIHighlights);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 24 – MakeACopy
// ---------------------------------------------------------------------------
describe('HostEvent.MakeACopy', () => {
test('postMessage type is makeACopy (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.MakeACopy);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'makeACopy' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.MakeACopy);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 25 – Remove (maps to 'delete' string)
// ---------------------------------------------------------------------------
describe('HostEvent.Remove', () => {
test("postMessage type is 'delete' (NOT 'Remove')", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Remove);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'delete' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Remove);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 26 – Explore
// ---------------------------------------------------------------------------
describe('HostEvent.Explore', () => {
test('postMessage type is explore (all lowercase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Explore, { vizId: 'v1' });
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'explore' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Explore, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 27 – CreateMonitor
// ---------------------------------------------------------------------------
describe('HostEvent.CreateMonitor', () => {
test('postMessage type is createMonitor (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.CreateMonitor);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'createMonitor' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.CreateMonitor);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 28 – ManageMonitor
// ---------------------------------------------------------------------------
describe('HostEvent.ManageMonitor', () => {
test('postMessage type is manageMonitor (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.ManageMonitor);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'manageMonitor' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.ManageMonitor);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 29 – Edit
// ---------------------------------------------------------------------------
describe('HostEvent.Edit', () => {
test('postMessage type is edit (all lowercase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Edit);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'edit' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Edit);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 30 – CopyLink (maps to 'embedDocument')
// ---------------------------------------------------------------------------
describe('HostEvent.CopyLink', () => {
test("postMessage type is 'embedDocument' (NOT 'CopyLink')", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.CopyLink);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'embedDocument' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.CopyLink);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 33 – ShowUnderlyingData
// ---------------------------------------------------------------------------
describe('HostEvent.ShowUnderlyingData', () => {
test('postMessage type is showUnderlyingData (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.ShowUnderlyingData);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'showUnderlyingData' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.ShowUnderlyingData);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 34 – Delete (maps to 'onDeleteAnswer')
// ---------------------------------------------------------------------------
describe('HostEvent.Delete', () => {
test("postMessage type is 'onDeleteAnswer' (NOT 'delete' or 'Delete')", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Delete);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'onDeleteAnswer' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Delete);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 35 – SpotIQAnalyze
// ---------------------------------------------------------------------------
describe('HostEvent.SpotIQAnalyze', () => {
test('postMessage type is spotIQAnalyze (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SpotIQAnalyze);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'spotIQAnalyze' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SpotIQAnalyze);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 36 – Download (maps to 'downloadAsPng', same as DownloadAsPng)
// ---------------------------------------------------------------------------
describe('HostEvent.Download', () => {
test("postMessage type is 'downloadAsPng' (same string as DownloadAsPng)", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Download);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'downloadAsPng' }), thoughtSpotHost, expect.anything());
});
});
test('Download and DownloadAsPng share the identical string value', () => {
expect(index_1.HostEvent.Download).toBe(index_1.HostEvent.DownloadAsPng);
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Download);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 37 – DownloadAsPng
// ---------------------------------------------------------------------------
describe('HostEvent.DownloadAsPng', () => {
test('postMessage type is downloadAsPng', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.DownloadAsPng);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'downloadAsPng' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.DownloadAsPng);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 39 – DownloadAsXlsx
// ---------------------------------------------------------------------------
describe('HostEvent.DownloadAsXlsx', () => {
test('postMessage type is downloadAsXLSX (capital X-L-S-X)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.DownloadAsXlsx);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'downloadAsXLSX' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.DownloadAsXlsx);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 40 – Share
// ---------------------------------------------------------------------------
describe('HostEvent.Share', () => {
test('postMessage type is share (all lowercase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.Share);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'share' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.Share);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 42 – SyncToSheets
// ---------------------------------------------------------------------------
describe('HostEvent.SyncToSheets', () => {
test('postMessage type is sync-to-sheets (hyphenated, all lowercase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SyncToSheets);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'sync-to-sheets' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SyncToSheets);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 43 – SyncToOtherApps
// ---------------------------------------------------------------------------
describe('HostEvent.SyncToOtherApps', () => {
test('postMessage type is sync-to-other-apps (hyphenated)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SyncToOtherApps);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'sync-to-other-apps' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SyncToOtherApps);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 44 – ManagePipelines
// ---------------------------------------------------------------------------
describe('HostEvent.ManagePipelines', () => {
test("postMessage type is 'manage-pipeline' (singular, hyphenated)", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.ManagePipelines);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'manage-pipeline' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.ManagePipelines);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 45 – ResetSearch
// ---------------------------------------------------------------------------
describe('HostEvent.ResetSearch', () => {
test('postMessage type is resetSearch (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.ResetSearch);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'resetSearch' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.ResetSearch);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 49 – SetVisibleTabs
// ---------------------------------------------------------------------------
describe('HostEvent.SetVisibleTabs', () => {
test("postMessage type is 'SetPinboardVisibleTabs' (NOT 'SetVisibleTabs')", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SetVisibleTabs, ['tab1']);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'SetPinboardVisibleTabs' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SetVisibleTabs, []);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 50 – SetHiddenTabs
// ---------------------------------------------------------------------------
describe('HostEvent.SetHiddenTabs', () => {
test("postMessage type is 'SetPinboardHiddenTabs' (NOT 'SetHiddenTabs')", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SetHiddenTabs, ['tab1']);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'SetPinboardHiddenTabs' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SetHiddenTabs, []);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 52 – AskSage
// ---------------------------------------------------------------------------
describe('HostEvent.AskSage', () => {
test('postMessage type is AskSage (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.AskSage);
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'AskSage' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.AskSage);
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 53 – UpdateCrossFilter
// ---------------------------------------------------------------------------
describe('HostEvent.UpdateCrossFilter', () => {
test('postMessage type is UpdateCrossFilter (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.UpdateCrossFilter, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'UpdateCrossFilter' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.UpdateCrossFilter, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 56 – UpdateParameters
// ---------------------------------------------------------------------------
describe('HostEvent.UpdateParameters', () => {
test('postMessage type is UpdateParameters (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.UpdateParameters, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'UpdateParameters' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.UpdateParameters, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 60 – SelectPersonalizedView (maps to British spelling)
// ---------------------------------------------------------------------------
describe('HostEvent.SelectPersonalizedView', () => {
test("postMessage type is 'SelectPersonalisedView' (British spelling)", async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SelectPersonalizedView, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'SelectPersonalisedView' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SelectPersonalizedView, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 64 – TransformTableVizData
// ---------------------------------------------------------------------------
describe('HostEvent.TransformTableVizData', () => {
test('postMessage type is TransformTableVizData (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.TransformTableVizData, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'TransformTableVizData' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.TransformTableVizData, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 65 – SpotterSearch
// ---------------------------------------------------------------------------
describe('HostEvent.SpotterSearch', () => {
test('postMessage type is SpotterSearch (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SpotterSearch, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'SpotterSearch' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SpotterSearch, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 66 – EditLastPrompt
// ---------------------------------------------------------------------------
describe('HostEvent.EditLastPrompt', () => {
test('postMessage type is EditLastPrompt (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.EditLastPrompt, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'EditLastPrompt' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.EditLastPrompt, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 67 – PreviewSpotterData
// ---------------------------------------------------------------------------
describe('HostEvent.PreviewSpotterData', () => {
test('postMessage type is PreviewSpotterData (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.PreviewSpotterData, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'PreviewSpotterData' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.PreviewSpotterData, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 68 – AddToCoaching
// ---------------------------------------------------------------------------
describe('HostEvent.AddToCoaching', () => {
test('postMessage type is addToCoaching (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.AddToCoaching, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'addToCoaching' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.AddToCoaching, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 69 – DataModelInstructions
// ---------------------------------------------------------------------------
describe('HostEvent.DataModelInstructions', () => {
test('postMessage type is DataModelInstructions (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.DataModelInstructions, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'DataModelInstructions' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.DataModelInstructions, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 70 – ResetSpotterConversation
// ---------------------------------------------------------------------------
describe('HostEvent.ResetSpotterConversation', () => {
test('postMessage type is ResetSpotterConversation (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.ResetSpotterConversation, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'ResetSpotterConversation' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.ResetSpotterConversation, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 71 – DeleteLastPrompt
// ---------------------------------------------------------------------------
describe('HostEvent.DeleteLastPrompt', () => {
test('postMessage type is DeleteLastPrompt (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.DeleteLastPrompt, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'DeleteLastPrompt' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.DeleteLastPrompt, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 72 – AnswerChartSwitcher
// ---------------------------------------------------------------------------
describe('HostEvent.AnswerChartSwitcher', () => {
test('postMessage type is answerChartSwitcher (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.AnswerChartSwitcher, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'answerChartSwitcher' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.AnswerChartSwitcher, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 75 – AskSpotter
// ---------------------------------------------------------------------------
describe('HostEvent.AskSpotter', () => {
test('postMessage type is AskSpotter (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.AskSpotter, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'AskSpotter' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.AskSpotter, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 78 – StartNewSpotterConversation
// ---------------------------------------------------------------------------
describe('HostEvent.StartNewSpotterConversation', () => {
test('postMessage type is StartNewSpotterConversation (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.StartNewSpotterConversation, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'StartNewSpotterConversation' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.StartNewSpotterConversation, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 80 – SendTestScheduleEmail
// ---------------------------------------------------------------------------
describe('HostEvent.SendTestScheduleEmail', () => {
test('postMessage type is sendTestScheduleEmail (camelCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SendTestScheduleEmail, {});
expect(iframe.contentWindow.postMessage).toHaveBeenCalledWith(expect.objectContaining({ type: 'sendTestScheduleEmail' }), thoughtSpotHost, expect.anything());
});
});
test('returns null when !isRendered', async () => {
const lb = unrenderedLiveboard();
const result = await lb.trigger(index_1.HostEvent.SendTestScheduleEmail, {});
expect(result).toBeNull();
});
});
// ---------------------------------------------------------------------------
// 81 – SpotterVizSendUserMessage
// ---------------------------------------------------------------------------
describe('HostEvent.SpotterVizSendUserMessage', () => {
test('postMessage type is SpotterVizSendUserMessage (PascalCase)', async () => {
(0, test_utils_1.mockMessageChannel)();
const { lb, iframe } = await renderLiveboard();
await (0, test_utils_1.executeAfterWait)(() => {
lb.trigger(index_1.HostEvent.SpotterVizSendUserMessage, {});
ex