Skip to content

Commit

Permalink
chore(tests): fix e2e runner (#4069)
Browse files Browse the repository at this point in the history
* test

* test

* fix sendconfirmation and addresses tests

* fix address e2e for TD

* updated getInputTokenType condition for send token

* fixed service provider e2e

* fix service provider e2e

* change delay back to 3000

* update test invalid url

* chore

* address spec fix

* e2e fix

* fix e2e

* use changi rpc for remote pg

* choer(tests): update snapshot

---------

Co-authored-by: Lyka Labrada <[email protected]>
Co-authored-by: Harsh <[email protected]>
Co-authored-by: Harsh R <[email protected]>
  • Loading branch information
4 people authored Oct 24, 2023
1 parent 0790c65 commit 4f922f1
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- run: .github/workflows/ci/wait-for http://localhost:3001/_actuator/probes/liveness -t 240
- run: .github/workflows/ci/wait-for http://localhost:3002/_actuator/probes/liveness -t 240
- run: .github/workflows/ci/wait-for http://localhost:19551/ping -t 240
- run: .github/workflows/ci/wait-for http://localhost:19550/ping -t 240

- uses: cypress-io/github-action@d79d2d530a66e641eb4a5f227e13bc985c60b964 # v4.2.2
with:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
ports:
- "19553:80"
- "19552:8080"
# - "19551:8082"
- "19550:8082"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function ActionButtons(): JSX.Element {
<ActionButton
name={translate("components/ActionButtons", "Convert")}
iconSize={28}
testID="convert_button"
testID="convert_action_button"
onPress={() => {
navigateToTokenSelectionScreen(TokenListType.From);
}}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ function NavigateItemRow({
light={tailwind("text-mono-light-v2-700")}
dark={tailwind("text-mono-dark-v2-700")}
style={tailwind("font-normal-v2 text-sm mr-1")}
testID={`${testID}_value`}
>
{translate("screens/Settings", value)}
</ThemedTextV2>
Expand Down
134 changes: 60 additions & 74 deletions mobile-app/cypress/e2e/functional/transferDomain/addresses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ context("Portfolio - Send - Address Book", () => {
"0x2DeC425BF3c289C9B7452aD54E2F9877F21e0316",
];

function validateMatchAddress(address: string, label: string): void {
cy.getByTestID("address_input").contains(address);
if (label === labels[0]) {
cy.getByTestID("address_input_footer").contains(label);
} else {
cy.getByTestID("address_input_footer_evm").contains(label);
}
// Addresses that shows up under the 'Your address' tab in address book
function populateYourAddresses(): void {
// Create new wallet address - only available if there is DFI UTXO
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("wallet_address").should("exist").click();
cy.getByTestID("create_new_address").should("exist").click(); // Generate Address 2 wallet address

// Go back to previous Address 1
cy.getByTestID("wallet_address").should("exist").click();
cy.getByTestID("address_row_0").click();
cy.getByTestID("wallet_address").should("have.text", "Address 1");
}

// Whitelisted addresses
function populateAddressBook(hasExistingAddress?: boolean): void {
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("action_button_group").should("exist");
cy.getByTestID("send_balance_button").click().wait(3000);
cy.getByTestID("select_DFI").click().wait(3000);
cy.getByTestID("address_book_button").click();
cy.wrap(labels).each((_v, index: number) => {
if (index === 0) {
cy.getByTestID("button_add_address").click();
} else {
cy.getByTestID("add_new_address").click();
}
cy.getByTestID("add_new_address").click();

if (hasExistingAddress) {
// Reselect DVM address type
Expand All @@ -45,43 +46,16 @@ context("Portfolio - Send - Address Book", () => {
cy.getByTestID("address_book_address_input_error").should("not.exist");
cy.getByTestID("save_address_label").click().wait(1000);
cy.getByTestID("pin_authorize").type("000000").wait(2000);
validateMatchAddress(addresses[index], labels[index]);
cy.wait(1000);
cy.getByTestID("address_input_clear_button").click();
cy.getByTestID("address_book_button").click();
cy.getByTestID(`address_row_label_${index}_WHITELISTED`).contains(
labels[index],
);
cy.getByTestID(`address_row_text_${index}_WHITELISTED`).contains(
addresses[index],
);
// cy.getByTestID('address_book_address_input').clear().type(addresses[index]).blur()
});
}
function verifyWhitelistedAddressRowItems(index: number) {
cy.getByTestID(`address_row_label_${index}_WHITELISTED`).should(
"have.text",
labels[index],
);
cy.getByTestID(`address_row_text_${index}_WHITELISTED`).should(
"have.text",
addresses[index],
);

cy.getByTestID(`address_row_${index}_WHITELISTED_caret`).should("exist");

// dvm address
if (index === 0) {
cy.getByTestID(`address_row_label_${index}_WHITELISTED_EVM_tag`).should(
"not.exist",
);
// evm address
} else {
cy.getByTestID(`address_row_label_${index}_WHITELISTED_EVM_tag`).should(
"exist",
);
}
}
function verifyYourAddressRowItems(index: number) {
// Generated wallet label
cy.getByTestID(`address_row_label_${index}_YOUR_ADDRESS`).should(
Expand All @@ -95,14 +69,12 @@ context("Portfolio - Send - Address Book", () => {
cy.getByTestID(`address_row_text_${index}_YOUR_ADDRESS_EVM`).should(
"exist",
);

// caret
cy.getByTestID(`address_row_${index}_YOUR_ADDRESS_caret`).should("exist");
}

// Send DFI tokens dvm -> evm
function topUpDfiInEvmDomain() {
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("action_button_group").should("exist");
cy.getByTestID("send_balance_button").click();
cy.getByTestID("select_DFI").click();
cy.getByTestID("25%_amount_button").click();
Expand All @@ -114,41 +86,71 @@ context("Portfolio - Send - Address Book", () => {
// Send confirmation screen
cy.getByTestID("button_confirm_send").click();
cy.getByTestID("pin_authorize").type("000000").wait(4000);
cy.getByTestID("oceanInterface_close").click(); // Close ocean interface popup
}

describe("Whitelisted and Your Addresses tab", () => {
before(() => {
cy.createEmptyWallet(true);
cy.sendDFItoWallet().sendDFITokentoWallet().wait(4000);
cy.getByTestID("bottom_tab_portfolio").click();

topUpDfiInEvmDomain();
cy.getByTestID("oceanInterface_close").click(); // Close ocean interface popup

populateYourAddresses(); // Generate new wallet Address 2
populateAddressBook(); // Add whitelist addresses
});

it("(dvm) Whitelisted - should not display evm tag for dvm addresses", () => {
populateAddressBook(); // Add whitelist addresses
verifyWhitelistedAddressRowItems(0);
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("header_settings").click();
cy.getByTestID("address_book_title").click();
cy.getByTestID("address_row_label_0_WHITELISTED").should(
"have.text",
labels[0],
);
cy.getByTestID("address_row_text_0_WHITELISTED").should(
"have.text",
addresses[0],
);
cy.getByTestID("address_row_0_WHITELISTED_caret").should("exist");

cy.getByTestID("address_row_label_0_WHITELISTED_EVM_tag").should(
"not.exist",
);
});

it("(dvm) Whitelisted - should display evm tag for evm addresses", () => {
verifyWhitelistedAddressRowItems(1);
cy.getByTestID("address_row_label_1_WHITELISTED").should(
"have.text",
labels[1],
);
cy.getByTestID("address_row_text_1_WHITELISTED").should(
"have.text",
addresses[1],
);
cy.getByTestID("address_row_1_WHITELISTED_caret").should("exist");
cy.getByTestID("address_row_label_1_WHITELISTED_EVM_tag").should("exist");
});

it("(dvm) Your Addresses - should display not evm tag for dvm addresses", () => {
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("header_settings").click();
cy.getByTestID("address_book_title").click();
cy.getByTestID("address_button_group_YOUR_ADDRESS").click();
verifyYourAddressRowItems(0);
});

it("(dvm) Your Addresses - should display evm tag for evm addresses", () => {
verifyYourAddressRowItems(1);
cy.getByTestID("bottom_tab_portfolio").click();
});

// Switch to evm domain
it("(evm) Whitelisted - should disable evm addresses in evm domain", () => {
// Go back to portfolio page to switch domain
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("domain_switch").click();

goToAddressBook();
cy.getByTestID("action_button_group").should("exist");
cy.getByTestID("send_balance_button").click().wait(3000);
cy.getByTestID("select_DFI").click().wait(3000);
cy.getByTestID("address_book_button").click();

cy.getByTestID("address_row_0_WHITELISTED").should(
"have.attr",
Expand All @@ -157,6 +159,7 @@ context("Portfolio - Send - Address Book", () => {
);
cy.getByTestID("address_row_1_WHITELISTED").should("not.be.disabled");
});

// Switch to your address tab
it("(evm) Your Address - should disable evm addresses in evm domain", () => {
cy.getByTestID("address_button_group_YOUR_ADDRESS").click();
Expand All @@ -165,25 +168,6 @@ context("Portfolio - Send - Address Book", () => {
});
});

// Addresses that shows up under the 'Your address' tab in address book
function populateYourAddresses(): void {
// Create new wallet address - only available if there is DFI UTXO
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("wallet_address").click();
cy.getByTestID("create_new_address").should("exist").click(); // Generate Address 2 wallet address

// Go back to previous Address 1
cy.getByTestID("wallet_address").click();
cy.getByTestID("address_row_0").click();
cy.getByTestID("wallet_address").should("have.text", "Address 1");
}
function goToAddressBook() {
cy.getByTestID("action_button_group").should("exist");
cy.getByTestID("send_balance_button").click().wait(3000);
cy.getByTestID("select_EvmDFI").click().wait(3000);
cy.getByTestID("address_book_button").click();
}

// Check if evm address is disabled in evm domain for generated Address 1 and 2 cards
function verifyYourAddressItemEvm() {
cy.wrap([0, 1]).each((index: number) => {
Expand All @@ -209,10 +193,12 @@ context("Portfolio", () => {

describe("Wallet label (& address book bottom sheet)", () => {
it('should display generated address label "Address 1" as first wallet label', () => {
cy.getByTestID("wallet_address").should("have.text", "Address 1");
cy.getByTestID("wallet_address")
.should("exist")
.should("have.text", "Address 1");
});
it("should display new wallet label after modifying wallet label", () => {
cy.getByTestID("wallet_address").click();
cy.getByTestID("wallet_address").should("exist").click();

// Go to edit address book bottom sheet
cy.getByTestID("address_edit_icon_address_row_0").click();
Expand All @@ -234,7 +220,7 @@ context("Portfolio", () => {
// Generate new wallet address
it("should display generated Address 2 label as second wallet label", () => {
cy.getByTestID("bottom_tab_portfolio").click();
cy.getByTestID("wallet_address").click();
cy.getByTestID("wallet_address").should("exist").click();

cy.getByTestID("create_new_address").should("exist").click(); // Generate Address 2 wallet address
cy.getByTestID("wallet_address").should("have.text", "Address 2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ context("Wallet - DEX - disabled pool pairs", () => {
cy.getByTestID("dex_action_button_composite_swap_button_26").should(
"have.css",
"opacity", // using opacity to check enable
"1"
"1",
); // status: true
cy.getByTestID("dex_action_button_composite_swap_button_28").should(
"have.css",
"opacity", // using opacity to check disable
"0.3"
"0.3",
); // status: false
});
});
Expand Down Expand Up @@ -134,7 +134,8 @@ context("Wallet - DEX - Instant/Future Swap - tabs and dropdowns", () => {
});

it("should be able to choose tokens to swap", () => {
cy.getByTestID("composite_swap").click();
cy.wait(1000);
cy.getByTestID("composite_swap").should("exist").click();
cy.wait(5000);
cy.getByTestID("token_select_button_FROM").click();
cy.getByTestID("select_DFI").click().wait(2000);
Expand All @@ -146,18 +147,18 @@ context("Wallet - DEX - Instant/Future Swap - tabs and dropdowns", () => {
cy.getByTestID("switch_button").click();
cy.getByTestID("token_select_button_FROM_display_symbol").should(
"have.text",
"dTU10"
"dTU10",
);
cy.getByTestID("token_select_button_TO_display_symbol").should(
"have.text",
"DFI"
"DFI",
);
});

it("should be able to disable future swap tab if tokenA and tokenB is not a valid future swap pair", () => {
cy.getByTestID("swap_tabs_FUTURE_SWAP").should(
"have.attr",
"aria-disabled"
"aria-disabled",
);

/* Only DUSD <-> Loan tokens are allowed in future swap */
Expand All @@ -167,19 +168,19 @@ context("Wallet - DEX - Instant/Future Swap - tabs and dropdowns", () => {
cy.getByTestID("select_dTU10").click();
cy.getByTestID("swap_tabs_FUTURE_SWAP").should(
"not.have.attr",
"aria-disabled"
"aria-disabled",
);
});

it("should be able to persist tokenA and tokenB when switching tabs", () => {
cy.getByTestID("swap_tabs_FUTURE_SWAP").click();
cy.getByTestID("token_select_button_FROM_display_symbol").should(
"have.text",
"DUSD"
"DUSD",
);
cy.getByTestID("token_select_button_TO_display_symbol").should(
"have.text",
"dTU10"
"dTU10",
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ context("Wallet - Send Preview/Confirmation", () => {
.invoke("text")
.should((t) => expect(t).equal("1.23400000"));
cy.getByTestID("wallet_address").should("exist");
cy.getByTestID("summary_to_value").should(
cy.getByTestID("address_input_footer").should(
"have.text",
"bcrt1q8rfsfny80jx78cmk4rsa069e2ckp6rn83u6ut9"
"bcrt1q8rfsfny80jx78cmk4rsa069e2ckp6rn83u6ut9",
);

cy.getByTestID("transaction_fee_label").should(
"have.text",
"Transaction fee"
"Transaction fee",
);
cy.getByTestID("transaction_fee_value").contains("DFI");

cy.getByTestID("text_amount_label").should("have.text", "Amount to send");
cy.getByTestID("text_amount").contains("1.23400000 dBTC");
cy.getByTestID("text_amount_rhsUsdAmount").should(
"have.text",
"$12,340.00"
"$12,340.00",
);
cy.getByTestID("button_confirm_send").should("not.have.attr", "disabled");
});
Expand Down
Loading

0 comments on commit 4f922f1

Please sign in to comment.