Skip to content

Commit

Permalink
Merge pull request #1854 from dedis/work-karate-4xiom5-final-ui-tests
Browse files Browse the repository at this point in the history
Karate UI Digital Cash Tests
  • Loading branch information
4xiom5 committed May 14, 2024
2 parents 16f42fc + 37705a7 commit 779775a
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const DigitalCashWallet = () => {
containerStyle={List.getListItemStyles(true, rollCallTokens.length === 0)}
style={List.getListItemStyles(true, rollCallTokens.length === 0)}
bottomDivider
testID="digital-cash-coin-issuance"
onPress={() => {
navigation.navigate(STRINGS.navigation_digital_cash_send_receive, {
isCoinbase: true,
Expand Down Expand Up @@ -82,6 +83,7 @@ const DigitalCashWallet = () => {
containerStyle={listStyle}
style={listStyle}
bottomDivider
testID={`digital-cash-roll-call-token-${idx}`}
onPress={() => {
navigation.navigate(STRINGS.navigation_digital_cash_send_receive, {
rollCallId: rollCallToken.rollCallId.valueOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ const SendReceive = () => {
onFocus={() => setBeneficiaryFocused(true)}
placeholder={STRINGS.digital_cash_wallet_beneficiary_placeholder}
isMonospaced
testID="digital-cash-send-beneficiary"
/>
)}
<Text style={[Typography.paragraph, Typography.important]}>
Expand All @@ -270,10 +271,14 @@ const SendReceive = () => {
value={amount}
onChange={setAmount}
placeholder={STRINGS.digital_cash_wallet_amount_placeholder}
testID="digital-cash-send-amount"
/>
</View>
{error !== '' && <Text style={[Typography.paragraph, Typography.error]}>{error}</Text>}
<PoPTextButton disabled={cannotSendTransaction} onPress={onSendTransaction}>
<PoPTextButton
disabled={cannotSendTransaction}
onPress={onSendTransaction}
testID="digital-cash-send-button">
{STRINGS.digital_cash_wallet_send_transaction}
</PoPTextButton>
</ScreenWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ exports[`SendReceive renders correctly 1`] = `
},
]
}
testID="digital-cash-send-beneficiary"
value=""
/>
</View>
Expand Down Expand Up @@ -574,6 +575,7 @@ exports[`SendReceive renders correctly 1`] = `
},
]
}
testID="digital-cash-send-amount"
value=""
/>
</View>
Expand All @@ -594,6 +596,7 @@ exports[`SendReceive renders correctly 1`] = `
"opacity": 1,
}
}
testID="digital-cash-send-button"
>
<View
style={
Expand Down Expand Up @@ -1123,6 +1126,7 @@ exports[`SendReceive renders correctly with passed scanned pop token 1`] = `
},
]
}
testID="digital-cash-send-beneficiary"
value="some pop token"
/>
</View>
Expand Down Expand Up @@ -1224,6 +1228,7 @@ exports[`SendReceive renders correctly with passed scanned pop token 1`] = `
},
]
}
testID="digital-cash-send-amount"
value=""
/>
</View>
Expand All @@ -1244,6 +1249,7 @@ exports[`SendReceive renders correctly with passed scanned pop token 1`] = `
"opacity": 1,
}
}
testID="digital-cash-send-button"
>
<View
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ exports[`DigitalCashWallet renders correctly for non-organizers 1`] = `
},
]
}
testID="digital-cash-roll-call-token-0"
>
<View
style={
Expand Down Expand Up @@ -1192,6 +1193,7 @@ exports[`DigitalCashWallet renders correctly for organizers 1`] = `
},
]
}
testID="digital-cash-coin-issuance"
>
<View
style={
Expand Down Expand Up @@ -1374,6 +1376,7 @@ exports[`DigitalCashWallet renders correctly for organizers 1`] = `
},
]
}
testID="digital-cash-roll-call-token-0"
>
<View
style={
Expand Down
44 changes: 44 additions & 0 deletions tests/karate/src/test/java/fe/features/digital_cash.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Feature: Digital Cash
Background:
* call read('classpath:fe/utils/constants.feature')
* call read(MOCK_CLIENT_FEATURE)

@name=digital_cash_page
Scenario:
Given def organizer = createMockClient()
And def lao = organizer.createLao()
And call read(PLATFORM_FEATURE) { name: '#(JOIN_ROLLCALL)', params: { lao: '#(lao)', organizer: '#(organizer)' } }
When call read(PLATFORM_FEATURE) { name: '#(SWITCH_TO_DIGITAL_CASH_PAGE)' }
Then assert exists(digital_cash_first_roll_call_button)
And screenshot()

@name=digital_cash_page_organizer
Scenario:
Given call read(PLATFORM_FEATURE) { name: '#(ORGANIZER_WITH_POP_TOKEN)' }
When call read(PLATFORM_FEATURE) { name: '#(SWITCH_TO_DIGITAL_CASH_PAGE)' }
Then assert exists(digital_cash_coin_issuance_button)
And screenshot()

@name=digital_cash_initial_issuance_one_address
Scenario:
Given call read(PLATFORM_FEATURE) { name: '#(ORGANIZER_WITH_POP_TOKEN)' }
And call read(PLATFORM_FEATURE) { name: '#(SWITCH_TO_DIGITAL_CASH_PAGE)' }
And waitFor(digital_cash_coin_issuance_button).click()
And def amount = '1337'
When waitFor(digital_cash_beneficiary_input).input(popToken)
And waitFor(digital_cash_amount_input).input(amount)
And screenshot()
And waitFor(digital_cash_send_button).click()
Then screenshot()

@name=digital_cash_initial_issuance_roll_call
Scenario:
Given call read(PLATFORM_FEATURE) { name: '#(ORGANIZER_WITH_POP_TOKEN)' }
And call read(PLATFORM_FEATURE) { name: '#(SWITCH_TO_DIGITAL_CASH_PAGE)' }
And waitFor(digital_cash_coin_issuance_button).click()
And def amount = '1337'
When selectOption(digital_cash_beneficiary_select, 1)
And waitFor(digital_cash_amount_input).input(amount)
And screenshot()
And waitFor(digital_cash_send_button).click()
Then screenshot()
3 changes: 3 additions & 0 deletions tests/karate/src/test/java/fe/utils/constants.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ Feature: Constants
# Event
* def CLICK_CREATE_ROLLCALL = 'click_rollcall_create'
* def JOIN_ROLLCALL = 'join_rollcall'
* def ORGANIZER_WITH_POP_TOKEN = 'organizer_with_pop_token'
* def SWITCH_TO_SOCIAL_PAGE = 'switch_to_social_page'
# Digital Cash
* def SWITCH_TO_DIGITAL_CASH_PAGE = 'switch_to_digital_cash_page'
34 changes: 33 additions & 1 deletion tests/karate/src/test/java/fe/utils/web.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: web page object
Background:
# Functions
* def actionSheetClick = (text) => script("setTimeout(() => document.evaluate('//div[text()=\\'" + text + "\\']', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click(), 1000)")

* def selectOption = (selector, option) => select(selector, option).script("_.dispatchEvent(new Event('change', {bubbles: true}))")
# Wallet screen
* def wallet_seed_wallet_text = "[data-testid='seed_wallet_text']"
* def wallet_new_wallet_button = "[data-testid='exploring_selector']"
Expand Down Expand Up @@ -33,6 +33,8 @@ Feature: web page object
* def event_rollcall_pop_token = "div[data-testid='roll_call_pop_token']"
* def event_rollcall_first_attendee = "div[data-testid='attendee_0']"
* def event_first_current_event = "[data-testid='current_event_selector_0']"
* def event_open_rollcall_button = "{}Open Roll-Call"
* def event_close_rollcall_button = "{}Close Roll-Call"

# Drawer menu
* def drawer_menu_button = "[data-testid='drawer_menu_button']"
Expand Down Expand Up @@ -62,6 +64,14 @@ Feature: web page object
* def social_chirp_love_count = "[data-testid='heart-count']"
* def social_chirp_delete = "[data-testid='delete_chirp']"

# Digital Cash screen
* def digital_cash_coin_issuance_button = "[data-testid='digital-cash-coin-issuance']"
* def digital_cash_first_roll_call_button = "[data-testid='digital-cash-roll-call-token-0']"
* def digital_cash_amount_input = "input[data-testid='digital-cash-send-amount']"
* def digital_cash_beneficiary_input = "input[data-testid='digital-cash-send-beneficiary']"
* def digital_cash_beneficiary_select = "select"
* def digital_cash_send_button = "{}Send Transaction"

@name=open_app
Scenario:
Given driver webDriverOptions
Expand Down Expand Up @@ -120,8 +130,30 @@ Feature: web page object
And organizer.closeRollCall(lao, rollCall, [popToken, organizer.publicKey])
And delay(1000)

@name=organizer_with_pop_token
Scenario:
Given call read(PLATFORM_FEATURE) { name: '#(CREATE_LAO)', params: { organization_name: 'Join roll call' } }
And def rollCallName = 'My Roll-Call'
When waitFor(event_create_button).click()
And call read(PLATFORM_FEATURE) { name: '#(CLICK_CREATE_ROLLCALL)' }
And waitFor(event_rollcall_name_input).input(rollCallName)
And waitFor(event_rollcall_location_input).input('Between 1 and 0s')
And waitFor(event_rollcall_confirm_button).click()
Then waitForText(event_first_current_event, rollCallName)
When waitFor(event_first_current_event).click()
And waitFor(event_open_rollcall_button).click()
And delay(500)
And def popToken = text(event_rollcall_first_attendee)
And waitFor(event_close_rollcall_button).click()

@name=switch_to_social_page
Scenario:
Given waitFor(drawer_menu_button).click()
And waitFor(drawer_menu_social).click()
And delay(500)

@name=switch_to_digital_cash_page
Scenario:
Given waitFor(drawer_menu_button).click()
And waitFor(drawer_menu_digital_cash).click()
And delay(500)
2 changes: 2 additions & 0 deletions tests/karate/src/test/java/karate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function fn() {
config.webDriverOptions = {
webDriverSession: {
capabilities,
// desiredCapabilities is there for compatibility with karate
desiredCapabilities: {}
}
};
Expand All @@ -114,6 +115,7 @@ function fn() {
'appium:avd': karate.properties['avd'],
}
},
// desiredCapabilities is there for compatibility with karate
desiredCapabilities: {
}
}
Expand Down

0 comments on commit 779775a

Please sign in to comment.