-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Snses without actionables banner (#4902)
# Motivation Because not all projects support actionable proposals (return neuron ballots), not all actionable proposals will be shown on the actionable proposals page. To make it clear that there could be more votable proposals, we display a banner with a list of projects that do not have actionable support. In this PR, we create a banner component that will be shown on the actionable proposals page. # Changes - Add new component `ActionableProposalsNotSupportedSnses` # Tests - PO for `ActionableProposalsNotSupportedSnses` - Tests for `ActionableProposalsNotSupportedSnses` # Todos - [ ] Add entry to changelog (if necessary). not yet. # Screenshot <img width="1325" alt="image" src="https://github.com/dfinity/nns-dapp/assets/98811342/ab1fbcf6-0f6e-4a8f-ac69-cb79fe990808">
- Loading branch information
1 parent
37633d0
commit b4daed2
Showing
7 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
frontend/src/lib/components/proposals/ActionableProposalsNotSupportedSnses.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,31 @@ | ||
<script lang="ts"> | ||
import { i18n } from "$lib/stores/i18n"; | ||
import { PageBanner, IconNotificationPage } from "@dfinity/gix-components"; | ||
import { replacePlaceholders } from "$lib/utils/i18n.utils.js"; | ||
import { actionableProposalNotSupportedUniversesStore } from "$lib/derived/actionable-proposals.derived"; | ||
import TestIdWrapper from "$lib/components/common/TestIdWrapper.svelte"; | ||
let snsNames: string; | ||
$: snsNames = $actionableProposalNotSupportedUniversesStore | ||
.map((universe) => universe.title) | ||
.join(", "); | ||
</script> | ||
|
||
<TestIdWrapper testId="actionable-proposals-not-supported-snses-component"> | ||
{#if snsNames !== ""} | ||
<PageBanner testId="actionable-proposals-not-supported-snses-banner"> | ||
<IconNotificationPage slot="image" /> | ||
<svelte:fragment slot="title" | ||
>{replacePlaceholders( | ||
$i18n.actionable_proposals_not_supported_snses.title, | ||
{ | ||
$snsNames: snsNames, | ||
} | ||
)}</svelte:fragment | ||
> | ||
<p class="description" slot="description"> | ||
{$i18n.actionable_proposals_not_supported_snses.text} | ||
</p> | ||
</PageBanner> | ||
{/if} | ||
</TestIdWrapper> |
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
75 changes: 75 additions & 0 deletions
75
frontend/src/tests/lib/components/proposals/ActionableProposalsNotSupportedSnses.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,75 @@ | ||
import ActionableProposalsNotSupportedSnses from "$lib/components/proposals/ActionableProposalsNotSupportedSnses.svelte"; | ||
import { actionableSnsProposalsStore } from "$lib/stores/actionable-sns-proposals.store"; | ||
import { principal } from "$tests/mocks/sns-projects.mock"; | ||
import { ActionableProposalsNotSupportedSnsesPo } from "$tests/page-objects/ActionableProposalsNotSupportedSnses.page-object"; | ||
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object"; | ||
import { resetSnsProjects, setSnsProjects } from "$tests/utils/sns.test-utils"; | ||
import { render } from "$tests/utils/svelte.test-utils"; | ||
import { SnsSwapLifecycle } from "@dfinity/sns"; | ||
|
||
describe("ActionableProposalsNotSupportedSnses", () => { | ||
const addSnsesWithSupport = (includeBallotsByCallerList: boolean[]) => { | ||
const snsProjects = Array.from( | ||
new Array(includeBallotsByCallerList.length) | ||
).map((_, i) => ({ | ||
lifecycle: SnsSwapLifecycle.Committed, | ||
rootCanisterId: principal(i), | ||
projectName: `SNS-${i}`, | ||
})); | ||
setSnsProjects(snsProjects); | ||
|
||
Array.from(new Array(includeBallotsByCallerList.length)).forEach((_, i) => | ||
actionableSnsProposalsStore.set({ | ||
rootCanisterId: principal(i), | ||
proposals: [], | ||
includeBallotsByCaller: includeBallotsByCallerList[i], | ||
}) | ||
); | ||
}; | ||
|
||
const renderComponent = () => { | ||
const { container } = render(ActionableProposalsNotSupportedSnses); | ||
|
||
return ActionableProposalsNotSupportedSnsesPo.under( | ||
new JestPageObjectElement(container) | ||
); | ||
}; | ||
|
||
beforeEach(() => { | ||
resetSnsProjects(); | ||
actionableSnsProposalsStore.resetForTesting(); | ||
}); | ||
|
||
it("should render a banner when there are Snses w/o actionable support", async () => { | ||
addSnsesWithSupport([false]); | ||
const po = renderComponent(); | ||
expect(await po.getBannerPo().isPresent()).toEqual(true); | ||
}); | ||
|
||
it("should not render the banner when all Snses supports actionable proposals", async () => { | ||
addSnsesWithSupport([true]); | ||
const po = renderComponent(); | ||
expect(await po.getBannerPo().isPresent()).toEqual(false); | ||
}); | ||
|
||
it("should not render the banne when there are no Snses", async () => { | ||
const po = renderComponent(); | ||
expect(await po.getBannerPo().isPresent()).toEqual(false); | ||
}); | ||
|
||
it("should display title", async () => { | ||
addSnsesWithSupport([true, false, true, false, true]); | ||
const po = renderComponent(); | ||
expect(await po.getBannerPo().getTitleText()).toEqual( | ||
"SNS-1, SNS-3 don’t yet support actionable proposals." | ||
); | ||
}); | ||
|
||
it("should display description", async () => { | ||
addSnsesWithSupport([false]); | ||
const po = renderComponent(); | ||
expect(await po.getBannerPo().getDescriptionText()).toEqual( | ||
"If an SNS DAO wishes to support actionable proposals, need to upgrade to a newer version of the SNS governance canister." | ||
); | ||
}); | ||
}); |
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
23 changes: 23 additions & 0 deletions
23
frontend/src/tests/page-objects/ActionableProposalsNotSupportedSnses.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,23 @@ | ||
import { PageBannerPo } from "$tests/page-objects/PageBanner.page-object"; | ||
import { BasePageObject } from "$tests/page-objects/base.page-object"; | ||
import type { PageObjectElement } from "$tests/types/page-object.types"; | ||
|
||
export class ActionableProposalsNotSupportedSnsesPo extends BasePageObject { | ||
private static readonly TID = | ||
"actionable-proposals-not-supported-snses-component"; | ||
|
||
static under( | ||
element: PageObjectElement | ||
): ActionableProposalsNotSupportedSnsesPo { | ||
return new ActionableProposalsNotSupportedSnsesPo( | ||
element.byTestId(ActionableProposalsNotSupportedSnsesPo.TID) | ||
); | ||
} | ||
|
||
getBannerPo(): PageBannerPo { | ||
return PageBannerPo.under({ | ||
element: this.root, | ||
testId: "actionable-proposals-not-supported-snses-banner", | ||
}); | ||
} | ||
} |