-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NNS1-3349 add neuron visibility action (#5516)
# Motivation Displaying visibility of Neuron under NnsNeuronAdvancedSection so clients can see the visibility of their neruons and eventually adjust them as needed. # Changes 1. Add NnsNeuronPublicVisibilityAction to display visibility and button, currently disabled. 2. Add ENABLE_NEURON_VISIBILITY flag check around NnsNeuronPublicVisibilityAction 3. Update NnsNeuronAdvancedSection , CommonItemAction and NnsNeuronAge styling to match with Figma # Tests Add tests for NnsNeuronPublicVisibilityAction Add fullpage screenshot for neuron details modal # Todos - [ ] Add entry to changelog (if necessary). --------- Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org> Co-authored-by: “Cosku <“cosku.cinkilic@dfinity.org”> Co-authored-by: sa-github-api <138766536+sa-github-api@users.noreply.github.com> Co-authored-by: gix-bot <gix-bot@users.noreply.github.com> Co-authored-by: David de Kloet <122978264+dskloetd@users.noreply.github.com> Co-authored-by: David Dal Busco <david.dalbusco@dfinity.org> Co-authored-by: Max Strasinsky <98811342+mstrasinskis@users.noreply.github.com>
- Loading branch information
1 parent
009d8af
commit bf677a9
Showing
14 changed files
with
244 additions
and
7 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
60 changes: 60 additions & 0 deletions
60
frontend/src/lib/components/neuron-detail/NnsNeuronPublicVisibilityAction.svelte
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,60 @@ | ||
<script lang="ts"> | ||
import { i18n } from "$lib/stores/i18n"; | ||
import { isPublicNeuron } from "$lib/utils/neuron.utils"; | ||
import CommonItemAction from "../ui/CommonItemAction.svelte"; | ||
import { IconPublicBadge } from "@dfinity/gix-components"; | ||
import type { NeuronInfo } from "@dfinity/nns"; | ||
export let neuron: NeuronInfo; | ||
let isPublic: boolean; | ||
$: isPublic = isPublicNeuron(neuron); | ||
</script> | ||
|
||
<CommonItemAction testId="nns-neuron-public-visibility-action-component"> | ||
<div slot="icon" class={`public-badge-container ${!isPublic && "private"}`}> | ||
<IconPublicBadge /> | ||
</div> | ||
|
||
<span slot="title" data-tid="neuron-visibility-title"> | ||
{isPublic | ||
? $i18n.neurons.public_neuron | ||
: $i18n.neurons.private_neuron}</span | ||
> | ||
<svelte:fragment slot="subtitle"> | ||
<span class="description" data-tid="neuron-visibility-description"> | ||
{isPublic | ||
? $i18n.neurons.public_neuron_description | ||
: $i18n.neurons.private_neuron_description} | ||
<a | ||
data-tid="neuron-visibility-learn-more" | ||
href="https://internetcomputer.org/docs/current/developer-docs/daos/nns/concepts/neurons/neuron-management" | ||
target="_blank">{$i18n.neurons.learn_more}</a | ||
> | ||
</span> | ||
</svelte:fragment> | ||
|
||
<button class="secondary" data-tid="change-neuron-visibility-button" disabled | ||
>{isPublic | ||
? $i18n.neurons.make_neuron_private | ||
: $i18n.neurons.make_neuron_public}</button | ||
> | ||
</CommonItemAction> | ||
|
||
<style lang="scss"> | ||
.public-badge-container { | ||
line-height: 0; | ||
color: var(--elements-badges); | ||
} | ||
.private { | ||
color: var(--elements-badges-inactive); | ||
} | ||
a { | ||
color: var(--link-color); | ||
} | ||
button { | ||
text-wrap: nowrap; | ||
} | ||
</style> |
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
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
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
Binary file modified
BIN
+8.58 KB
(110%)
...rc/tests/e2e/screenshots/neuron-details.spec.ts-desktop-Google-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+14.1 KB
(110%)
...tend/src/tests/e2e/screenshots/neuron-details.spec.ts-desktop-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10 KB
(110%)
...src/tests/e2e/screenshots/neuron-details.spec.ts-mobile-Google-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+13.8 KB
(110%)
frontend/src/tests/e2e/screenshots/neuron-details.spec.ts-mobile-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions
94
frontend/src/tests/lib/components/neuron-detail/NnsNeuronPublicVisibilityAction.spec.ts
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,94 @@ | ||
import NnsNeuronPublicVisibilityAction from "$lib/components/neuron-detail/NnsNeuronPublicVisibilityAction.svelte"; | ||
import { mockNeuron } from "$tests/mocks/neurons.mock"; | ||
import { NnsNeuronPublicVisibilityActionPo } from "$tests/page-objects/NnsNeuronPublicVisibilityAction.page-object"; | ||
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object"; | ||
import { NeuronVisibility, type NeuronInfo } from "@dfinity/nns"; | ||
import { render } from "@testing-library/svelte"; | ||
|
||
describe("NnsNeuronPublicVisibilityAction", () => { | ||
const renderComponent = async (neuron) => { | ||
const { container } = render(NnsNeuronPublicVisibilityAction, { | ||
props: { neuron }, | ||
}); | ||
return NnsNeuronPublicVisibilityActionPo.under( | ||
new JestPageObjectElement(container) | ||
); | ||
}; | ||
|
||
it("should render elements and text for public neuron", async () => { | ||
const mockNeuronPublic: NeuronInfo = { | ||
...mockNeuron, | ||
visibility: NeuronVisibility.Public, | ||
}; | ||
const po = await renderComponent(mockNeuronPublic); | ||
|
||
expect(await po.getTitleText()).toBe("Public Neuron"); | ||
expect(await po.getSubtitleText()).toBe( | ||
"This neuron exposes additional information, including its votes. Learn more." | ||
); | ||
expect(await po.getSubtitleLinkPo().getText()).toBe("Learn more."); | ||
expect(await po.getSubtitleLinkPo().getHref()).toBe( | ||
"https://internetcomputer.org/docs/current/developer-docs/daos/nns/concepts/neurons/neuron-management" | ||
); | ||
expect(await po.getButtonPo().getText()).toBe("Make Neuron Private"); | ||
expect(await po.getButtonPo().isDisabled()).toBe(true); | ||
}); | ||
|
||
it("should render elements and text for private neuron", async () => { | ||
const mockNeuronPrivate: NeuronInfo = { | ||
...mockNeuron, | ||
visibility: NeuronVisibility.Private, | ||
}; | ||
const po = await renderComponent(mockNeuronPrivate); | ||
|
||
expect(await po.getTitleText()).toBe("Private Neuron"); | ||
expect(await po.getSubtitleText()).toBe( | ||
"This neuron limits information it exposes publicly. Learn more." | ||
); | ||
expect(await po.getSubtitleLinkPo().getText()).toBe("Learn more."); | ||
expect(await po.getSubtitleLinkPo().getHref()).toBe( | ||
"https://internetcomputer.org/docs/current/developer-docs/daos/nns/concepts/neurons/neuron-management" | ||
); | ||
expect(await po.getButtonPo().getText()).toBe("Make Neuron Public"); | ||
expect(await po.getButtonPo().isDisabled()).toBe(true); | ||
}); | ||
|
||
it("should render elements and text for unspecified neuron", async () => { | ||
const mockNeuronUnspecified: NeuronInfo = { | ||
...mockNeuron, | ||
visibility: NeuronVisibility.Unspecified, | ||
}; | ||
const po = await renderComponent(mockNeuronUnspecified); | ||
|
||
expect(await po.getTitleText()).toBe("Private Neuron"); | ||
expect(await po.getSubtitleText()).toBe( | ||
"This neuron limits information it exposes publicly. Learn more." | ||
); | ||
|
||
expect(await po.getSubtitleLinkPo().getText()).toBe("Learn more."); | ||
expect(await po.getSubtitleLinkPo().getHref()).toBe( | ||
"https://internetcomputer.org/docs/current/developer-docs/daos/nns/concepts/neurons/neuron-management" | ||
); | ||
expect(await po.getButtonPo().getText()).toBe("Make Neuron Public"); | ||
expect(await po.getButtonPo().isDisabled()).toBe(true); | ||
}); | ||
|
||
it("should render elements and text for neuron with no visibility", async () => { | ||
const mockNeuronVisibilityUndefined: NeuronInfo = { | ||
...mockNeuron, | ||
visibility: undefined, | ||
}; | ||
const po = await renderComponent(mockNeuronVisibilityUndefined); | ||
|
||
expect(await po.getTitleText()).toBe("Private Neuron"); | ||
expect(await po.getSubtitleText()).toBe( | ||
"This neuron limits information it exposes publicly. Learn more." | ||
); | ||
expect(await po.getSubtitleLinkPo().getText()).toBe("Learn more."); | ||
expect(await po.getSubtitleLinkPo().getHref()).toBe( | ||
"https://internetcomputer.org/docs/current/developer-docs/daos/nns/concepts/neurons/neuron-management" | ||
); | ||
expect(await po.getButtonPo().getText()).toBe("Make Neuron Public"); | ||
expect(await po.getButtonPo().isDisabled()).toBe(true); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
frontend/src/tests/page-objects/NnsNeuronPublicVisibilityAction.page-object.ts
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,38 @@ | ||
import { TooltipIconPo } from "$tests/page-objects/TooltipIcon.page-object"; | ||
import { BasePageObject } from "$tests/page-objects/base.page-object"; | ||
import type { PageObjectElement } from "$tests/types/page-object.types"; | ||
import { ButtonPo } from "./Button.page-object"; | ||
import { LinkPo } from "./Link.page-object"; | ||
|
||
export class NnsNeuronPublicVisibilityActionPo extends BasePageObject { | ||
private static readonly TID = "nns-neuron-public-visibility-action-component"; | ||
|
||
static under(element: PageObjectElement): NnsNeuronPublicVisibilityActionPo { | ||
return new NnsNeuronPublicVisibilityActionPo( | ||
element.byTestId("nns-neuron-public-visibility-action-component") | ||
); | ||
} | ||
|
||
getTooltipIconPo(): TooltipIconPo { | ||
return TooltipIconPo.under(this.root); | ||
} | ||
|
||
getTitleText(): Promise<string> { | ||
return this.getText("neuron-visibility-title"); | ||
} | ||
|
||
getSubtitleText(): Promise<string> { | ||
return this.getText("neuron-visibility-description"); | ||
} | ||
|
||
getSubtitleLinkPo(): LinkPo { | ||
return LinkPo.under({ | ||
element: this.root, | ||
testId: "neuron-visibility-learn-more", | ||
}); | ||
} | ||
|
||
getButtonPo(): ButtonPo { | ||
return this.getButton("change-neuron-visibility-button"); | ||
} | ||
} |