-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from chalabi2/main
feats: mfx minting | tx indexing
- Loading branch information
Showing
155 changed files
with
7,739 additions
and
2,539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Prettier | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Bun | ||
uses: oven-sh/setup-bun@v1 | ||
- name: Install dependencies | ||
run: bun install | ||
- name: Check Prettier | ||
run: bun prettier . --check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Test and Coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Bun | ||
uses: oven-sh/setup-bun@v2 | ||
- name: Install dependencies | ||
run: bun install | ||
- name: Run tests and generate coverage | ||
run: bun run test:coverage | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
file: ./coverage/lcov.info | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ yarn-error.log* | |
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Ignore artifacts: | ||
build | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
preload = "./happydom.ts" |
62 changes: 62 additions & 0 deletions
62
components/admins/components/__tests__/adminOptions.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { afterEach, describe, expect, test } from "bun:test"; | ||
import React from "react"; | ||
import { screen, cleanup, within, fireEvent } from "@testing-library/react"; | ||
import AdminOptions from "@/components/admins/components/adminOptions"; | ||
import matchers from "@testing-library/jest-dom/matchers"; | ||
import { renderWithChainProvider } from "@/tests/render"; | ||
import { mockPoaParams, mockGroup } from "@/tests/mock"; | ||
|
||
expect.extend(matchers); | ||
|
||
const renderWithProps = (props = {}) => { | ||
const defaultProps = { | ||
poaParams: mockPoaParams, | ||
group: mockGroup, | ||
isLoading: false, | ||
address: "test_address", | ||
admin: "admin1", | ||
}; | ||
return renderWithChainProvider(<AdminOptions {...defaultProps} {...props} />); | ||
}; | ||
|
||
describe("AdminOptions", () => { | ||
afterEach(cleanup); | ||
|
||
test("renders loading state correctly", () => { | ||
renderWithProps({ isLoading: true }); | ||
expect(screen.getByText("Admin")).toBeInTheDocument(); | ||
}); | ||
|
||
test("renders admin details correctly when not loading", () => { | ||
renderWithProps(); | ||
expect(screen.getByText("Admin")).toBeInTheDocument(); | ||
expect(screen.getByAltText("Profile Avatar")).toBeInTheDocument(); | ||
const titleContainer = screen.getByLabelText("title"); | ||
expect(within(titleContainer).getByText("title1")).toBeInTheDocument(); | ||
const detailsContainer = screen.getByLabelText("details"); | ||
expect(within(detailsContainer).getByText("details1")).toBeInTheDocument(); | ||
}); | ||
|
||
test("opens update modal on button click", () => { | ||
renderWithProps(); | ||
const updateAdminButtonContainer = screen.getByLabelText("update admin"); | ||
fireEvent.click( | ||
within(updateAdminButtonContainer).getByText("Update Admin"), | ||
); | ||
const modal = document.getElementById( | ||
"update-admin-modal", | ||
) as HTMLDialogElement; | ||
expect(modal).toBeInTheDocument(); | ||
expect(modal.open).toBe(true); | ||
}); | ||
|
||
test("opens description modal on button click", () => { | ||
renderWithProps(); | ||
fireEvent.click(screen.getByLabelText("three-dots")); | ||
const modal = document.getElementById( | ||
"description-modal", | ||
) as HTMLDialogElement; | ||
expect(modal).toBeInTheDocument(); | ||
expect(modal.open).toBe(true); | ||
}); | ||
}); |
82 changes: 82 additions & 0 deletions
82
components/admins/components/__tests__/stakingParams.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { afterEach, describe, expect, test } from "bun:test"; | ||
import React from "react"; | ||
import { screen, cleanup, within, fireEvent } from "@testing-library/react"; | ||
import StakingParams from "@/components/admins/components/stakingParams"; | ||
import matchers from "@testing-library/jest-dom/matchers"; | ||
import { mockStakingParams } from "@/tests/mock"; | ||
import { renderWithChainProvider } from "@/tests/render"; | ||
|
||
expect.extend(matchers); | ||
|
||
const renderWithProps = (props = {}) => { | ||
const defaultProps = { | ||
stakingParams: mockStakingParams, | ||
isLoading: false, | ||
address: "test_address", | ||
admin: "admin1", | ||
}; | ||
return renderWithChainProvider( | ||
<StakingParams {...defaultProps} {...props} />, | ||
); | ||
}; | ||
|
||
describe("StakingParams", () => { | ||
afterEach(cleanup); | ||
|
||
test("renders correctly when not loading", () => { | ||
renderWithProps(); | ||
const stakingParamsContainer = screen.getByLabelText("Staking Params"); | ||
expect( | ||
within(stakingParamsContainer).getByText("UNBONDING TIME"), | ||
).toBeInTheDocument(); | ||
expect(within(stakingParamsContainer).getByText("1")).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("MAX VALIDATORS"), | ||
).toBeInTheDocument(); | ||
expect(within(stakingParamsContainer).getByText("100")).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("BOND DENOM"), | ||
).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("upoa"), | ||
).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("MINIMUM COMMISSION"), | ||
).toBeInTheDocument(); | ||
expect(within(stakingParamsContainer).getByText("5 %")).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("MAX ENTRIES"), | ||
).toBeInTheDocument(); | ||
expect(within(stakingParamsContainer).getByText("7")).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("HISTORICAL ENTRIES"), | ||
).toBeInTheDocument(); | ||
expect(within(stakingParamsContainer).getByText("200")).toBeInTheDocument(); | ||
}); | ||
|
||
test("renders loading state correctly", () => { | ||
renderWithProps({ isLoading: true }); | ||
const stakingParamsContainer = screen.getByLabelText( | ||
"Skeleton Staking Params", | ||
); | ||
expect( | ||
within(stakingParamsContainer).getByText("Staking Params"), | ||
).toBeInTheDocument(); | ||
expect( | ||
within(stakingParamsContainer).getByText("Update"), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
test("opens update modal on button click", () => { | ||
renderWithProps(); | ||
const stakingParamsContainer = screen.getByLabelText( | ||
"Skeleton Staking Params", | ||
); | ||
fireEvent.click(within(stakingParamsContainer).getByText("Update")); | ||
const modal = document.getElementById( | ||
"update-params-modal", | ||
) as HTMLDialogElement; | ||
expect(modal).toBeInTheDocument(); | ||
expect(modal.open).toBe(true); | ||
}); | ||
}); |
65 changes: 65 additions & 0 deletions
65
components/admins/components/__tests__/validatorList.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { afterEach, describe, expect, test } from "bun:test"; | ||
import React from "react"; | ||
import ValidatorList from "@/components/admins/components/validatorList"; | ||
import { fireEvent, screen, cleanup, waitFor } from "@testing-library/react"; | ||
import matchers from "@testing-library/jest-dom/matchers"; | ||
import { mockActiveValidators, mockPendingValidators } from "@/tests/mock"; | ||
import { renderWithChainProvider } from "@/tests/render"; | ||
|
||
expect.extend(matchers); | ||
|
||
const renderWithProps = (props = {}) => { | ||
const defaultProps = { | ||
admin: "admin1", | ||
activeValidators: mockActiveValidators, | ||
pendingValidators: mockPendingValidators, | ||
isLoading: false, | ||
}; | ||
return renderWithChainProvider( | ||
<ValidatorList {...defaultProps} {...props} />, | ||
); | ||
}; | ||
|
||
describe("ValidatorList", () => { | ||
afterEach(cleanup); | ||
|
||
test("renders correctly", () => { | ||
renderWithProps(); | ||
expect(screen.getByText("Active Validators")).toBeInTheDocument(); | ||
expect(screen.getByText("Validator One")).toBeInTheDocument(); | ||
expect(screen.getByText("Validator Two")).toBeInTheDocument(); | ||
}); | ||
|
||
test("search functionality works", () => { | ||
renderWithProps(); | ||
fireEvent.change(screen.getByPlaceholderText("Search for a validator..."), { | ||
target: { value: "Validator One" }, | ||
}); | ||
expect(screen.getByText("Validator One")).toBeInTheDocument(); | ||
expect(screen.queryByText("Validator Two")).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("active/pending toggle works", () => { | ||
renderWithProps(); | ||
fireEvent.click(screen.getByText("Pending")); | ||
expect(screen.getByText("Pending Validators")).toBeInTheDocument(); | ||
expect(screen.getByText("Validator Three")).toBeInTheDocument(); | ||
}); | ||
|
||
test("clicking on a validator row opens the modal", async () => { | ||
renderWithProps(); | ||
fireEvent.click(screen.getByText("Validator One")); | ||
await waitFor(() => expect(screen.getByRole("dialog")).toBeInTheDocument()); | ||
}); | ||
|
||
test("remove button works and shows the warning modal", async () => { | ||
renderWithProps(); | ||
const allRemoveButtons = screen.getAllByText("Remove"); | ||
fireEvent.click(allRemoveButtons[0]); | ||
await waitFor(() => | ||
expect( | ||
screen.getByText("Are you sure you want to remove the validator"), | ||
).toBeInTheDocument(), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.