-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
frontend/src/tests/page-objects/PortfolioPage.page-object.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |