Skip to content

Commit

Permalink
check specifically for each skeleton card
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabib committed Jan 23, 2025
1 parent 634e43e commit 8f14282
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script lang="ts">
import Card from "$lib/components/portfolio/Card.svelte";
export let testId: string;
</script>

<Card testId="skeleton-tokens-card">
<Card {testId}>
<div class="wrapper">
<div class="header">
<div class="header-wrapper">
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/pages/Portfolio.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</div>
<div class="content">
{#if heldTokensCard === "skeleton"}
<SkeletonTokensCard />
<SkeletonTokensCard testId="held-tokens-skeleton-card" />
{:else if heldTokensCard === "empty"}
<NoHeldTokensCard />
{:else}
Expand All @@ -135,7 +135,7 @@
{/if}

{#if stakedTokensCard === "skeleton"}
<SkeletonTokensCard />
<SkeletonTokensCard testId="staked-tokens-skeleton-card" />
{:else if stakedTokensCard === "empty"}
<NoStakedTokensCard primaryCard={hasNoStakedTokensCardAPrimaryAction} />
{:else}
Expand Down
30 changes: 20 additions & 10 deletions frontend/src/tests/lib/pages/Portfolio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ describe("Portfolio page", () => {
});

expect(await po.getTotalAssetsCardPo().hasSpinner()).toEqual(false);
expect(await po.getNumberOfSkeletonCards()).toEqual(0);
expect(await po.getHeldTokensSkeletonCard().isPresent()).toEqual(false);
expect(await po.getStakedTokensSkeletonCard().isPresent()).toEqual(false);
});
});

Expand Down Expand Up @@ -540,9 +541,12 @@ describe("Portfolio page", () => {
});

expect(await po.getTotalAssetsCardPo().hasSpinner()).toEqual(true);
expect(await po.getNumberOfSkeletonCards()).toEqual(2);
expect(await po.getHeldTokensCardPo().isPresent()).toBe(false);
expect(await po.getStakedTokensCardPo().isPresent()).toBe(false);
expect(await po.getHeldTokensSkeletonCard().isPresent()).toEqual(true);
expect(await po.getStakedTokensSkeletonCard().isPresent()).toEqual(
true
);
expect(await po.getHeldTokensCardPo().isPresent()).toEqual(false);
expect(await po.getStakedTokensCardPo().isPresent()).toEqual(false);

const loadedToken = createUserToken({
balanceInUsd: 100,
Expand All @@ -554,9 +558,12 @@ describe("Portfolio page", () => {
});

expect(await po.getTotalAssetsCardPo().hasSpinner()).toEqual(true);
expect(await po.getNumberOfSkeletonCards()).toEqual(1);
expect(await po.getHeldTokensCardPo().isPresent()).toBe(true);
expect(await po.getStakedTokensCardPo().isPresent()).toBe(false);
expect(await po.getHeldTokensSkeletonCard().isPresent()).toEqual(false);
expect(await po.getStakedTokensSkeletonCard().isPresent()).toEqual(
true
);
expect(await po.getHeldTokensCardPo().isPresent()).toEqual(true);
expect(await po.getStakedTokensCardPo().isPresent()).toEqual(false);

const loadedProject: TableProject = {
...mockTableProject,
Expand All @@ -570,9 +577,12 @@ describe("Portfolio page", () => {
});

expect(await po.getTotalAssetsCardPo().hasSpinner()).toEqual(false);
expect(await po.getNumberOfSkeletonCards()).toEqual(0);
expect(await po.getHeldTokensCardPo().isPresent()).toBe(true);
expect(await po.getStakedTokensCardPo().isPresent()).toBe(true);
expect(await po.getHeldTokensSkeletonCard().isPresent()).toEqual(false);
expect(await po.getStakedTokensSkeletonCard().isPresent()).toEqual(
false
);
expect(await po.getHeldTokensCardPo().isPresent()).toEqual(true);
expect(await po.getStakedTokensCardPo().isPresent()).toEqual(true);
});
});
});
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/tests/page-objects/PortfolioPage.page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ export class PortfolioPagePo extends BasePageObject {
return StakedTokensCardPo.under(this.root);
}

async getNumberOfSkeletonCards(): Promise<number> {
const skeletons = await this.root.allByTestId("skeleton-tokens-card");
return skeletons.length;
getHeldTokensSkeletonCard(): PageObjectElement {
return this.getElement("held-tokens-skeleton-card");
}

getStakedTokensSkeletonCard(): PageObjectElement {
return this.getElement("staked-tokens-skeleton-card");
}
}

0 comments on commit 8f14282

Please sign in to comment.