tiki-archive / apps-receipt-capacitor

https://receipt-capacitor.mytiki.com/
MIT License
2 stars 0 forks source link

Write test scenarios for Vue/TS #125

Closed ricardobrg closed 1 year ago

ricardobrg commented 1 year ago

As a maintainer I need to ensure that the code is well tested so that we can prevent any changes that might lead to new bugs

What is it now

The tests are outdated and insufficient

What it should be

All public methods should have tests. To achieve that we need a test plan that will tell what to test and how to.

Technical details

Use TIKI SDK Android as a sample of how to implement tests.

Acceptance criteria

A list of tests with input and output and the issues to implement it.

MiroBenicio commented 1 year ago

Receipt-service.ts

scan method:

— input: 
        scantype: ScanType | undefined
    account?: ReceiptAccount
— output: 
    Promise<void>

login:

— input:
    account: ReceiptAccount
— output:
    Promise<void>

logout:

— input:
    account: ReceiptAccount | undefined
— output:
    Promise<void>

loadAccount

— input:
    void
— output:
    Promise<void>

addAccount:

— input:
    account: ReceiptAccount
— output:
    void

removeAccount:

— input:
    account: ReceiptAccount
— output:
    void

addReceipt:

— input:
    receipt: TikiReceiptCapture.Receipt
    account?: TikiReceiptCapture.Account
— output:
    Promise<void>

process:

— input:
    event: ReceiptEvent
    details: { receipt: TikiReceiptCapture.Receipt, account: ReceiptAccount}
— output:
    Promise<void>

history-service.ts

load:

— input:
    void
— output:
    promise<void>

add:

— input:
    event: HistoryEvent
— output:
    void

redeem:

— input:    
    void
— output
    Promise<void>

clear:

— input:
    void
— output:
    void

tiki-service.ts

initialize:

— input:
    id: string
— output: 
    Promise<void>

logout:

— input:
    void
— output:
    Promise<void>

receipt-capture.ts in tiki-capture-receipt-capacitor

initialize:

— input:
    licenseKey: string
    productKey?: string
— output
    Promise<void>

scan:

— input:
    scanType: scanType | undefined
    account?: Account
— output:
    Promise<{
        receipt: Receipt,
        isRunning: boolean
                     account: Account}

loginWithEmail:

— input:
    username: string
    password: string
    provider: string
— output
    Promise<Account>

removeEmail:

— input:
    username: string
    password: string
    provider: string
— output
    Promise<void>

loginWithRetailer:

— input:
    username: string
    password: string
    provider: string
— output
    Promise<Account>

accounts:

— input:
    void
— output:
    Promise<Account[]>

removeRetailer:

— input
    username: string
    provider: string
— output
    Promise<Account>

flushEmail && flushRetailer

— input
    void
— output 
    void
ricardobrg commented 1 year ago

exemplo

ricardobrg commented 1 year ago

Scan method in receiot-service.ts

/**

MiroBenicio commented 1 year ago

login method in receipt-service.ts

MiroBenicio commented 1 year ago

logout method in receipt-service.ts

mocks

MiroBenicio commented 1 year ago

accounts method in receipt-service.ts

mocks

MiroBenicio commented 1 year ago

addReceipt in receipt-service

caso com receipt duplicado e não fraudulento caso com receipt não duplicado e fraudulento caso com receipt duplicado e fraudulento caso com receipt nao duplicado e nao fraudulento

-mocks this.tiki.sdk.ingest()

MiroBenicio commented 1 year ago

process in receipt-service

amount undefined amount não undefined

mock

MiroBenicio commented 1 year ago

load in history-service.ts

caso de event undefined

mocks

MiroBenicio commented 1 year ago

add in history-service.ts

caso event.type igual REDEEM caso event.type diferente REDEEM

MiroBenicio commented 1 year ago

redeem in history-service.ts

caso com a callback undefined caso com points undefined

mocks: this.tiki.sdk.createReceipt