Skip to content

Commit

Permalink
Rename UniversePageSummary to UniverseSummary (#5368)
Browse files Browse the repository at this point in the history
# Motivation

Since `UniversePageSummary` is generic enough and is used in more than
just the page header components, it makes more sense to rename it to
`UniverseSummary`.

# Changes

- Rename `UniversePageSummary` to `UniverseSummary`.

# Tests

- Pass.

# Todos

- [ ] Add entry to changelog (if necessary).
Not necessary.
  • Loading branch information
mstrasinskis authored Aug 28, 2024
1 parent 7853036 commit e91d793
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { i18n } from "$lib/stores/i18n";
import UniversePageSummary from "$lib/components/universe/UniversePageSummary.svelte";
import UniverseSummary from "$lib/components/universe/UniverseSummary.svelte";
import type { Universe } from "$lib/types/universe";
import { nonNullish } from "@dfinity/utils";
import ConfirmationModal from "$lib/modals/common/ConfirmationModal.svelte";
Expand All @@ -15,7 +15,7 @@
<div class="content">
<h4>{$i18n.import_token.remove_confirmation_header}</h4>
<div class="token">
{#if nonNullish(universe)}<UniversePageSummary {universe} />{/if}
{#if nonNullish(universe)}<UniverseSummary {universe} />{/if}
<Tag>{$i18n.import_token.imported_token}</Tag>
</div>
<p class="description text_small">
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/lib/components/accounts/WalletPageHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { Universe } from "$lib/types/universe";
import PageHeader from "../common/PageHeader.svelte";
import IdentifierHash from "../ui/IdentifierHash.svelte";
import UniversePageSummary from "../universe/UniversePageSummary.svelte";
import UniverseSummary from "../universe/UniverseSummary.svelte";
import { nonNullish } from "@dfinity/utils";
export let universe: Universe;
Expand All @@ -11,7 +11,7 @@

<PageHeader testId="wallet-page-header-component">
<div slot="start" class="header-start">
<UniversePageSummary {universe} />
<UniverseSummary {universe} />
<slot name="actions" />
</div>
<span
Expand All @@ -33,7 +33,7 @@
.header-end {
// The IdentifierHash has the copy button at the end which has some extra padding.
// This is needed to align in the center the UniversePageSummary and the IdentifierHash in mobile view.
// This is needed to align in the center the UniverseSummary and the IdentifierHash in mobile view.
padding-left: var(--padding-1_5x);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import { nnsUniverseStore } from "$lib/derived/nns-universe.derived";
import PageHeader from "../common/PageHeader.svelte";
import IdentifierHash from "../ui/IdentifierHash.svelte";
import UniversePageSummary from "../universe/UniversePageSummary.svelte";
import UniverseSummary from "../universe/UniverseSummary.svelte";
export let canister: CanisterInfo;
</script>

<PageHeader testId="canister-page-header-component">
<UniversePageSummary slot="start" universe={$nnsUniverseStore} />
<UniverseSummary slot="start" universe={$nnsUniverseStore} />
<div slot="end" class="description header-end" data-tid="canister-id-element">
<IdentifierHash identifier={canister.canister_id.toText()} />
</div>
Expand All @@ -18,7 +18,7 @@
<style lang="scss">
.header-end {
// The IdentifierHash has the copy button at the end which has some extra padding.
// This is needed to align in the center the UniversePageSummary and the IdentifierHash in mobile view.
// This is needed to align in the center the UniverseSummary and the IdentifierHash in mobile view.
padding-left: var(--padding-1_5x);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import type { IntersectingDetail } from "$lib/types/intersection.types";
import PageHeader from "../common/PageHeader.svelte";
import IdentifierHash from "../ui/IdentifierHash.svelte";
import UniversePageSummary from "../universe/UniversePageSummary.svelte";
import UniverseSummary from "../universe/UniverseSummary.svelte";
import type { NeuronInfo } from "@dfinity/nns";
export let neuron: NeuronInfo;
Expand All @@ -27,7 +27,7 @@
</script>

<PageHeader testId="nns-neuron-page-header-component">
<UniversePageSummary slot="start" universe={$nnsUniverseStore} />
<UniverseSummary slot="start" universe={$nnsUniverseStore} />
<span
slot="end"
class="description header-end"
Expand All @@ -45,7 +45,7 @@
<style lang="scss">
.header-end {
// The IdentifierHash has the copy button at the end which has some extra padding.
// This is needed to align in the center the UniversePageSummary and the IdentifierHash in mobile view.
// This is needed to align in the center the UniverseSummary and the IdentifierHash in mobile view.
padding-left: var(--padding-1_5x);
}
</style>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import UniversePageSummary from "$lib/components/universe/UniversePageSummary.svelte";
import UniverseSummary from "$lib/components/universe/UniverseSummary.svelte";
import type { Universe } from "$lib/types/universe";
import { InfiniteScroll } from "@dfinity/gix-components";
Expand All @@ -8,7 +8,7 @@

<div class="container" data-tid="universe-with-actionable-proposals-component">
<div class="title">
<UniversePageSummary {universe} />
<UniverseSummary {universe} />
</div>

<InfiniteScroll layout="grid" disabled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { getSnsNeuronIdAsHexString } from "$lib/utils/sns-neuron.utils";
import PageHeader from "../common/PageHeader.svelte";
import IdentifierHash from "../ui/IdentifierHash.svelte";
import UniversePageSummary from "../universe/UniversePageSummary.svelte";
import UniverseSummary from "../universe/UniverseSummary.svelte";
import type { SnsNeuron } from "@dfinity/sns";
import { isNullish, nonNullish, type Token } from "@dfinity/utils";
import { getContext } from "svelte";
Expand Down Expand Up @@ -45,7 +45,7 @@
</script>

<PageHeader testId="sns-neuron-page-header-component">
<UniversePageSummary slot="start" universe={$selectedUniverseStore} />
<UniverseSummary slot="start" universe={$selectedUniverseStore} />
<span
slot="end"
class="description header-end"
Expand All @@ -62,7 +62,7 @@
<style lang="scss">
.header-end {
// The IdentifierHash has the copy button at the end which has some extra padding.
// This is needed to align in the center the UniversePageSummary and the IdentifierHash in mobile view.
// This is needed to align in the center the UniverseSummary and the IdentifierHash in mobile view.
padding-left: var(--padding-1_5x);
}
</style>
4 changes: 2 additions & 2 deletions frontend/src/lib/components/summary/Summary.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import UniversePageSummary from "$lib/components/universe/UniversePageSummary.svelte";
import UniverseSummary from "$lib/components/universe/UniverseSummary.svelte";
import { selectedUniverseStore } from "$lib/derived/selected-universe.derived";
</script>

<h1 class="summary" data-tid="projects-summary">
<UniversePageSummary universe={$selectedUniverseStore} />
<UniverseSummary universe={$selectedUniverseStore} />
</h1>

<style lang="scss">
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/pages/Canisters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Footer from "$lib/components/layout/Footer.svelte";
import PrincipalText from "$lib/components/summary/PrincipalText.svelte";
import SkeletonCard from "$lib/components/ui/SkeletonCard.svelte";
import UniversePageSummary from "$lib/components/universe/UniversePageSummary.svelte";
import UniverseSummary from "$lib/components/universe/UniverseSummary.svelte";
import { AppPath } from "$lib/constants/routes.constants";
import { nnsUniverseStore } from "$lib/derived/nns-universe.derived";
import { pageStore } from "$lib/derived/page.derived";
Expand Down Expand Up @@ -70,7 +70,7 @@
<main>
<div class="summary" data-tid="projects-summary">
<h1 class="summary-title">
<UniversePageSummary universe={$nnsUniverseStore} />
<UniverseSummary universe={$nnsUniverseStore} />
</h1>
<div class="summary-details">
<PrincipalText inline />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ describe("ImportTokenRemoveConfirmation", () => {

it("should render token logo", async () => {
const po = renderComponent();
expect(await po.getUniversePageSummaryPo().getLogoUrl()).toEqual(tokenLogo);
expect(await po.getUniverseSummaryPo().getLogoUrl()).toEqual(tokenLogo);
});

it("should render token name", async () => {
const po = renderComponent();
expect(await po.getUniversePageSummaryPo().getTitle()).toEqual(tokenName);
expect(await po.getUniverseSummaryPo().getTitle()).toEqual(tokenName);
});
});
4 changes: 2 additions & 2 deletions frontend/src/tests/lib/components/summary/Summary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppPath } from "$lib/constants/routes.constants";
import { page } from "$mocks/$app/stores";
import { mockSnsFullProject } from "$tests/mocks/sns-projects.mock";
import { nnsUniverseMock } from "$tests/mocks/universe.mock";
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object";
import { resetSnsProjects, setSnsProjects } from "$tests/utils/sns.test-utils";
import { SnsSwapLifecycle } from "@dfinity/sns";
Expand All @@ -14,7 +14,7 @@ import { render } from "@testing-library/svelte";
describe("Summary", () => {
const renderComponent = () => {
const { container } = render(Summary);
return UniversePageSummaryPo.under(new JestPageObjectElement(container));
return UniverseSummaryPo.under(new JestPageObjectElement(container));
};

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import UniversePageSummary from "$lib/components/universe/UniversePageSummary.svelte";
import UniverseSummary from "$lib/components/universe/UniverseSummary.svelte";
import { createUniverse } from "$lib/utils/universe.utils";
import { mockSummary } from "$tests/mocks/sns-projects.mock";
import {
ckBTCUniverseMock,
ckTESTBTCUniverseMock,
nnsUniverseMock,
} from "$tests/mocks/universe.mock";
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object";
import { render } from "@testing-library/svelte";

describe("UniversePageSummary", () => {
describe("UniverseSummary", () => {
const renderComponent = (universe) => {
const { container } = render(UniversePageSummary, {
const { container } = render(UniverseSummary, {
props: { universe },
});

return UniversePageSummaryPo.under(new JestPageObjectElement(container));
return UniverseSummaryPo.under(new JestPageObjectElement(container));
};

it("shout render IC", async () => {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/tests/lib/pages/Canisters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { mockCanistersStoreSubscribe } from "$tests/mocks/canisters.mock";
import en from "$tests/mocks/i18n.mock";
import { nnsUniverseMock } from "$tests/mocks/universe.mock";
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object";
import { fireEvent } from "@testing-library/dom";
import { render, waitFor } from "@testing-library/svelte";
Expand Down Expand Up @@ -57,9 +57,7 @@ describe("Canisters", () => {

it("should render the IC summary", async () => {
const { container } = render(Canisters);
const po = UniversePageSummaryPo.under(
new JestPageObjectElement(container)
);
const po = UniverseSummaryPo.under(new JestPageObjectElement(container));

expect(await po.getLogoUrl()).toBe(nnsUniverseMock.logo);
expect(await po.getTitle()).toBe(nnsUniverseMock.title);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tests/lib/pages/SnsWallet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@ describe("SnsWallet", () => {
// we want to make sure that SNSes have the ability to change the logo in
// their ledger canister metadata.
expect(
await po.getWalletPageHeaderPo().getUniversePageSummaryPo().getLogoUrl()
await po.getWalletPageHeaderPo().getUniverseSummaryPo().getLogoUrl()
).toBe(snsProjectLogo);
expect(
await po.getWalletPageHeaderPo().getUniversePageSummaryPo().getLogoUrl()
await po.getWalletPageHeaderPo().getUniverseSummaryPo().getLogoUrl()
).not.toBe(tokenLogo);
});
});
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/tests/page-objects/CanisterHeader.page-object.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";
import { UniversePageSummaryPo } from "./UniversePageSummary.page-object";
import { UniverseSummaryPo } from "./UniverseSummary.page-object";

export class CanisterHeaderPo extends BasePageObject {
private static readonly TID = "canister-page-header-component";
Expand All @@ -9,12 +9,12 @@ export class CanisterHeaderPo extends BasePageObject {
return new CanisterHeaderPo(element.byTestId(CanisterHeaderPo.TID));
}

getUniversePageSummaryPo(): UniversePageSummaryPo {
return UniversePageSummaryPo.under(this.root);
getUniverseSummaryPo(): UniverseSummaryPo {
return UniverseSummaryPo.under(this.root);
}

getUniverseText(): Promise<string> {
return this.getUniversePageSummaryPo().getTitle();
return this.getUniverseSummaryPo().getTitle();
}

getCanisterIdText(): Promise<string> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConfirmationModalPo } from "$tests/page-objects/ConfirmationModal.page-object";
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";

Expand All @@ -16,8 +16,8 @@ export class ImportTokenRemoveConfirmationPo extends BasePageObject {
return ConfirmationModalPo.under(this.root);
}

getUniversePageSummaryPo(): UniversePageSummaryPo {
return UniversePageSummaryPo.under(this.root);
getUniverseSummaryPo(): UniverseSummaryPo {
return UniverseSummaryPo.under(this.root);
}

clickConfirm(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";

Expand All @@ -11,12 +11,12 @@ export class NnsNeuronPageHeaderPo extends BasePageObject {
);
}

getUniversePageSummaryPo(): UniversePageSummaryPo {
return UniversePageSummaryPo.under(this.root);
getUniverseSummaryPo(): UniverseSummaryPo {
return UniverseSummaryPo.under(this.root);
}

getUniverse(): Promise<string> {
return this.getUniversePageSummaryPo().getTitle();
return this.getUniverseSummaryPo().getTitle();
}

getNeuronId(): Promise<string> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";

Expand All @@ -11,11 +11,11 @@ export class SnsNeuronPageHeaderPo extends BasePageObject {
);
}

getUniversePageSummaryPo(): UniversePageSummaryPo {
return UniversePageSummaryPo.under(this.root);
getUniverseSummaryPo(): UniverseSummaryPo {
return UniverseSummaryPo.under(this.root);
}

getUniverse(): Promise<string> {
return this.getUniversePageSummaryPo().getTitle();
return this.getUniverseSummaryPo().getTitle();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";

export class UniversePageSummaryPo extends BasePageObject {
export class UniverseSummaryPo extends BasePageObject {
private static readonly TID = "universe-page-summary-component";

static under(element: PageObjectElement): UniversePageSummaryPo {
return new UniversePageSummaryPo(
element.byTestId(UniversePageSummaryPo.TID)
);
static under(element: PageObjectElement): UniverseSummaryPo {
return new UniverseSummaryPo(element.byTestId(UniverseSummaryPo.TID));
}

async getLogoUrl(): Promise<string> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UniversePageSummaryPo } from "$tests/page-objects/UniversePageSummary.page-object";
import { UniverseSummaryPo } from "$tests/page-objects/UniverseSummary.page-object";
import { BasePageObject } from "$tests/page-objects/base.page-object";
import type { PageObjectElement } from "$tests/types/page-object.types";

Expand All @@ -19,8 +19,8 @@ export class UniverseWithActionableProposalsPo extends BasePageObject {
).map((el) => new UniverseWithActionableProposalsPo(el));
}

getSummaryPo(): UniversePageSummaryPo {
return UniversePageSummaryPo.under(this.root);
getSummaryPo(): UniverseSummaryPo {
return UniverseSummaryPo.under(this.root);
}

getTitle(): Promise<string> {
Expand Down
Loading

0 comments on commit e91d793

Please sign in to comment.