ArboreumDev / credit-union-frontend

Frontend in Next.js + Typescript + GraphQL
https://frontend-two-sandy.vercel.app
1 stars 0 forks source link

Test scenarios #135

Closed gparuthi closed 3 years ago

gparuthi commented 3 years ago

Purpose of scenarios:

  1. Keep a trail of actions performed so we can recreate incidents.
  2. Write multi-user, multi-action scenario for testing purposes. The goal of it would be to do more than what a unit-test can do.

I simplified the scenario to the extent that made sense to me. Reduced redundant code, and simple loan request that is needed by DBClient

gparuthi commented 3 years ago

@djudjuu With the simple scenario, the repayment is throwing an error from swarmai that I am not sure how to resolve.

request

{"system_state":{"users":{"3576df66-ef1c-4e82-ad21-70943dcecaf2":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf2","balance":10000,"name":"l2","email":"lender2@mail.com","user_type":"lender","demographic_info":{"income":null,"credit_score":null,"education_years":null},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0},"3576df66-ef1c-4e82-ad21-70943dcecaf3":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf3","balance":10000,"name":"l3","email":"lender3@mail.com","user_type":"lender","demographic_info":{"income":null,"credit_score":null,"education_years":null},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0},"3576df66-ef1c-4e82-ad21-70943dcecaf4":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf4","balance":10000,"name":"l4","email":"lender4@mail.com","user_type":"lender","demographic_info":{"income":null,"credit_score":null,"education_years":null},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0},"3576df66-ef1c-4e82-ad21-70943dcecaf5":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf5","balance":0,"name":"l5","email":"lender5@mail.com","user_type":"lender","demographic_info":{"income":null,"credit_score":null,"education_years":null},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0},"3576df66-ef1c-4e82-ad21-70943dcecaf6":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf6","balance":0,"name":"b1","email":"borrower1@mail.com","user_type":"borrower","demographic_info":{"income":48000,"credit_score":842,"education_years":18},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0},"3576df66-ef1c-4e82-ad21-70943dcecaf7":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf7","balance":0,"name":"b2","email":"borrower2@mail.com","user_type":"borrower","demographic_info":{"income":8000,"credit_score":599,"education_years":8},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0},"3576df66-ef1c-4e82-ad21-70943dcecaf1":{"id":"3576df66-ef1c-4e82-ad21-70943dcecaf1","balance":20000,"name":"l1","email":"lender1@mail.com","user_type":"lender","demographic_info":{"income":null,"credit_score":null,"education_years":null},"corpus_share":0,"encumbered_cash":0,"encumbered_portfolio":0}},"loans":{},"loan_requests":{"41a6d3e7-56cc-4255-a138-8babbe079b63":{"terms":{"tenor":6,"amount":20000,"request_id":"41a6d3e7-56cc-4255-a138-8babbe079b63","supporters":[{"apr_delta":1.1,"supporter_id":"3576df66-ef1c-4e82-ad21-70943dcecaf4","trust_amount":4000,"demographic_info":null,"recommendation_risk":{"beta_params":[5,2],"kumr_params":[4,5]}}],"borrower_info":{"borrower_id":"3576df66-ef1c-4e82-ad21-70943dcecaf6","demographic_info":{"income":48000,"credit_score":842,"education_years":18}},"borrower_collateral":0,"num_annual_cmpnd_prds":12},"request_id":"41a6d3e7-56cc-4255-a138-8babbe079b63","risk_params":null}},"loan_offers":{"41a6d3e7-56cc-4255-a138-8babbe079b63":{"state":{"repayments":[],"request_id":"41a6d3e7-56cc-4255-a138-8babbe079b63","borrower_collateral":0,"supporter_cash_encumbered":0,"supporter_portfolio_encumbered":0},"terms":{"tenor":6,"amount":20000,"corpus_apr":0.113151,"request_id":"41a6d3e7-56cc-4255-a138-8babbe079b63","supporters":[{"apr_delta":1.1,"supporter_id":"3576df66-ef1c-4e82-ad21-70943dcecaf4","trust_amount":4000,"demographic_info":null,"recommendation_risk":{"beta_params":[5,2],"kumr_params":[4,5]}}],"penalty_apr":0.055,"borrower_apr":0.112676,"corpus_share":0.8,"borrower_info":{"borrower_id":"3576df66-ef1c-4e82-ad21-70943dcecaf6","demographic_info":{"income":48000,"credit_score":842,"education_years":18}},"supporter_apr":0.112201,"supporter_lag":1,"supporter_share":0.2,"borrower_collateral":0,"num_annual_cmpnd_prds":12},"schedule":{"request_id":"41a6d3e7-56cc-4255-a138-8babbe079b63","corpus_view":null,"borrower_view":{"total_payments":{"paid":0,"remain":20664.083826},"corpus_interest":{"paid":0,"remain":532.167505},"corpus_principal":{"paid":0,"remain":16000},"supporter_interest":{"paid":0,"remain":131.91632},"borrower_collateral":{"paid":0,"remain":0},"supporter_principal":{"paid":0,"remain":4000}},"supporter_view":null,"next_borrower_payment":3444.013971},"request_id":"41a6d3e7-56cc-4255-a138-8babbe079b63"}}},"loan_id":"41a6d3e7-56cc-4255-a138-8babbe079b63","amount":5000}

response

  console.log
    /loan/repay -- res -- ```{"status":"error","message":"The server responded with an unexpected status.","data":{"detail":"Unknown loan / request id: 61a5f997-4a82-4cf9-acc4-6ec2c22c0f0c"}}```
gparuthi commented 3 years ago

Got it. I will add the confirm loan offer action next

gparuthi commented 3 years ago

@djudjuu There still an error when accepting that I am unsure on how to resolve. Looks like the system state doesn't contain the loan_request object? Can you check?

gparuthi commented 3 years ago

Tested UI interactions. Merging now.