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

cartesi / rollups-explorer / 9656272020

25 Jun 2024 04:06AM CUT coverage: 94.098% (+0.001%) from 94.097%
9656272020

Pull #187

github

brunomenezes
feat(e2e): Add fixture to intercept graphql calls for rollups graphql api by Operation name.

Trust on nodes running makes the e2e tests brittle. Therefore, any call to a Rollups graphQL API will get a mocked response for better control.
Pull Request #187: #183 Add e2e tests for inputs page

759 of 893 branches covered (84.99%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

8408 of 8849 relevant lines covered (95.02%)

55.53 hits per line

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

45.76
/apps/web/src/providers/connectionConfig/localRepository.ts
1
"use client";
1✔
2
import { hasPath, omit, path, pathOr, values } from "ramda";
1✔
3
import { Config, Connection, Repository } from "./types";
1✔
4

1✔
5
const networkId = process.env.NEXT_PUBLIC_CHAIN_ID || "31337";
1✔
6
const namespace = `cartesiscan:conn` as const;
1✔
7
const deserialize = <T>(jsonString: string) => JSON.parse(jsonString) as T;
1✔
8
const serialize = (cfg: Config) => JSON.stringify(cfg);
1✔
9

1✔
10
const getConfig = () => {
1✔
11
    const raw = localStorage.getItem(namespace);
×
12
    return raw ? deserialize<Config>(raw) : { [networkId]: {} };
×
13
};
×
14

1✔
15
/**
1✔
16
 * Implements the Repository interface providing a persistent storage.
1✔
17
 * It uses the LocalStorage underneath.
1✔
18
 */
1✔
19
const localRepository: Repository = {
1✔
20
    async add(conn: Connection) {
1✔
21
        const cfg = getConfig();
×
22
        conn.timestamp = Date.now();
×
23
        if (cfg[networkId]) {
×
24
            cfg[networkId][conn.address] = conn;
×
25
        } else {
×
26
            cfg[networkId] = { [conn.address]: conn };
×
27
        }
×
28

×
29
        localStorage.setItem(namespace, serialize(cfg));
×
30
        return { ...conn };
×
31
    },
×
32

1✔
33
    async has(addr) {
1✔
34
        const cfg = getConfig();
×
35
        return hasPath([networkId, addr], cfg);
×
36
    },
×
37

1✔
38
    async remove(addr) {
1✔
39
        const cfg = getConfig();
×
40
        if (hasPath([networkId, addr], cfg)) {
×
41
            const newEntry = omit([addr], cfg[networkId]);
×
42
            cfg[networkId] = newEntry;
×
43
            localStorage.setItem(namespace, serialize(cfg));
×
44
        }
×
45

×
46
        return true;
×
47
    },
×
48
    async get(addr) {
1✔
49
        const cfg = getConfig();
×
50
        return pathOr<Connection | null>(null, [networkId, addr], cfg);
×
51
    },
×
52

1✔
53
    async list() {
1✔
54
        const cfg = getConfig();
×
55
        return values(path([networkId], cfg));
×
56
    },
×
57
};
1✔
58

1✔
59
export default localRepository;
1✔
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