Skip to content

Commit

Permalink
test(porfolio): enable ENABLE_PORTFOLIO_PAGE in missing e2e test (#6240)
Browse files Browse the repository at this point in the history
# Motivation

In #6199, we will change the root page from the `tokens` page to the
`portfolio`.
In #6225, we modified tests that were redirecting to `/` by enabling the
feature flag and reloading the page to ensure they function correctly.

This PR addresses  one missing case from #6225.

# Changes

- Updated the expectations for navigating to `/`.
- Extended the `AppPo` to return the `PortfolioPo`.

# Tests

- Should pass as before.

# Todos

- [ ] Add entry to changelog (if necessary).
Not necessary
  • Loading branch information
yhabib authored Jan 23, 2025
1 parent 0230d80 commit afbe5af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
32 changes: 24 additions & 8 deletions frontend/src/tests/e2e/multi-tab-auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { AppPo } from "$tests/page-objects/App.page-object";
import { PlaywrightPageObjectElement } from "$tests/page-objects/playwright.page-object";
import { signInWithNewUser, step } from "$tests/utils/e2e.test-utils";
import {
setFeatureFlag,
signInWithNewUser,
step,
} from "$tests/utils/e2e.test-utils";
import { expect, test } from "@playwright/test";

const expectSignedOut = async (appPo: AppPo) => {
Expand All @@ -15,11 +19,12 @@ const expectSignedInAccountsPage = async (appPo: AppPo) => {
expect(await appPo.getSignInPo().isPresent()).toBe(false);
};

const expectSignedInTokensPage = async (appPo: AppPo) => {
await appPo.getTokensPo().getTokensPagePo().waitFor();
expect(await appPo.getTokensPo().getSignInTokensPagePo().isPresent()).toBe(
false
);
const expectSignedInPortfolioPage = async (appPo: AppPo) => {
await appPo.getPortfolioPo().getPortfolioPagePo().waitFor();

expect(
await appPo.getPortfolioPo().getPortfolioPagePo().getLoginCard().isPresent()
).toBe(false);
};

test("Test multi-tab auth", async ({ page: page1, context }) => {
Expand Down Expand Up @@ -47,9 +52,20 @@ test("Test multi-tab auth", async ({ page: page1, context }) => {
await page2.reload();
await expectSignedInAccountsPage(appPo2);

// When signed in, the landing page shows the tokens page.
// When signed in, the landing page shows the portfolio page.
await page1.goto("/");
await expectSignedInTokensPage(appPo1);

//TODO: Remove once the the feature flag is in PROD
await expect(page1).toHaveTitle(/.*\s\/\sNNS Dapp/);

await setFeatureFlag({
page: page1,
featureFlag: "ENABLE_PORTFOLIO_PAGE",
value: true,
});

await page1.reload();
await expectSignedInPortfolioPage(appPo1);

await step("Sign out");
await appPo1.getAccountMenuPo().openMenu();
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/tests/page-objects/App.page-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LaunchpadPo } from "$tests/page-objects/Launchpad.page-object";
import { MenuItemsPo } from "$tests/page-objects/MenuItems.page-object";
import { NeuronDetailPo } from "$tests/page-objects/NeuronDetail.page-object";
import { NeuronsPo } from "$tests/page-objects/Neurons.page-object";
import { PortfolioRoutePo } from "$tests/page-objects/PortfolioRoute.page-object";
import { ProjectDetailPo } from "$tests/page-objects/ProjectDetail.page-object";
import { ProposalDetailPo } from "$tests/page-objects/ProposalDetail.page-object";
import { ProposalsPo } from "$tests/page-objects/Proposals.page-object";
Expand Down Expand Up @@ -40,6 +41,10 @@ export class AppPo extends BasePageObject {
return SignInAccountsPo.under(this.root);
}

getPortfolioPo(): PortfolioRoutePo {
return PortfolioRoutePo.under(this.root);
}

getTokensPo(): TokensRoutePo {
return TokensRoutePo.under(this.root);
}
Expand Down

0 comments on commit afbe5af

Please sign in to comment.