Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

explorer: Add cardano db v2 support & rework tabs layout #2270

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mithril-explorer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ upgrade: clean install
bootstrap-icons@latest \
chart.js@latest \
next@latest \
react@^18.3.1 \
react@latest \
react-bootstrap@latest \
react-chartjs-2@latest \
react-dom@^18.3.1 \
react-dom@latest \
react-redux@latest \
@testing-library/jest-dom@latest \
@testing-library/react@latest \
Expand Down
71 changes: 71 additions & 0 deletions mithril-explorer/__tests__/DownloadImmutableFormInput.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { fireEvent, render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { DownloadImmutableFormInput } from "#/Artifacts/CardanoDbV2SnapshotsList/DownloadButton";

const maxImmutable = 100_000;

function setup(max) {
const utils = render(<DownloadImmutableFormInput max={max} />);
return {
input: screen.getByRole("spinbutton"),
...utils,
};
}

describe("DownloadImmutableFormInput", () => {
it("Empty default to invalid", () => {
const { input } = setup(maxImmutable);
expect(input.checkValidity()).toBeFalsy();
expect(input.value).toBe("");
});

it("Setting empty string is invalid", () => {
const { input } = setup(maxImmutable);
fireEvent.change(input, { target: { value: "" } });
expect(input.checkValidity()).toBeFalsy();
expect(input.value).toBe("");
});

it.each([0, 123, 67_782, maxImmutable])(
"Immutable below or equal to max allowed: %d",
(immutable_file_number) => {
const { input } = setup(maxImmutable);
fireEvent.change(input, {
target: { value: immutable_file_number },
});

expect(input.checkValidity()).toBeTruthy();
expect(input.value).toBe(`${immutable_file_number}`);
},
);

it.each([-4328, -1, maxImmutable + 1, 528_432])(
"Immutable above max or below 0 is invalid: %d",
(immutable_file_number) => {
const { input } = setup(maxImmutable);
fireEvent.change(input, {
target: { value: immutable_file_number },
});

expect(input.checkValidity()).toBeFalsy();
},
);

it.each(["@124", "⚠️", "text"])("Non-number is invalid: %s", (immutable_file_number) => {
const { input } = setup({ maxImmutable });
fireEvent.change(input, {
target: { value: immutable_file_number },
});

expect(input.checkValidity()).toBeFalsy();
});

it.each([0.1, 1.432, 67_782.32])("Float is invalid: %f", ({ immutable_file_number }) => {
const { input } = setup({ maxImmutable });
fireEvent.change(input, {
target: { value: immutable_file_number },
});

expect(input.checkValidity()).toBeFalsy();
});
});
23 changes: 23 additions & 0 deletions mithril-explorer/__tests__/getImmutableUrlFromTemplate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { getImmutableUrlFromTemplate } from "@/utils";

const urlTemplate = "https://example.com/{immutable_file_number}.tar.zst";

describe("Get Immutable Url from template", () => {
it.each([
[0, "https://example.com/00000.tar.zst"],
[1, "https://example.com/00001.tar.zst"],
[23, "https://example.com/00023.tar.zst"],
[437, "https://example.com/00437.tar.zst"],
[9428, "https://example.com/09428.tar.zst"],
[52983, "https://example.com/52983.tar.zst"],
[103202, "https://example.com/103202.tar.zst"],
])("padding immutable file number with zeros to 5 digits", (immutableFileNumber, expected) => {
expect(getImmutableUrlFromTemplate(urlTemplate, immutableFileNumber)).toEqual(expected);
});

it("numbers with more than 5 digits are not cut", () => {
expect(getImmutableUrlFromTemplate(urlTemplate, 103202)).toEqual(
"https://example.com/103202.tar.zst",
);
});
});
Loading
Loading