• 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

41.3
/apps/web/src/hooks/usePaginationParams.tsx
1
import { usePathname, useRouter, useSearchParams } from "next/navigation";
1✔
2
import { pathOr } from "ramda";
1✔
3
import { useCallback, useMemo } from "react";
1✔
4
import { useQueryParams } from "./useQueryParams";
1✔
5

1✔
6
export const limitBounds = {
1✔
7
    "10": 10,
1✔
8
    "20": 20,
1✔
9
    "30": 30,
1✔
10
} as const;
1✔
11

1✔
12
export type LimitBound = (typeof limitBounds)[keyof typeof limitBounds];
1✔
13

1✔
14
export type UsePaginationReturn = [
1✔
15
    { limit: LimitBound; page: number },
1✔
16
    (page: number, limit: LimitBound) => void,
1✔
17
];
1✔
18

1✔
19
export const usePaginationParams = (): UsePaginationReturn => {
1✔
20
    const searchParams = useSearchParams();
×
21
    const router = useRouter();
×
22
    const pathName = usePathname();
×
23
    const { query } = useQueryParams();
×
24
    const urlSearchParams = new URLSearchParams(searchParams);
×
25
    const pg = parseInt(urlSearchParams.get("pg") ?? "");
×
26
    const lt = urlSearchParams.get("lt") ?? limitBounds[10];
×
27
    const limit = pathOr(limitBounds[10], [lt], limitBounds);
×
28
    const page = isNaN(pg) ? 1 : pg;
×
29
    const updateParams = useCallback(
×
30
        (page: number, limit: number): void => {
×
31
            const urlSearchParams = new URLSearchParams({
×
32
                query: query.toString(),
×
33
                pg: page.toString(),
×
34
                lt: limit.toString(),
×
35
            });
×
36
            router.push(`${pathName}?${urlSearchParams.toString()}`, {
×
37
                scroll: false,
×
38
            });
×
39
        },
×
40
        [query, router, pathName],
×
41
    );
×
42
    return useMemo(
×
43
        () => [{ page, limit }, updateParams],
×
44
        [limit, page, updateParams],
×
45
    );
×
46
};
×
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