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

Feature/270-payment-request-improvements #535

Merged
merged 25 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fb04bf8
Refactor payment request components and remove unused avatar function…
etsraphael Sep 21, 2024
3a857b6
Refactor payment request interfaces and update component bindings
etsraphael Sep 21, 2024
59b5263
Remove unused payment page and card styles, along with related tests …
etsraphael Sep 21, 2024
c233ff8
Remove unused profile properties and related selectors from payment r…
etsraphael Sep 21, 2024
eb1e45f
Refactor payment request state and interfaces to unify request detail…
etsraphael Sep 22, 2024
6e5ed35
Refactor payment request component to use unified request detail sele…
etsraphael Sep 23, 2024
918ab8f
Add payment setup logic in PayNowPage and rename payment effect
etsraphael Sep 23, 2024
d1afa05
Implement payment type switching and update transaction handling for …
etsraphael Sep 23, 2024
754c202
Enhance payment type handling and conversion display in PayNowPage
etsraphael Sep 24, 2024
cb935d8
Update payment request handling to use unified result property and en…
etsraphael Sep 24, 2024
2799d26
Refactor PayNowPage component for improved readability and maintainab…
etsraphael Sep 25, 2024
ad13f0a
Refactor PayNowPage component imports and clean up unused payment req…
etsraphael Sep 25, 2024
39f0fbd
Refactor PayNowPage component to update lockInUSD logic and streamlin…
etsraphael Sep 25, 2024
61a2b53
Refactor error handling in TokensService and WalletService; enhance e…
etsraphael Sep 25, 2024
43ddf9d
Enhance error code extraction in WalletService; improve handling of n…
etsraphael Sep 25, 2024
0476eff
Refactor error handling in TokenSetupService and WalletService; enhan…
etsraphael Sep 27, 2024
75d8776
Refactor PaymentRequest components; remove protocol fee display and s…
etsraphael Sep 27, 2024
6b0db51
Update PayNowPage to handle undefined token symbol and set payment ty…
etsraphael Sep 27, 2024
1f0b6d2
Update PayNowPage to improve amount handling and apply token conversi…
etsraphael Sep 27, 2024
409c1df
Refactor PayNowPage to use ITokenContract for network support and upd…
etsraphael Sep 27, 2024
f0e2811
Remove unused form controls and protocol fee calculations in payment …
etsraphael Sep 27, 2024
6e14e08
Enhance test setup for TokensService and TokenSetupService by adding …
etsraphael Sep 27, 2024
e2b9005
Refactor payment request tests to use 'name' instead of 'username' an…
etsraphael Sep 27, 2024
f286ceb
Refactor PayNowPage to streamline amount handling and enhance token c…
etsraphael Sep 27, 2024
fe58131
Add dynamic amount title to PayNowPage for improved currency display
etsraphael Sep 27, 2024
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
109 changes: 29 additions & 80 deletions UI/cypress/e2e/use-case/payment/payment-generated.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ describe('Check native payment generated', () => {
const paymentRequest: IPaymentRequest = {
chainId: NetworkChainId.SEPOLIA,
tokenId: TokenId.SEPOLIA,
username: 'John Doe',
name: 'John Doe',
publicAddress: '0xd288b9f2028cea98f3132b700fa45c95023eca24',
amount: 1,
description: 'A simple description',
avatarUrl: '',
usdEnabled: false
};

Expand All @@ -38,58 +36,27 @@ describe('Check native payment generated', () => {
.replace('+', '-')
.replace('/', '_');

beforeEach(() => {
cy.viewport('iphone-x');
});

it('Generate payment without wallet', () => {
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);
cy.get('[data-id=recipient-username-id]').should('have.text', paymentRequest.username);
cy.get('[data-id=recipient-description-id]').contains(paymentRequest.description);
cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible');
cy.visit(`${Cypress.env('baseUrl')}/pay-now/${paymentRequestBase64}`);
cy.get('[data-id=pn-header-container] h3').should('have.text', paymentRequest.name);
cy.get('[data-id=action-btn]').should('have.text', 'Connect Wallet');
cy.get('[data-id=payment-type-container]').contains('Amount (in SEP)');
});

it('Generate payment with wallet and wrong network', () => {
// before
const WALLET_ADDRESS = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
const SIGNED_MESSAGE = '...';
cy.login(WALLET_ADDRESS, SIGNED_MESSAGE, NetworkChainId.POLYGON);
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);
cy.visit(`${Cypress.env('baseUrl')}/pay-now/${paymentRequestBase64}`);

// test
cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible').click();
cy.get('lib-web3-login lib-card-body-login [data-id="wallet-container-btn-metamask"]').click();
cy.get('app-payment-page [data-id="wrong-network-alert"]').should('be.visible').contains('Wrong network');
});

it('Generate payment with wallet and right network', () => {
const WALLET_ADDRESS = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
const SIGNED_MESSAGE = '...';

// Inject MetaMask
cy.login(WALLET_ADDRESS, SIGNED_MESSAGE, NetworkChainId.SEPOLIA);
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);

cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible').click();
cy.get('lib-web3-login lib-card-body-login [data-id="wallet-container-btn-metamask"]').click();
cy.get('app-payment-request-card [data-id="login-btn"]').should('not.exist');

cy.get('app-payment-request-card [data-id="btn-confirm-transaction"]').should('be.visible');

cy.get('app-payment-request-card [data-id="btn-confirm-transaction"]')
.find('button[type="submit"]')
.should('not.have.attr', 'disabled');
});

it('Generate payment receiver of the transaction', () => {
const WALLET_ADDRESS = paymentRequest.publicAddress;
const SIGNED_MESSAGE = '...';

// Inject MetaMask
cy.login(WALLET_ADDRESS, SIGNED_MESSAGE, NetworkChainId.SEPOLIA);
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);
cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible').click();
cy.get('lib-web3-login lib-card-body-login [data-id="wallet-container-btn-metamask"]').click();

cy.get('app-payment-page [data-id="warning-banner"]')
.should('be.visible')
.contains('Attention: This is a preview of your request. Avoid the mistake of self-payment.');
cy.get('[data-id=action-btn]').should('have.text', 'Pay Now');
cy.get('[data-id=action-btn]').click();
});
});

Expand All @@ -99,11 +66,9 @@ describe('Check native payment generated with USD enabled', () => {
const paymentRequest: IPaymentRequest = {
chainId: NetworkChainId.POLYGON,
tokenId: TokenId.ETHEREUM,
username: 'John Doe',
name: 'John Doe',
publicAddress: '0xd288b9f2028cea98f3132b700fa45c95023eca24',
amount: 1000,
description: 'A simple transaction',
avatarUrl: '',
usdEnabled: true
};

Expand All @@ -115,15 +80,15 @@ describe('Check native payment generated with USD enabled', () => {
.replace('+', '-')
.replace('/', '_');

beforeEach(() => {
cy.viewport('iphone-x');
});

it('Generate payment without wallet', () => {
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);
cy.get('[data-id=recipient-username-id]').should('have.text', paymentRequest.username);
cy.get('[data-id=recipient-description-id]').contains(paymentRequest.description);
cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible');

cy.get('[data-id=mathing-amount-message]').contains(
`${paymentRequest.username} is requesting a sum equivalent to $${paymentRequest.amount} USD.`
);
cy.visit(`${Cypress.env('baseUrl')}/pay-now/${paymentRequestBase64}`);
cy.get('[data-id=pn-header-container] h3').should('have.text', paymentRequest.name);
cy.get('[data-id=payment-type-container]').contains('Amount (in USD)');
cy.get('[data-id=action-btn]').should('have.text', 'Connect Wallet');
});
});

Expand All @@ -133,11 +98,9 @@ describe('Check non-native payment generated', () => {
const paymentRequest: IPaymentRequest = {
chainId: NetworkChainId.POLYGON,
tokenId: 'chainlink',
username: 'John Doe',
name: 'John Doe',
publicAddress: '0xd288b9f2028cea98f3132b700fa45c95023eca24',
amount: 1,
description: 'A simple transaction',
avatarUrl: '',
usdEnabled: false
};

Expand All @@ -149,29 +112,15 @@ describe('Check non-native payment generated', () => {
.replace('+', '-')
.replace('/', '_');

it('Generate payment without wallet', () => {
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);
cy.get('[data-id=recipient-username-id]').should('have.text', paymentRequest.username);
cy.get('[data-id=recipient-description-id]').contains(paymentRequest.description);
cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible');
beforeEach(() => {
cy.viewport('iphone-x');
});

it('Generate payment with wallet and right network', () => {
const WALLET_ADDRESS = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
const SIGNED_MESSAGE = '...';

// Inject MetaMask
cy.login(WALLET_ADDRESS, SIGNED_MESSAGE, NetworkChainId.POLYGON);
cy.visit(`${Cypress.env('baseUrl')}/payment-page/${paymentRequestBase64}`);

cy.get('app-payment-request-card [data-id="login-btn"]').should('be.visible').click();
cy.get('lib-web3-login lib-card-body-login [data-id="wallet-container-btn-metamask"]').click();
cy.get('app-payment-request-card [data-id="login-btn"]').should('not.exist');

cy.get('app-payment-request-card [data-id="btn-confirm-transaction"]').should('be.visible');
it('Generate payment without wallet', () => {
cy.visit(`${Cypress.env('baseUrl')}/pay-now/${paymentRequestBase64}`);

cy.get('app-payment-request-card [data-id="btn-confirm-transaction"]')
.find('button[type="submit"]')
.should('have.attr', 'disabled');
cy.get('[data-id=pn-header-container] h3').should('have.text', paymentRequest.name);
cy.get('[data-id=action-btn]').should('have.text', 'Connect Wallet');
cy.get('[data-id=payment-type-container]').contains('Amount (in LINK)');
});
});
16 changes: 0 additions & 16 deletions UI/cypress/e2e/use-case/payment/payment-maker.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ describe('Create a payment request with wallet', () => {
// Complete profile information
cy.get('app-payment-request-profile-settings [data-id="username-input"]').type('My Username');
cy.get('app-payment-request-profile-settings [data-id="submit-button"]').click();

// Complete description
cy.get('app-payment-request-price-settings [data-id="description-input"]')
.should('be.visible')
.should('be.enabled')
.focus()
.type('This is my payment request description');

cy.get('app-payment-request-price-settings [data-id="submit-button"]').click();
});
});
Expand All @@ -40,14 +32,6 @@ describe('Create a payment request without wallet', () => {

// Complete description
cy.get('app-payment-request-price-settings').contains('A connected wallet is required for conversion rates');
cy.get('app-payment-request-price-settings [data-id="description-input"]').should('be.visible');
cy.get('app-payment-request-price-settings [data-id="description-input"]').should('be.enabled');

cy.get('app-payment-request-price-settings [data-id="description-input"]')
.should('be.visible')
.should('be.enabled')
.focus()
.type('This is my payment request description');
cy.get('app-payment-request-price-settings [data-id="submit-button"]').click();
});
});
11 changes: 8 additions & 3 deletions UI/cypress/e2e/use-case/payment/shop-payment-generated.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/// <reference types="cypress" />

import '@angular/compiler';
import { IPaymentRequestRaw } from '../../../../src/app/shared/interfaces';
import { IPaymentRequest } from '../../../../src/app/shared/interfaces';
import { NetworkChainId } from '@chainbrary/web3-login';

class MockPaymentService {
removeEmptyStringProperties<T>(obj: T): T {
Expand All @@ -18,9 +19,13 @@ class MockPaymentService {
describe('Check native payment generated', () => {
const formatService = new MockPaymentService();

const paymentRequest: IPaymentRequestRaw = {
const paymentRequest: IPaymentRequest = {
publicAddress: '0xbA3Fc0648186a79baEF8DCeE9e055873F432a351',
name: 'John Doe'
name: 'John Doe',
chainId: NetworkChainId.ETHEREUM,
tokenId: null,
amount: null,
usdEnabled: false
};

const paymentRequestBase64: string = Buffer.from(
Expand Down
Loading
Loading