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

[QAA-356][Playwright][Speculos] Fix solana stake flow #8605

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Props = {
style?: React.CSSProperties;
fontSize?: number;
color?: string;
id?: string;
}; // can add more dynamic options if needed
export function LinkWithExternalIcon({
onClick,
Expand All @@ -48,9 +49,16 @@ export function LinkWithExternalIcon({
style,
fontSize,
color = "wallet",
id,
}: Props) {
return (
<Wrapper onClick={onClick} style={style} fontSize={fontSize || 4} color={color}>
<Wrapper
onClick={onClick}
style={style}
fontSize={fontSize || 4}
color={color}
data-testid={id}
>
{label || children}
</Wrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ export default function LedgerValidatorTCLink({ transaction }: Props) {
if (!data) return null;

const openLedgerValidatorTC = () => openURL(data.url);
return <LinkWithExternalIcon label={t(data.label)} onClick={openLedgerValidatorTC} />;
return (
<LinkWithExternalIcon
label={t(data.label)}
onClick={openLedgerValidatorTC}
id="ledger-validator-tc"
/>
);
}
const shouldShowTC = ({ model }: Transaction) => {
switch (model.kind) {
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/src/renderer/icons/Check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Check = ({
size?: number;
color?: string;
}) => (
<svg id={id} viewBox="0 0 16 16" height={size} width={size}>
<svg id={id} viewBox="0 0 16 16" height={size} width={size} data-testid="check-icon">
<path
fill={color}
d="M13.62 2.608l-8.22 8.22-3.02-3.02a.375.375 0 0 0-.53 0l-.884.884a.375.375 0 0 0 0 .53l4.169 4.17a.375.375 0 0 0 .53 0l9.37-9.37a.375.375 0 0 0 0-.53l-.884-.884a.375.375 0 0 0-.53 0z"
Expand Down
71 changes: 54 additions & 17 deletions apps/ledger-live-desktop/tests/page/modal/delegate.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,59 @@ export class delegateModal extends Modal {
private stakeProviderContainer = (stakeProviderID: string) =>
this.page.getByTestId(`stake-provider-container-${stakeProviderID}`);
private detailsButton = this.page.getByRole("button", { name: "View details" });
private validatorTC = this.page.getByTestId("ledger-validator-tc");
private checkIcon = this.page.getByTestId("check-icon");

@step("Get title provider")
async getTitleProvider() {
await this.titleProvider.waitFor();
return await this.titleProvider.textContent();
@step("Get title provider on row $0")
async getTitleProvider(row: number): Promise<string> {
await this.titleProvider.nth(row - 1).waitFor();
const titleProvider = await this.titleProvider.nth(row - 1).textContent();
expect(titleProvider).not.toBeNull();
return titleProvider!;
}

@step("Verify provider is $0")
async verifyProvider(provider: string) {
const providerName = await this.getTitleProvider();
if (providerName) {
expect(providerName).toBe(provider);
}
@step("Verify first provider name is $0")
async verifyFirstProviderName(provider: string) {
const providerName = await this.getTitleProvider(1);
expect(providerName).toBe(provider);
}

@step("Select provider on row $0")
async selectProviderOnRow(row: number) {
await this.selectProviderByName(await this.getTitleProvider(row));
}

@step("Select provider $0")
async selectProviderByName(name: string) {
const providerRow = this.rowProvider.filter({ hasText: name }).first();
await providerRow.click({ position: { x: 10, y: 10 } }); // Prevent click on the title as it is a redirection
await this.verifyContinueEnabled();
}

@step("Select provider on row $0")
async verifyProvider(row: number) {
const isCheckIconWithinRowProvider =
(await this.rowProvider
.nth(row - 1)
.locator(this.checkIcon)
.count()) > 0;
expect(isCheckIconWithinRowProvider).toBe(true);
}

@step("Verify continue button is disabled")
async verifyContinueDisabled() {
await expect(this.delegateContinueButton).toBeDisabled();
}

@step("Verify continue button is enabled")
async verifyContinueEnabled() {
await expect(this.delegateContinueButton).toBeEnabled();
}

@step("Verify provider TC contains $0")
async verifyProviderTC(provider: string) {
const providerTC = await this.validatorTC.textContent();
expect(providerTC).toContain(provider);
}

@step("Click on continue button - delegate")
Expand All @@ -43,14 +83,11 @@ export class delegateModal extends Modal {
await this.inputSearchField.fill(provider);
}

@step("check selected provider is different from the previous one")
async selectProvider(providerIndex: number) {
const selectedfProvider = await this.titleProvider.nth(providerIndex).textContent();
await this.rowProvider.nth(providerIndex).click();
@step("Check selected provider is displayed when closing list")
async closeProviderList(providerRow: number) {
const selectedfProvider = await this.getTitleProvider(providerRow);
await this.searchCloseButton.click();
if (selectedfProvider) {
expect(await this.getTitleProvider()).toContain(selectedfProvider);
}
expect(await this.getTitleProvider(1)).toContain(selectedfProvider);
}

@step("Click on chosen stake provider $0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("Delegate flow using max amount", async () => {

await test.step("Check Ledger is the provider by default", async () => {
await modalPage.continue();
const defaultprovider = await delegate.getTitleProvider();
const defaultprovider = await delegate.getTitleProvider(1);
expect(defaultprovider).toEqual("Ledger");
});

Expand All @@ -52,8 +52,8 @@ test("The user search and select a provider", async () => {
const providerResearched = "Figment";
await delegate.openSearchProviderModal();
await delegate.inputProvider(providerResearched);
await delegate.selectProvider(0);
const providerSelected = await delegate.getTitleProvider();
await delegate.selectProviderOnRow(1);
const providerSelected = await delegate.getTitleProvider(1);
expect(providerSelected).toEqual(providerResearched);
});
});
37 changes: 28 additions & 9 deletions apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { addTmsLink } from "tests/utils/allureUtils";
import { getDescription } from "../../utils/customJsonReporter";
import { commandCLI } from "tests/utils/cliUtils";
import { isRunningInScheduledWorkflow } from "tests/utils/githubUtils";
import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency";

const e2eDelegationAccounts = [
{
Expand Down Expand Up @@ -34,10 +35,10 @@ const validators = [
delegate: new Delegate(Account.NEAR_2, "0.01", "ledgerbyfigment.poolv1.near"),
xrayTicket: "B2CQA-2732, B2CQA-2765",
},
/*{
delegate: new Delegate(Account.ADA_1, "0.01", "LBF3 - Ledger by Figment 3"), // todo: deactivate due to bug (Clicking 'Show less' does not select the validator that was chosen previously) - LIVE-14500
{
delegate: new Delegate(Account.ADA_1, "0.01", "LBF3 - Ledger by Figment 3"),
xrayTicket: "B2CQA-2766",
},*/
},
{
delegate: new Delegate(Account.MULTIVERS_X_1, "1", "Ledger by Figment"),
xrayTicket: "B2CQA-2767",
Expand Down Expand Up @@ -85,8 +86,13 @@ test.describe("Delegate flows", () => {
await app.accounts.navigateToAccountByName(account.delegate.account.accountName);

await app.account.clickBannerCTA();
await app.delegate.verifyProvider(account.delegate.provider);

await app.delegate.verifyFirstProviderName(account.delegate.provider);
if (account.delegate.account.currency.name == Currency.SOL.name) {
await app.delegate.verifyContinueDisabled();
await app.delegate.selectProviderByName(account.delegate.provider);
await app.delegate.verifyProviderTC(account.delegate.provider);
await app.delegate.verifyProvider(1);
}
await app.delegate.continueDelegate();
await app.delegate.fillAmount(account.delegate.amount);
await app.modal.countinueSendAmount();
Expand Down Expand Up @@ -142,10 +148,23 @@ test.describe("Delegate flows", () => {
await app.account.startStakingFlowFromMainStakeButton();
await app.modal.continue();

await app.delegate.verifyProvider(validator.delegate.provider);
await app.delegate.verifyFirstProviderName(validator.delegate.provider);
if (validator.delegate.account.currency.name == Currency.SOL.name) {
await app.delegate.verifyContinueDisabled();
await app.delegate.selectProviderByName(validator.delegate.provider);
await app.delegate.verifyProviderTC(validator.delegate.provider);
} else await app.delegate.verifyContinueEnabled();
await app.delegate.verifyProvider(1);
await app.delegate.openSearchProviderModal();
await app.delegate.checkValidatorListIsVisible();
await app.delegate.selectProvider(1);
await app.delegate.selectProviderOnRow(2);
// TODO: verification skipped due to bug (Clicking 'Show less' does not select the validator that was chosen previously) - LIVE-14500
if (
![Currency.SOL.name, Currency.ADA.name].includes(
validator.delegate.account.currency.name,
)
)
await app.delegate.closeProviderList(2);
},
);
});
Expand Down Expand Up @@ -185,7 +204,7 @@ test.describe("Delegate flows", () => {
await app.assetDrawer.selectAsset(delegateAccount.account.currency);
await app.assetDrawer.selectAccountByIndex(delegateAccount.account);

await app.delegate.verifyProvider(delegateAccount.provider);
await app.delegate.verifyFirstProviderName(delegateAccount.provider);
await app.delegate.continueDelegate();
},
);
Expand All @@ -206,7 +225,7 @@ test.describe("Delegate flows", () => {

await app.assetDrawer.selectAccountByIndex(delegateAccount.account);

await app.delegate.verifyProvider(delegateAccount.provider);
await app.delegate.verifyFirstProviderName(delegateAccount.provider);
await app.delegate.continueDelegate();
},
);
Expand Down
Loading