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(portfolio): implement page loading states #6216

Merged
merged 8 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
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
48 changes: 28 additions & 20 deletions frontend/src/tests/lib/pages/Portfolio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,25 @@ describe("Portfolio page", () => {
});

describe("Loading States", () => {
it("should show loading states while tokens are loading", async () => {
const loadingToken = createUserTokenLoading({});
const loadingProject: TableProject = {
...mockTableProject,
isStakeLoading: true,
};
const loadingToken = createUserTokenLoading({});
const loadingProject: TableProject = {
...mockTableProject,
isStakeLoading: true,
};

const loadedToken = createUserToken({
balanceInUsd: 100,
universeId: principal(1),
});

// Test Case 1: Initial loading state - both tokens and projects loading
let po = renderPage({
const loadedProject: TableProject = {
...mockTableProject,
stakeInUsd: 100,
isStakeLoading: false,
};

it("should show the inital loading state - both tokens and projects loading", async () => {
const po = renderPage({
userTokens: [loadingToken],
tableProjects: [loadingProject],
});
Expand All @@ -562,14 +572,15 @@ describe("Portfolio page", () => {
);
expect(await po.getHeldTokensCardPo().isPresent()).toEqual(false);
expect(await po.getStakedTokensCardPo().isPresent()).toEqual(false);
});

it("should show a partial loading state - tokens loaded, projects still loading", async () => {
const loadedToken = createUserToken({
balanceInUsd: 100,
universeId: principal(1),
});

// Test Case 2: Partial loading state - tokens loaded, projects still loading
po = renderPage({
const po = renderPage({
userTokens: [loadedToken],
tableProjects: [loadingProject],
});
Expand All @@ -581,15 +592,11 @@ describe("Portfolio page", () => {
);
expect(await po.getHeldTokensCardPo().isPresent()).toEqual(true);
expect(await po.getStakedTokensCardPo().isPresent()).toEqual(false);
});

const loadedProject: TableProject = {
...mockTableProject,
stakeInUsd: 100,
isStakeLoading: false,
};

// Test Case 3: Partial loading state - projects loaded, tokens still loading
po = renderPage({
it("should show a partial loading state - projects loaded, tokens still loading", async () => {
// Test Case 3:
yhabib marked this conversation as resolved.
Show resolved Hide resolved
const po = renderPage({
userTokens: [loadingToken],
tableProjects: [loadedProject],
});
Expand All @@ -601,9 +608,10 @@ describe("Portfolio page", () => {
);
expect(await po.getHeldTokensCardPo().isPresent()).toEqual(false);
expect(await po.getStakedTokensCardPo().isPresent()).toEqual(true);
});

// Test Case 4: Fully loaded state - both tokens and projects loaded
po = renderPage({
it("should show a fully loaded state - both tokens and projects loaded", async () => {
const po = renderPage({
userTokens: [loadedToken],
yhabib marked this conversation as resolved.
Show resolved Hide resolved
tableProjects: [loadedProject],
});
Expand Down
Loading