Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement Portfolio page with base layout #6062

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions frontend/src/lib/pages/Portfolio.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<script lang="ts">
import Card from "$lib/components/portfolio/Card.svelte";
import LoginCard from "$lib/components/portfolio/LoginCard.svelte";
import { authSignedInStore } from "$lib/derived/auth.derived";
</script>

<main data-tid="portfolio-page-component">
<div class="top" class:single-card={$authSignedInStore}>
{#if !$authSignedInStore}
<LoginCard />
{/if}
<Card>Card1</Card>
</div>
<div class="content">
<Card>Card3</Card>
<Card>Card4</Card>
</div>
</main>

<style lang="scss">
@use "@dfinity/gix-components/dist/styles/mixins/media";

main {
display: flex;
flex-direction: column;
gap: var(--padding-2x);
padding: var(--padding-2x);

@include media.min-width(large) {
display: grid;
grid-template-rows: auto 1fr;
gap: var(--padding-3x);
padding: var(--padding-3x);
}

.top {
display: grid;
grid-template-columns: 1fr;
gap: var(--padding-2x);

@include media.min-width(large) {
display: grid;
grid-template-columns: 1fr 2fr;

> :global(article:first-of-type) {
order: 1;
}

&.single-card {
grid-template-columns: 1fr;
}
}
}

.content {
display: grid;
grid-template-columns: 1fr;
yhabib marked this conversation as resolved.
Show resolved Hide resolved
gap: var(--padding-2x);

@include media.min-width(large) {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
}
}
</style>
8 changes: 6 additions & 2 deletions frontend/src/routes/(app)/(home)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
<LayoutList {title}>
<Layout>
<Content>
<IslandWidthMain>
{#if $ENABLE_PORTFOLIO_PAGE}
<slot />
</IslandWidthMain>
{:else}
<IslandWidthMain>
<slot />
</IslandWidthMain>
{/if}
</Content>
</Layout>
</LayoutList>
3 changes: 2 additions & 1 deletion frontend/src/routes/(app)/(nns)/portfolio/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import TestIdWrapper from "$lib/components/common/TestIdWrapper.svelte";
import Portfolio from "$lib/pages/Portfolio.svelte";
</script>

<TestIdWrapper testId="portfolio-route-component"></TestIdWrapper>
<TestIdWrapper testId="portfolio-route-component"><Portfolio /></TestIdWrapper>
28 changes: 28 additions & 0 deletions frontend/src/tests/lib/pages/Portfolio.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Portfolio from "$lib/pages/Portfolio.svelte";
import { resetIdentity, setNoIdentity } from "$tests/mocks/auth.store.mock";
import { PortfolioPagePo } from "$tests/page-objects/PortfolioPage.page-object";
import { JestPageObjectElement } from "$tests/page-objects/jest.page-object";
import { render } from "@testing-library/svelte";

describe("Portfolio page", () => {
const renderPage = () => {
const { container } = render(Portfolio);

return PortfolioPagePo.under(new JestPageObjectElement(container));
};

beforeEach(() => {
resetIdentity();
});

it("should display the login card when the user is not logged in", async () => {
setNoIdentity();
const po = renderPage();
expect(await po.getLoginCard().isPresent()).toBe(true);
});

it("should not display the login card when the user is logged in", async () => {
const page = renderPage();
expect(await page.getLoginCard().isPresent()).toBe(false);
});
});
14 changes: 14 additions & 0 deletions frontend/src/tests/page-objects/PortfolioPage.page-object.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { PageObjectElement } from "$tests/types/page-object.types";
import { BasePageObject } from "./base.page-object";

export class PortfolioPagePo extends BasePageObject {
private static readonly TID = "portfolio-page-component";

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

getLoginCard() {
return this.getElement("portfolio-login-card");
}
}
Loading