Skip to content

Commit

Permalink
Bugfix: Applications my apps tab. (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunomenezes authored Jan 17, 2025
1 parent c6485fb commit 44cbf71
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/web/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const UserApplicationsRow: FC<UserApplicationsRowProps> = (props) => {
showConnectionModal,
removeConnection,
} = useConnectionConfig();
const appId = application.id as AddressType;
const appId = application.address as AddressType;
const connection = getConnection(appId);
return (
<Table.Tr key={application.id}>
Expand Down
30 changes: 19 additions & 11 deletions apps/web/test/components/applications/userApplicationRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import prettyMilliseconds from "pretty-ms";
import type { FC } from "react";
import { afterEach, beforeEach, describe, it } from "vitest";
import { ApplicationRowProps } from "../../../src/components/applications/applicationRow";
import UserApplicationsRow, {
UserApplicationsRowProps,
} from "../../../src/components/applications/userApplicationsRow";
Expand All @@ -24,12 +23,20 @@ const Component = withMantineTheme(TableComponent);

const defaultProps: UserApplicationsRowProps = {
application: {
id: "0x028367fe226cd9e5699f4288d512fe3a4a4a0012",
id: "11155111-0x028367fe226cd9e5699f4288d512fe3a4a4a0012",
owner: "0x74d093f6911ac080897c3145441103dabb869307",
timestamp: 1700593992,
address: "0x028367fe226cd9e5699f4288d512fe3a4a4a0012",
chain: {
id: "11155111",
},
factory: {
id: "0x7122cd1221c20892234186facfe8615e6743ab02",
id: "11155111-0x7122cd1221c20892234186facfe8615e6743ab02",
applications: [],
address: "0x7122cd1221c20892234186facfe8615e6743ab02",
chain: {
id: "11155111",
},
},
},
keepDataColVisible: false,
Expand All @@ -51,6 +58,7 @@ describe("UserApplicationRow component", () => {
hideConnectionModal: vi.fn(),
showConnectionModal: vi.fn(),
listConnections: vi.fn(),
fetching: false,
});
});

Expand All @@ -59,10 +67,10 @@ describe("UserApplicationRow component", () => {
cleanup();
});

it("should display shortened application id", () => {
it("should display shortened application address", () => {
render(<Component {...defaultProps} />);
const { application } = defaultProps;
const appId = application.id;
const appId = application.address;
const shortenedId = `${appId.slice(0, 8)}...${appId.slice(-6)}`;

expect(screen.getByText(shortenedId)).toBeInTheDocument();
Expand Down Expand Up @@ -114,7 +122,7 @@ describe("UserApplicationRow component", () => {

expect(link).toBeInTheDocument();
expect(link.getAttribute("href")).toBe(
`/applications/${defaultProps.application.id}`,
`/applications/${defaultProps.application.address}`,
);
});

Expand All @@ -124,7 +132,7 @@ describe("UserApplicationRow component", () => {

expect(link).toBeInTheDocument();
expect(link.getAttribute("href")).toBe(
`/applications/${defaultProps.application.id}/inputs`,
`/applications/${defaultProps.application.address}/inputs`,
);
});

Expand All @@ -133,7 +141,7 @@ describe("UserApplicationRow component", () => {
expect(screen.getByTestId("add-connection")).toBeInTheDocument();
});

it("should invoke showConnectionModal with application id, when add-connection button is clicked", () => {
it("should invoke showConnectionModal with application address, when add-connection button is clicked", () => {
const showConnectionModalMock = vi.fn();
useConnectionConfigMock.mockReturnValue({
...useConnectionConfigMock(),
Expand All @@ -147,7 +155,7 @@ describe("UserApplicationRow component", () => {
fireEvent.click(addConnectionButton);

expect(showConnectionModalMock).toHaveBeenCalledWith(
defaultProps.application.id,
defaultProps.application.address,
);
});

Expand All @@ -160,7 +168,7 @@ describe("UserApplicationRow component", () => {
expect(screen.getByTestId("remove-connection")).toBeInTheDocument();
});

it("should invoke removeConnection with application id, when remove-connection button is clicked", () => {
it("should invoke removeConnection with application address, when remove-connection button is clicked", () => {
const removeConnectionMock = vi.fn();
useConnectionConfigMock.mockReturnValue({
...useConnectionConfigMock(),
Expand All @@ -175,7 +183,7 @@ describe("UserApplicationRow component", () => {
fireEvent.click(addConnectionButton);

expect(removeConnectionMock).toHaveBeenCalledWith(
defaultProps.application.id,
defaultProps.application.address,
);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"format:check": "prettier \"**/*.{ts,tsx}\" --check",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"test": "turbo run test",
"test:ci": "turbo run test:ci",
"test:ci": "turbo run test:ci --filter=!workshop",
"test:e2e": "turbo run test:e2e",
"changeset": "changeset",
"version-packages": "changeset version",
Expand Down

0 comments on commit 44cbf71

Please sign in to comment.