Skip to content

Commit

Permalink
NNS1-3094: Make projects without neurons clickable again (#5216)
Browse files Browse the repository at this point in the history
# Motivation

In #5202 I made projects without
neurons not clickable.
But this makes it not possible to stake those tokens.
We are still working on a way to stake tokens from the projects table
but this doesn't need to be part of the MVP.
So we want to make all projects clickable again for now.

# Changes

Give every `TableProject` a `rowHref` regardless of neurons.

# Tests

1. As we may go back again on this once there is a way to stake from the
projects table, I kept the structure of the tests the same but just
changed the expectations.
2. Tested manually at
https://qsgjb-riaaa-aaaaa-aaaga-cai.dskloet-ingress.devenv.dfinity.network/staking/

# Todos

- [ ] Add entry to changelog (if necessary).
not necessary
  • Loading branch information
dskloetd authored Jul 18, 2024
1 parent 6a38154 commit b2e9b40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
5 changes: 1 addition & 4 deletions frontend/src/lib/utils/staking.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ export const getTableProjects = ({
nnsNeurons,
snsNeurons,
});
const rowHref =
(neuronCount ?? 0) > 0
? buildNeuronsUrl({ universe: universe.canisterId })
: undefined;
const rowHref = buildNeuronsUrl({ universe: universe.canisterId });
return {
rowHref,
domKey: universe.canisterId,
Expand Down
30 changes: 18 additions & 12 deletions frontend/src/tests/lib/components/staking/ProjectsTable.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,27 @@ describe("ProjectsTable", () => {
const rowPos = await po.getProjectsTableRowPos();
expect(rowPos).toHaveLength(2);
expect(await rowPos[0].getNeuronCount()).toBe("-/-");
expect(await rowPos[0].getHref()).toBe(null);
expect(await rowPos[0].hasGoToNeuronsTableAction()).toBe(false);
expect(await rowPos[0].getHref()).toBe(
`/neurons/?u=${OWN_CANISTER_ID_TEXT}`
);
expect(await rowPos[0].hasGoToNeuronsTableAction()).toBe(true);
expect(await rowPos[1].getNeuronCount()).toBe("-/-");
expect(await rowPos[1].getHref()).toBe(null);
expect(await rowPos[1].hasGoToNeuronsTableAction()).toBe(false);
expect(await rowPos[1].getHref()).toBe(`/neurons/?u=${snsCanisterId}`);
expect(await rowPos[1].hasGoToNeuronsTableAction()).toBe(true);
});

it("should not render SNS neurons count when not loaded", async () => {
const po = renderComponent();
const rowPos = await po.getProjectsTableRowPos();
expect(rowPos).toHaveLength(2);
expect(await rowPos[0].getNeuronCount()).toBe("-/-");
expect(await rowPos[0].getHref()).toBe(null);
expect(await rowPos[0].hasGoToNeuronsTableAction()).toBe(false);
expect(await rowPos[0].getHref()).toBe(
`/neurons/?u=${OWN_CANISTER_ID_TEXT}`
);
expect(await rowPos[0].hasGoToNeuronsTableAction()).toBe(true);
expect(await rowPos[1].getNeuronCount()).toBe("-/-");
expect(await rowPos[0].getHref()).toBe(null);
expect(await rowPos[1].hasGoToNeuronsTableAction()).toBe(false);
expect(await rowPos[1].getHref()).toBe(`/neurons/?u=${snsCanisterId}`);
expect(await rowPos[1].hasGoToNeuronsTableAction()).toBe(true);
});

it("should not render clickable row with zero neurons", async () => {
Expand All @@ -219,11 +223,13 @@ describe("ProjectsTable", () => {
const rowPos = await po.getProjectsTableRowPos();
expect(rowPos).toHaveLength(2);
expect(await rowPos[0].getNeuronCount()).toBe("0");
expect(await rowPos[0].getHref()).toBe(null);
expect(await rowPos[0].hasGoToNeuronsTableAction()).toBe(false);
expect(await rowPos[0].getHref()).toBe(
`/neurons/?u=${OWN_CANISTER_ID_TEXT}`
);
expect(await rowPos[0].hasGoToNeuronsTableAction()).toBe(true);
expect(await rowPos[1].getNeuronCount()).toBe("0");
expect(await rowPos[1].getHref()).toBe(null);
expect(await rowPos[1].hasGoToNeuronsTableAction()).toBe(false);
expect(await rowPos[1].getHref()).toBe(`/neurons/?u=${snsCanisterId}`);
expect(await rowPos[1].hasGoToNeuronsTableAction()).toBe(true);
});
});

Expand Down
8 changes: 2 additions & 6 deletions frontend/src/tests/lib/utils/staking.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("staking.utils", () => {
const snsHref = `/neurons/?u=${universeId2}`;

const defaultExpectedNnsTableProject = {
rowHref: undefined,
rowHref: nnsHref,
domKey: OWN_CANISTER_ID_TEXT,
title: "Internet Computer",
logo: IC_LOGO_ROUNDED,
Expand All @@ -46,7 +46,7 @@ describe("staking.utils", () => {
};

const defaultExpectedSnsTableProject = {
rowHref: undefined,
rowHref: snsHref,
domKey: universeId2,
title: "title2",
logo: "logo2",
Expand Down Expand Up @@ -223,13 +223,11 @@ describe("staking.utils", () => {
expect(tableProjects).toEqual([
{
...defaultExpectedNnsTableProject,
rowHref: undefined,
neuronCount: undefined,
stake: undefined,
},
{
...defaultExpectedSnsTableProject,
rowHref: undefined,
neuronCount: undefined,
stake: undefined,
},
Expand All @@ -249,13 +247,11 @@ describe("staking.utils", () => {
expect(tableProjects).toEqual([
{
...defaultExpectedNnsTableProject,
rowHref: undefined,
neuronCount: undefined,
stake: undefined,
},
{
...defaultExpectedSnsTableProject,
rowHref: undefined,
neuronCount: undefined,
stake: undefined,
},
Expand Down

0 comments on commit b2e9b40

Please sign in to comment.