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

thoughtspot / visual-embed-sdk / #1337

03 Jan 2025 06:00AM UTC coverage: 90.769% (-2.9%) from 93.701%
#1337

Pull #65

yinstardev
SCAL-233454-exp temp-testcases skip
Pull Request #65: test-exported memb

918 of 1087 branches covered (84.45%)

Branch coverage included in aggregate %.

76 of 135 new or added lines in 7 files covered. (56.3%)

19 existing lines in 2 files now uncovered.

2376 of 2542 relevant lines covered (93.47%)

52.69 hits per line

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

57.58
/src/utils/authService/tokenizedAuthService.ts
1
import { tokenizedFetch } from '../../tokenizedFetch';
20✔
2
import { logger } from '../logger';
20✔
3
import { EndPoints } from './authService';
20✔
4

5
/**
6
 *
7
 * @param url
8
 * @param options
9
 */
10
function tokenizedFailureLoggedFetch(url: string, options: RequestInit = {}): Promise<Response> {
×
11
    return tokenizedFetch(url, options).then(async (r) => {
1✔
12
        if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
1!
UNCOV
13
            logger.error(`Failed to fetch ${url}`, await r.text?.());
×
14
        }
15
        return r;
1✔
16
    });
17
}
18

19
/**
20
 * Fetches the session info from the ThoughtSpot server.
21
 * @param thoughtspotHost
22
 * @returns {Promise<any>}
23
 * @example
24
 * ```js
25
 *  const response = await sessionInfoService();
26
 * ```
27
 */
28
export async function fetchSessionInfoService(thoughtspotHost: string): Promise<any> {
20✔
UNCOV
29
    const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
×
UNCOV
30
    const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
×
UNCOV
31
    if (!response.ok) {
×
UNCOV
32
        throw new Error(`Failed to fetch session info: ${response.statusText}`);
×
33
    }
UNCOV
34
    const data = await response.json();
×
UNCOV
35
    return data;
×
36
}
37

38
/**
39
 *
40
 * @param thoughtSpotHost
41
 */
42
export async function fetchLogoutService(thoughtSpotHost: string): Promise<any> {
20✔
43
    return tokenizedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
1✔
44
        credentials: 'include',
45
        method: 'POST',
46
        headers: {
47
            'x-requested-by': 'ThoughtSpot',
48
        },
49
    });
50
}
51

52
/**
53
 * Is active service to check if the user is logged in.
54
 * @param thoughtSpotHost
55
 * @version SDK: 1.28.4 | ThoughtSpot: *
56
 */
57
export async function isActiveService(thoughtSpotHost: string): Promise<boolean> {
20✔
58
    const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
3✔
59
    try {
3✔
60
        const res = await tokenizedFetch(isActiveUrl, {
3✔
61
            credentials: 'include',
62
        });
63
        return res.ok;
2✔
64
    } catch (e) {
65
        logger.warn(`Is Logged In Service failed : ${e.message}`);
1✔
66
    }
67

68
    return false;
1✔
69
}
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

© 2025 Coveralls, Inc