• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thoughtspot / visual-embed-sdk / #1451

16 Jan 2025 06:06AM UTC coverage: 41.695% (-52.2%) from 93.86%
#1451

Pull #65

Prashant.patil
SCAL-233454-exp removing all extra config and checking
Pull Request #65: test-exported memb

273 of 1114 branches covered (24.51%)

Branch coverage included in aggregate %.

84 of 366 new or added lines in 14 files covered. (22.95%)

1011 existing lines in 23 files now uncovered.

1301 of 2661 relevant lines covered (48.89%)

9.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.29
/src/utils/processData.ts
1
import { getEmbedConfig } from '../embed/embedConfig';
14✔
2
import {
14✔
3
    disableAutoLogin,
4
    notifyAuthFailure,
5
    notifyAuthSuccess,
6
    notifyLogout,
7
} from '../embed/base';
8
import { AuthFailureType } from '../auth';
14✔
9
import { AuthType, CustomActionPayload, EmbedEvent } from '../types';
14✔
10
import { AnswerService } from './graphql/answerService/answerService';
14✔
11
import { resetCachedAuthToken } from '../authToken';
14✔
12
import { ERROR_MESSAGE } from '../errors';
14✔
13

14
/**
15
 *
16
 * @param e
17
 * @param thoughtSpotHost
18
 */
19
export function processCustomAction(e: any, thoughtSpotHost: string) {
14✔
UNCOV
20
    const { session, embedAnswerData, contextMenuPoints } = e.data as CustomActionPayload;
×
UNCOV
21
    const answerService = new AnswerService(
×
22
        session,
23
        embedAnswerData || {},
×
24
        thoughtSpotHost,
25
        contextMenuPoints?.selectedPoints,
×
26
    );
UNCOV
27
    return {
×
28
        ...e,
29
        answerService,
30
    };
31
}
32

33
/**
34
 * Responds to AuthInit sent from host signifying successful authentication in host.
35
 * @param e
36
 * @returns {any}
37
 */
38
function processAuthInit(e: any) {
UNCOV
39
    notifyAuthSuccess();
×
40

41
    // Expose only allowed details (eg: userGUID) back to SDK users.
UNCOV
42
    return {
×
43
        ...e,
44
        data: {
45
            userGUID: e.data?.userGUID || e.payload?.userGUID,
×
46
        },
47
    };
48
}
49

50
/**
51
 *
52
 * @param e
53
 * @param containerEl
54
 */
55
function processNoCookieAccess(e: any, containerEl: Element) {
56
    const {
57
        loginFailedMessage,
58
        suppressNoCookieAccessAlert,
59
        ignoreNoCookieAccess,
60
        suppressErrorAlerts,
UNCOV
61
    } = getEmbedConfig();
×
UNCOV
62
    if (!ignoreNoCookieAccess) {
×
UNCOV
63
        if (!suppressNoCookieAccessAlert && !suppressErrorAlerts) {
×
64
            // eslint-disable-next-line no-alert
UNCOV
65
            alert(ERROR_MESSAGE.THIRD_PARTY_COOKIE_BLOCKED_ALERT);
×
66
        }
67
        // eslint-disable-next-line no-param-reassign
UNCOV
68
        containerEl.innerHTML = loginFailedMessage;
×
69
    }
UNCOV
70
    notifyAuthFailure(AuthFailureType.NO_COOKIE_ACCESS);
×
UNCOV
71
    return e;
×
72
}
73

74
/**
75
 *
76
 * @param e
77
 * @param containerEl
78
 */
79
export function processAuthFailure(e: any, containerEl: Element) {
14✔
UNCOV
80
    const { loginFailedMessage, authType, disableLoginFailurePage } = getEmbedConfig();
×
UNCOV
81
    if (authType !== AuthType.None && !disableLoginFailurePage) {
×
82
        // eslint-disable-next-line no-param-reassign
UNCOV
83
        containerEl.innerHTML = loginFailedMessage;
×
UNCOV
84
        notifyAuthFailure(AuthFailureType.OTHER);
×
85
    }
UNCOV
86
    resetCachedAuthToken();
×
UNCOV
87
    return e;
×
88
}
89

90
/**
91
 *
92
 * @param e
93
 * @param containerEl
94
 */
95
function processAuthLogout(e: any, containerEl: Element) {
UNCOV
96
    const { loginFailedMessage } = getEmbedConfig();
×
97
    // eslint-disable-next-line no-param-reassign
UNCOV
98
    containerEl.innerHTML = loginFailedMessage;
×
UNCOV
99
    resetCachedAuthToken();
×
UNCOV
100
    disableAutoLogin();
×
UNCOV
101
    notifyLogout();
×
UNCOV
102
    return e;
×
103
}
104

105
/**
106
 *
107
 * @param type
108
 * @param e
109
 * @param thoughtSpotHost
110
 * @param containerEl
111
 */
112
export function processEventData(
14✔
113
    type: EmbedEvent,
114
    e: any,
115
    thoughtSpotHost: string,
116
    containerEl: Element,
117
): any {
UNCOV
118
    switch (type) {
×
119
        case EmbedEvent.CustomAction:
UNCOV
120
            return processCustomAction(e, thoughtSpotHost);
×
121
        case EmbedEvent.AuthInit:
UNCOV
122
            return processAuthInit(e);
×
123
        case EmbedEvent.NoCookieAccess:
UNCOV
124
            return processNoCookieAccess(e, containerEl);
×
125
        case EmbedEvent.AuthFailure:
UNCOV
126
            return processAuthFailure(e, containerEl);
×
127
        case EmbedEvent.AuthLogout:
UNCOV
128
            return processAuthLogout(e, containerEl);
×
129
        default:
130
    }
UNCOV
131
    return e;
×
132
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc