Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
abdurrahman-ledger committed Dec 5, 2024
1 parent c3d2529 commit a6c4184
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
19 changes: 13 additions & 6 deletions apps/ledger-live-desktop/tests/page/modal/delegate.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { step } from "tests/misc/reporters/step";

export class delegateModal extends Modal {
private titleProvider = this.page.getByTestId("modal-provider-title");
private sideInfoProvider = this.page.getByTestId("modal-provider-side-info");
private delegateContinueButton = this.page.getByText("Continue");
private rowProvider = this.page.getByTestId("modal-provider-row");
private searchOpenButton = this.page.getByText("Show all");
Expand All @@ -18,20 +17,28 @@ export class delegateModal extends Modal {
private checkIcon = this.page.getByTestId("check-icon");

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

@step("Verify first provider name")
@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 selectProvider(row: number) {
this.rowProvider.nth(row - 1).click();
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();
}

Expand Down
17 changes: 11 additions & 6 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 @@ -86,9 +87,9 @@ test.describe("Delegate flows", () => {

await app.account.clickBannerCTA();
await app.delegate.verifyFirstProviderName(account.delegate.provider);
if (account.delegate.account.currency.name === "Solana") {
if (account.delegate.account.currency.name == Currency.SOL.name) {
await app.delegate.verifyContinueDisabled();
await app.delegate.selectProvider(1);
await app.delegate.selectProviderByName(account.delegate.provider);
await app.delegate.verifyProviderTC(account.delegate.provider);
await app.delegate.verifyProvider(1);
}
Expand Down Expand Up @@ -148,17 +149,21 @@ test.describe("Delegate flows", () => {
await app.modal.continue();

await app.delegate.verifyFirstProviderName(validator.delegate.provider);
if (validator.delegate.account.currency.name === "Solana") {
if (validator.delegate.account.currency.name == Currency.SOL.name) {
await app.delegate.verifyContinueDisabled();
await app.delegate.selectProvider(1);
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(2);
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 (!["Solana", "Cardano"].includes(validator.delegate.account.currency.name))
if (
![Currency.SOL.name, Currency.ADA.name].includes(
validator.delegate.account.currency.name,
)
)
await app.delegate.closeProviderList(2);
},
);
Expand Down

0 comments on commit a6c4184

Please sign in to comment.