Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

LIVE-448 - Add playwright test suite for market page #4736

Merged
merged 33 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bebd53a
Add playwright test suite for market page
thomasrogerlux Feb 2, 2022
205a473
update screenshots (linux)
ledgerlive Feb 2, 2022
cb2489a
update screenshots (windows)
ledgerlive Feb 2, 2022
8de6e42
update screenshots (windows)
ledgerlive Feb 2, 2022
aef5cc1
update screenshots (linux)
ledgerlive Feb 2, 2022
e0b686d
update screenshots (windows)
ledgerlive Feb 2, 2022
2f2a728
Fix screenshots
thomasrogerlux Feb 11, 2022
bad3a21
Merge branch 'develop' into LIVE-448
thomasrogerlux Feb 11, 2022
bc046e3
Update market tests
thomasrogerlux Feb 21, 2022
203877f
Merge branch 'develop' into LIVE-448
thomasrogerlux Feb 21, 2022
d5dee16
update screenshots (linux)
ledgerlive Feb 21, 2022
60f3d71
update screenshots (windows)
ledgerlive Feb 21, 2022
372f450
update screenshots (windows)
ledgerlive Feb 22, 2022
f8d6ca5
Fix conflicts
thomasrogerlux Feb 24, 2022
896285b
Merge branch 'develop' into LIVE-448
thomasrogerlux Feb 24, 2022
bf954d4
Update LLC
thomasrogerlux Feb 24, 2022
3fa550d
Merge branch 'LIVE-448' of github.com:LedgerHQ/ledger-live-desktop in…
thomasrogerlux Feb 24, 2022
9a38773
update screenshots (linux)
ledgerlive Feb 24, 2022
a163be0
update screenshots (linux)
ledgerlive Feb 24, 2022
2f6ed47
Merge branch 'develop' into LIVE-448
thomasrogerlux Feb 28, 2022
b014e0f
update screenshots (linux)
ledgerlive Feb 28, 2022
a9d6a86
Merge branch 'develop' into LIVE-448
thomasrogerlux Mar 2, 2022
840b9f0
Merge branch 'LIVE-448' of github.com:LedgerHQ/ledger-live-desktop in…
thomasrogerlux Mar 2, 2022
ea1a115
ci run
nabil-brn Mar 3, 2022
34dac88
Merge branch 'develop' into LIVE-448
thomasrogerlux Mar 3, 2022
38464ff
Fix merge
thomasrogerlux Mar 3, 2022
210e9c1
update screenshots (windows)
ledgerlive Mar 3, 2022
2e25062
market page tests
nabil-brn Mar 7, 2022
6f80c49
Merge branch 'develop' into LIVE-448
nabil-brn Mar 7, 2022
fc3f970
update screenshots (linux)
ledgerlive Mar 7, 2022
7b38281
update screenshots (windows)
ledgerlive Mar 7, 2022
1da17a3
last ci run
nabil-brn Mar 7, 2022
0d4214c
Split sorting test step in two
thomasrogerlux Mar 7, 2022
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
2 changes: 1 addition & 1 deletion src/renderer/components/LoadingPlaceholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Activity = styled.div`

function LoadingPlaceholder({ style }: { style?: any }) {
return (
<Wrapper style={style}>
<Wrapper data-test-id="loading-placeholder" style={style}>
<Activity />
</Wrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ function MarkeCoinChartComponent({
)}
</Flex>
</Flex>
<Bar onTabChange={setRange} initialActiveIndex={activeRangeIndex}>
<Bar
data-test-id="market-coin-range-select"
onTabChange={setRange}
initialActiveIndex={activeRangeIndex}
>
{ranges
.filter(k => k !== "1h")
.map(key => (
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/screens/market/MarketCoinScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default function MarketCoinScreen() {
<Flex pl={3} flexDirection="column" alignItems="left" pr={16}>
<Flex flexDirection="row" alignItems="center">
<Title>{name}</Title>
<StarContainer onClick={toggleStar}>
<StarContainer data-test-id="market-coin-star-button" onClick={toggleStar}>
<Icon name={isStarred > 0 ? "StarSolid" : "Star"} size={18} />
</StarContainer>
</Flex>
Expand All @@ -221,19 +221,25 @@ export default function MarketCoinScreen() {
{internalCurrency && (
<>
{availableOnBuy && (
<Button variant="shade" mr={1} onClick={onBuy}>
<Button
data-test-id="market-coin-buy-button"
variant="shade"
mr={1}
onClick={onBuy}
>
{t("accounts.contextMenu.buy")}
</Button>
)}
{availableOnSwap && (
<Button variant="shade" onClick={onSwap}>
<Button data-test-id="market-coin-swap-button" variant="shade" onClick={onSwap}>
{t("accounts.contextMenu.swap")}
</Button>
)}
</>
)}
<Flex justifyContent="flex-end" ml={4}>
<CounterValueSelect
data-test-id="market-coin-counter-value-select"
counterCurrency={counterCurrency}
setCounterCurrency={setCounterCurrency}
supportedCounterCurrencies={supportedCounterCurrencies}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/screens/market/MarketList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function MarketList({
)}
<TableRow header>
<SortTableCell
data-test-id="market-sort-button"
onClick={toggleSortBy}
orderByKey="market_cap"
orderBy={orderBy}
Expand All @@ -331,6 +332,7 @@ function MarketList({
<TableCell disabled>{t("market.marketList.last7d")}</TableCell>
)}
<TableCell
data-test-id="market-star-button"
disabled={starredMarketCoins.length <= 0 && starred.length <= 0}
onClick={toggleStarredAccounts}
>
Expand Down
17 changes: 13 additions & 4 deletions src/renderer/screens/market/MarketRowItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function MarketRowItem({
<TableCell loading />
</TableRow>
) : (
<TableRow onClick={onCurrencyClick}>
<TableRow data-test-id={`market-${currency?.ticker}-row`} onClick={onCurrencyClick}>
<TableCell>{currency?.marketcapRank ?? "-"}</TableCell>
<TableCell overflow="hidden" mr={3}>
<CryptoCurrencyIconWrapper>
Expand All @@ -170,12 +170,21 @@ function MarketRowItem({
{currency.internalCurrency && (
<>
{availableOnBuy && (
<Button variant="shade" mr={1} onClick={onBuy}>
<Button
data-test-id={`market-${currency?.ticker}-buy-button`}
variant="shade"
mr={1}
onClick={onBuy}
>
{t("accounts.contextMenu.buy")}
</Button>
)}
{availableOnSwap && (
<Button variant="shade" onClick={onSwap}>
<Button
data-test-id={`market-${currency?.ticker}-swap-button`}
variant="shade"
onClick={onSwap}
>
{t("accounts.contextMenu.swap")}
</Button>
)}
Expand Down Expand Up @@ -218,7 +227,7 @@ function MarketRowItem({
)}
</TableCell>
)}
<TableCell onClick={onStarClick}>
<TableCell data-test-id={`market-${currency?.ticker}-star-button`} onClick={onStarClick}>
<Icon name={isStarred ? "StarSolid" : "Star"} size={18} />
</TableCell>
</TableRow>
Expand Down
8 changes: 7 additions & 1 deletion src/renderer/screens/market/SideDrawerFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export default function SideDrawerFilter({

return (
<>
<Button Icon={Icons.FiltersRegular} variant="shade" outline onClick={openDrawer} />
<Button
data-test-id="market-filter-drawer-button"
Icon={Icons.FiltersRegular}
variant="shade"
outline
onClick={openDrawer}
/>
<SideDrawer
isOpen={isOpen}
onRequestClose={closeDrawer}
Expand Down
16 changes: 13 additions & 3 deletions src/renderer/screens/market/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,27 @@ export default function Market() {
<Title>{t("market.title")}</Title>
<Flex flexDirection="row" pr="6px" my={2} alignItems="center" justifyContent="space-between">
<SearchContainer>
<SearchInput value={search} onChange={updateSearch} placeholder={t("common.search")} />
<SearchInput
data-test-id="market-search-input"
value={search}
onChange={updateSearch}
placeholder={t("common.search")}
/>
</SearchContainer>
<Flex flexDirection="row" alignItems="center" justifyContent="flex-end">
<Flex width="290px" justifyContent="flex-end" ml={3}>
<Flex
data-test-id="market-countervalue-select"
width="290px"
justifyContent="flex-end"
ml={3}
>
<CounterValueSelect
counterCurrency={counterCurrency}
setCounterCurrency={setCounterCurrency}
supportedCounterCurrencies={supportedCounterCurrencies}
/>
</Flex>
<Flex mx={3}>
<Flex data-test-id="market-range-select" mx={3}>
<Dropdown
label={t("market.rangeLabel")}
menuPortalTarget={document.body}
Expand Down
8 changes: 8 additions & 0 deletions tests/models/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { Page, Locator } from "@playwright/test";
export class Layout {
readonly page: Page;
readonly totalBalance: Locator;
readonly pageScroller: Locator;
readonly loadingLogo: Locator;
readonly logo: Locator;
readonly bigSpinner: Locator;
readonly inputError: Locator;
readonly inputWarning: Locator;
readonly drawerCollapseButton: Locator;
readonly drawerPortfolioButton: Locator;
readonly drawerMarketButton: Locator;
readonly drawerAccountsButton: Locator;
readonly drawerDiscoverButton: Locator;
readonly drawerSendButton: Locator;
Expand Down Expand Up @@ -37,6 +39,7 @@ export class Layout {
// drawer
this.drawerCollapseButton = page.locator("data-test-id=drawer-collapse-button");
this.drawerPortfolioButton = page.locator("data-test-id=drawer-dashboard-button");
this.drawerMarketButton = page.locator("data-test-id=drawer-market-button");
this.drawerAccountsButton = page.locator("data-test-id=drawer-accounts-button");
this.drawerDiscoverButton = page.locator("data-test-id=drawer-catalog-button");
this.drawerSendButton = page.locator("data-test-id=drawer-send-button");
Expand All @@ -57,6 +60,7 @@ export class Layout {
this.discreetTooltip = page.locator("#tippy-12"); //automatically generated tippy id but it's consistent

// general
this.pageScroller = page.locator("id=page-scroller");
this.loadingLogo = page.locator("id=loading-logo");
this.logo = page.locator("data-test-id=logo");
this.inputError = page.locator("id=input-error"); // no data-test-id because css style is applied
Expand All @@ -71,6 +75,10 @@ export class Layout {
await this.drawerPortfolioButton.click();
}

async goToMarket() {
await this.drawerMarketButton.click();
}

async goToAccounts() {
await this.drawerAccountsButton.click();
}
Expand Down
27 changes: 27 additions & 0 deletions tests/models/MarketCoinPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Page, Locator } from "@playwright/test";

export class MarketCoinPage {
readonly page: Page;
readonly buyButton: Locator;
readonly swapButton: Locator;
readonly counterValueSelect: Locator;
readonly marketRangeSelect: Locator;
readonly starFilterButton: Locator;

constructor(page: Page) {
this.page = page;
this.buyButton = page.locator("data-test-id=market-coin-buy-button");
this.swapButton = page.locator("data-test-id=market-coin-swap-button");
this.counterValueSelect = page.locator("data-test-id=market-coin-counter-value-select");
this.marketRangeSelect = page.locator("data-test-id=market-coin-range-select");
this.starFilterButton = page.locator("data-test-id=market-coin-star-button");
}

async openBuyPage() {
await this.buyButton.click();
}

async openSwapPage() {
await this.swapButton.click();
}
}
83 changes: 83 additions & 0 deletions tests/models/MarketPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Page, Locator } from "@playwright/test";

export class MarketPage {
readonly page: Page;
readonly searchInput: Locator;
readonly counterValueSelect: Locator;
readonly marketRangeSelect: Locator;
readonly filterDrawerButton: Locator;
readonly starFilterButton: Locator;
readonly sortButton: Locator;
readonly loadingPlaceholder: Locator;
readonly coinRow: Function;
readonly starButton: Function;
readonly buyButton: Function;
readonly swapButton: Function;

constructor(page: Page) {
this.page = page;
this.searchInput = page.locator("data-test-id=market-search-input");
this.counterValueSelect = page.locator("data-test-id=market-countervalue-select");
this.marketRangeSelect = page.locator("data-test-id=market-range-select");
this.filterDrawerButton = page.locator("data-test-id=market-filter-drawer-button");
this.starFilterButton = page.locator("data-test-id=market-star-button");
this.sortButton = page.locator("data-test-id=market-sort-button");
this.loadingPlaceholder = page.locator("data-test-id=loading-placeholder");
this.coinRow = (ticker: string): Locator => page.locator(`data-test-id=market-${ticker}-row`);
this.starButton = (ticker: string): Locator =>
page.locator(`data-test-id=market-${ticker}-star-button`);
this.buyButton = (ticker: string): Locator =>
page.locator(`data-test-id=market-${ticker}-buy-button`);
this.swapButton = (ticker: string): Locator =>
page.locator(`data-test-id=market-${ticker}-swap-button`);
}

async search(query: string) {
await this.searchInput.fill(query);
}

async openFilterDrawer() {
await this.filterDrawerButton.click();
}

async toggleInvertSort() {
await this.sortButton.click();
}

async switchCountervalue(ticker: string) {
await this.counterValueSelect.click();
// TODO: For some reason need to hack selects like that
await this.page.click('#react-select-2-listbox div div:has-text("Thai Baht - THB")');
}

async switchMarketRange(range: string) {
await this.marketRangeSelect.click();
// TODO: For some reason need to hack selects like that
await this.page.click(`text=${range}`);
}

async toggleStarFilter() {
await this.starFilterButton.click();
}

async openCoinPage(ticker: string) {
await this.coinRow(ticker).click();
}

async starCoin(ticker: string) {
await this.starButton(ticker).click();
}

async openBuyPage(ticker: string) {
await this.buyButton(ticker).click();
}

async openSwapPage(ticker: string) {
await this.swapButton(ticker).click();
}

async waitForLoading() {
await this.loadingPlaceholder.first().waitFor({ state: "detached" });
await this.swapButton("btc").waitFor({ state: "attached" }); // swap buttons are displayed few seconds after
}
}
2 changes: 1 addition & 1 deletion tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config: PlaywrightTestConfig = {
testDir: "specs/",
testIgnore: "specs/recorder.spec.ts",
outputDir: "./artifacts/test-results",
timeout: 60000,
timeout: process.env.CI ? 60000 : 600000,
globalTimeout: 0,
globalSetup: require.resolve("./utils/global-setup"),
globalTeardown: require.resolve("./utils/global-teardown"),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/account.spec.ts-snapshots/BTC-complete-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/account.spec.ts-snapshots/ETH-complete-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/account.spec.ts-snapshots/LTC-complete-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/account.spec.ts-snapshots/XRP-complete-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/account.spec.ts-snapshots/XTZ-complete-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/devmode.spec.ts-snapshots/devMode-on-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/layout.spec.ts-snapshots/accounts-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/layout.spec.ts-snapshots/buy-sell-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/layout.spec.ts-snapshots/discreet-mode-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/layout.spec.ts-snapshots/help-drawer-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/layout.spec.ts-snapshots/receive-modal-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/specs/layout.spec.ts-snapshots/send-modal-win32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading