Add Subscription and update test case of payment screen

This commit is contained in:
osamacis 2022-12-01 20:27:07 +05:30
parent 255cffd061
commit 3fb6adad9b
No known key found for this signature in database
GPG Key ID: 15F978BEFADAB9E1
11 changed files with 201 additions and 103 deletions

View File

@ -79,7 +79,8 @@ if __name__ == "__main__":
'translations/*.ts', 'translations/*.qm', 'default.ini', 'sql/*.sql', 'translations/*.ts', 'translations/*.qm', 'default.ini', 'sql/*.sql',
'images/*.png', 'images/*.ico', 'images/*.icns', 'images/*.png', 'images/*.ico', 'images/*.icns',
'bitmessagekivy/main.kv', 'bitmessagekivy/screens_data.json', 'bitmessagekivy/main.kv', 'bitmessagekivy/screens_data.json',
'bitmessagekivy/kv/*.kv' 'bitmessagekivy/kv/*.kv', 'images/kivy/payment/*.png', 'images/kivy/*.gif',
'images/kivy/text_images*.png'
]} ]}
if sys.version_info[0] == 3: if sys.version_info[0] == 3:

View File

@ -1,71 +1,144 @@
#:import get_color_from_hex kivy.utils.get_color_from_hex
<Payment>: <Payment>:
name: "payment" name: "payment"
BoxLayout: id: id_payment_screen
ScrollView: payment_plan_id: ""
bar_width:0 MDTabs:
do_scroll_x: False id: tab_panel
#scroll_y:0 tab_display_mode:'text'
Tab:
title: app.tr._("Payment")
id: id_payment plan
padding: "12dp"
spacing: "12dp"
BoxLayout: BoxLayout:
spacing: dp(8) ScrollView:
padding: dp(5) bar_width:0
size_hint_y: None do_scroll_x: False
height: self.minimum_height BoxLayout:
orientation: "vertical" spacing: dp(5)
padding: dp(5)
ProductCategoryLayout: size_hint_y: None
category_text: "Monthly-Subscriptions" height: self.minimum_height
orientation: "vertical"
ProductLayout: ProductCategoryLayout:
heading_text: "Gas (Play Billing Codelab)" MDCard:
price_text: "$0.99" orientation: "vertical"
source: app.image_path + "/payment/buynew1.png" padding: "8dp"
description_text: "Buy gasoline to ride!" spacing: "12dp"
product_id: "SKUGASBILLING" size_hint: None, None
size: "560dp", "40dp"
ProductLayout: pos_hint: {"center_x": .5, "center_y": .5}
heading_text: "Upgrade your car (Play Billing Codelab)" MDLabel:
price_text: "$1.49" text: f"You have {app.encrypted_messages_per_month} messages left"
source: app.image_path + "/payment/buynew1.png" bold: True
description_text: "Buy a premium outfit for your car!" halign:'center'
product_id: "SKUUPGRADECAR" size_hint_y: None
pos_hint: {"center_x": .5, "center_y": .5}
ProductLayout:
heading_text: "Month in gold status (Play Billing Codelab)"
price_text: "$0.99"
source: app.image_path + "/payment/buynew1.png"
description_text: "Enjoy a gold status for a month!"
product_id: "SKUMONTHLYGOLD"
ProductCategoryLayout:
category_text: "One-time payment"
ProductLayout:
heading_text: "Gas (Play Billing Codelab)"
price_text: "$0.99"
source: app.image_path + "/payment/buynew1.png"
description_text: "Buy gasoline to ride!"
product_id: "SKUONETIMEGAS"
ProductCategoryLayout:
category_text: "Annual-Subscriptions"
ProductLayout:
heading_text: "Gas (Play Billing Codelab)"
price_text: "$0.99"
source: app.image_path + "/payment/buynew1.png"
description_text: "Buy gasoline to ride!"
product_id: "SKUANNUALGAS"
ProductLayout:
heading_text: "Year in gold status (Play Billing Codelab)"
price_text: "$10.99"
source: app.image_path + "/payment/buynew1.png"
description_text: "Enjoy a gold status for a year!"
product_id: "SKUANNUALGOLD"
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "12dp"
size_hint: None, None
size: "560dp", "300dp"
md_bg_color: [1, 0.6, 0,0.5]
pos_hint: {"center_x": .5, "center_y": .5}
MDLabel:
text: "Free"
bold: True
halign:'center'
size_hint_y: None
pos_hint: {"center_x": .5, "center_y": .5}
MDRectangleFlatIconButton:
text: "[Currently this plan is active.]"
icon: 'shield-check'
line_color: 0, 0, 0, 0
text_color: 'ffffff'
pos_hint: {"center_x": .5, "center_y": .5}
font_size: '18sp'
MDSeparator:
height: "1dp"
MDLabel:
text: "You can get zero encrypted message per month"
halign:'center'
bold: True
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "12dp"
size_hint: None, None
size: "560dp", "300dp"
md_bg_color: [0, 0.6, 0.8,0.8]
pos_hint: {"center_x": .5, "center_y": .5}
payment_plan_id: "sub_standard"
MDLabel:
text: "Standard"
bold: True
halign:'center'
size_hint_y: None
MDSeparator:
height: "1dp"
MDLabel:
text: "You can get 100 encrypted message per month"
halign:'center'
MDRaisedButton:
text: "Get it now"
theme_text_color: 'Primary'
md_bg_color: [1, 1, 1,1]
pos_hint: {'center_x': .5}
on_release:app.open_payment_layout(root.payment_plan_id)
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "12dp"
size_hint: None, None
size: "560dp", "300dp"
md_bg_color: [1, 0.6, 0.8,0.5]
pos_hint: {"center_x": .5, "center_y": .5}
payment_plan_id: "sub_premium"
MDLabel:
text: "Premium"
bold: True
halign:'center'
size_hint_y: None
MDSeparator:
height: "1dp"
MDLabel:
text: "You can get 1000 encrypted message per month"
halign:'center'
MDRaisedButton:
text: "Get it now"
theme_text_color: 'Primary'
md_bg_color: [1, 1, 1,1]
pos_hint: {'center_x': .5}
on_release:app.open_payment_layout(root.payment_plan_id)
Tab:
title: app.tr._("Extra-Messages")
id: id_payment_tab
BoxLayout:
ScrollView:
bar_width:0
do_scroll_x: False
BoxLayout:
spacing: dp(8)
padding: dp(5)
size_hint_y: None
height: self.minimum_height
orientation: "vertical"
ProductCategoryLayout:
category_text: "Extra-Messages"
ProductLayout:
heading_text: "100 Encrypted messages "
price_text: "$0.99"
source: app.image_path + "/payment/buynew1.png"
description_text: "Buy extra one hundred encrypted messages!"
product_id: "SKUGASBILLING"
ProductLayout:
heading_text: "1000 Encrypted messages "
price_text: "$1.49"
source: app.image_path + "/payment/buynew1.png"
description_text: "Buy extra one thousand encrypted messages!"
product_id: "SKUUPGRADECAR"
<ProductCategoryLayout@BoxLayout>: <ProductCategoryLayout@BoxLayout>:
size_hint_y: None size_hint_y: None
height: self.minimum_height height: self.minimum_height
@ -94,7 +167,6 @@
MDLabel: MDLabel:
text: root.text_ text: root.text_
font_size: sp(15) font_size: sp(15)
<ProductLayout>: <ProductLayout>:
heading_text: "" heading_text: ""
price_text: "" price_text: ""
@ -117,7 +189,6 @@
#heading area #heading area
BoxLayout: BoxLayout:
size_hint_y: 0.3 size_hint_y: 0.3
#text heading #text heading
BoxLayout: BoxLayout:
Widget: Widget:
@ -169,7 +240,6 @@
MDLabel: MDLabel:
text: root.description_text text: root.description_text
font_size: sp(15) font_size: sp(15)
#Button Area #Button Area
BoxLayout: BoxLayout:
size_hint_y: 0.4 size_hint_y: 0.4
@ -201,7 +271,7 @@
RightLabel: RightLabel:
text: root.right_label_text text: root.right_label_text
theme_text_color: "Custom" theme_text_color: "Custom"
text_color: 0,0,0,.4 text_color: 0,0,0,0.5
font_size: sp(12) font_size: sp(12)
<PaymentMethodLayout>: <PaymentMethodLayout>:
@ -239,15 +309,17 @@
ListItemWithLabel: ListItemWithLabel:
source: app.image_path + "/payment/btc.png" source: app.image_path + "/payment/btc.png"
text: "BTC" text: "BTC (Currently this feature is not available)"
method_name: "btc" method_name: "btc"
theme_text_color: 'Secondary'
md_bg_color: [0, 0, 0,1]
ListItemWithLabel: ListItemWithLabel:
source: app.image_path + "/payment/paypal.png" source: app.image_path + "/payment/paypal.png"
text: "Paypal" text: "Paypal (Currently this feature is not available)"
method_name: "som" method_name: "som"
theme_text_color: 'Secondary'
md_bg_color: [0, 0, 0,1]
ListItemWithLabel: ListItemWithLabel:
source: app.image_path + "/payment/buy.png" source: app.image_path + "/payment/buy.png"
text: "One more method" text: "One more method"
method_name: "omm" method_name: "omm"

View File

@ -185,7 +185,7 @@
on_release: app.root.ids.scr_mngr.current = 'set' on_release: app.root.ids.scr_mngr.current = 'set'
on_release: root.parent.set_state() on_release: root.parent.set_state()
NavigationItem: NavigationItem:
text: app.tr._('Purchase') text: app.tr._('Payment plan')
icon: 'shopping' icon: 'shopping'
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'payment' on_release: app.root.ids.scr_mngr.current = 'payment'

View File

@ -45,7 +45,7 @@ from pybitmessage.bitmessagekivy.baseclass.popup import (
from pybitmessage.bitmessagekivy.baseclass.login import * # noqa: F401, F403 from pybitmessage.bitmessagekivy.baseclass.login import * # noqa: F401, F403
from pybitmessage.bitmessagekivy.uikivysignaler import UIkivySignaler from pybitmessage.bitmessagekivy.uikivysignaler import UIkivySignaler
from pybitmessage.mock.helper_startup import loadConfig from pybitmessage.mock.helper_startup import loadConfig, total_encrypted_messages_per_month
logger = logging.getLogger('default') logger = logging.getLogger('default')
@ -93,6 +93,7 @@ class NavigateApp(MDApp):
identity_list = get_identity_list() identity_list = get_identity_list()
image_path = load_image_path() image_path = load_image_path()
app_platform = platform app_platform = platform
encrypted_messages_per_month = total_encrypted_messages_per_month()
tr = Lang("en") # for changing in franch replace en with fr tr = Lang("en") # for changing in franch replace en with fr
def __init__(self): def __init__(self):

View File

@ -1,14 +1,13 @@
from .telenium_process import TeleniumTestProcess from .telenium_process import TeleniumTestProcess
from .common import skip_screen_checks
from .common import ordered from .common import ordered
class PaymentScreen(TeleniumTestProcess): class PaymentScreen(TeleniumTestProcess):
"""SubscriptionPayment Screen Functionality Testing""" """Payment Plan Screen Functionality Testing"""
@ordered @ordered
def test_select_subscription(self): def test_select_payment_plan(self):
"""Select Subscription From List of Subscriptions""" """Select Payment plan From List of payments"""
# This is for checking Current screen # This is for checking Current screen
self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox') self.assert_wait_no_except('//ScreenManager[@current]', timeout=15, value='inbox')
# Method to open the side navbar # Method to open the side navbar
@ -18,35 +17,54 @@ class PaymentScreen(TeleniumTestProcess):
# assert for checking scroll function # assert for checking scroll function
self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=10) self.assertCheckScrollDown('//ContentNavigationDrawer//ScrollView[0]', timeout=10)
# this is for opening Payment screen # this is for opening Payment screen
self.cli.wait_click('//NavigationItem[@text=\"Purchase\"]', timeout=5) self.cli.wait_click('//NavigationItem[@text=\"Payment plan\"]', timeout=5)
# Checking the navbar is in closed state # Checking the navbar is in closed state
self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5) self.assertExists('//MDNavigationDrawer[@status~=\"closed\"]', timeout=5)
# Assert for checking Current Screen # Assert for checking Current Screen
self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=5) self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=5)
# Scrolling Down Product list # Checking state of Current tab Payment plan
self.assertExists(
'//Payment/MDTabs[0]//MDTabsLabel[@text=\"Payment\"][@state=\"down\"]', timeout=5
)
# Scrolling Down Payment plan Cards
self.drag( self.drag(
'//ProductCategoryLayout[0]/ProductLayout[0]', '//Payment//MDTabs[0]//MDCard[2]//MDLabel[@text=\"Standard\"]',
'//ProductCategoryLayout[0]/ProductLayout[1]') '//Payment//MDTabs[0]//MDCard[1]//MDLabel[@text=\"You can get zero encrypted message per month\"]'
# assert for checking scroll function )
self.assertCheckScrollDown('//Payment//ScrollView[0]', timeout=5) # Checking the subscription offer cards
# Scrolling Up Product list self.assertExists(
self.drag( '//Payment/MDTabs[0]//MDCard[3]//MDLabel[@text=\"Premium\"]',
'//ProductCategoryLayout[0]/ProductLayout[1]', timeout=10
'//ProductCategoryLayout[0]/ProductLayout[0]') )
# assert for checking scroll function # Checking the get it now button
self.assertCheckScrollUp('//Payment//ScrollView[0]', timeout=10) self.assertExists(
'//Payment/MDTabs[0]//MDCard[3]//MDRaisedButton[@text=\"Get it now\"]',
@skip_screen_checks timeout=10
@ordered )
def test_buy_option(self): # Clicking on the get it now button
"""Check subscription""" self.cli.wait_click(
# Click on BUY Button '//Payment/MDTabs[0]//MDCard[3]//MDRaisedButton[@text=\"Get it now\"]',
self.cli.wait_click('//MDRaisedButton[@text=\"BUY\"]', timeout=5) timeout=10
)
# Checking the Payment method popup
self.assertExists('//PaymentMethodLayout//ScrollView[0]//ListItemWithLabel[0]', timeout=10)
# CLick on the Payment Method # CLick on the Payment Method
self.cli.click_on('//ScrollView[0]//ListItemWithLabel[0]') self.cli.wait_click(
'//PaymentMethodLayout//ScrollView[0]//ListItemWithLabel[0]',
timeout=10
)
# Check pop up is opened # Check pop up is opened
self.assertExists('//PaymentMethodLayout[@disabled=false]', timeout=10) self.assertExists('//PaymentMethodLayout[@disabled=false]', timeout=10)
# Click out side to dismiss the popup # Click out side to dismiss the popup
self.cli.wait_click('//MDRaisedButton[5]', timeout=5) self.cli.wait_click('//MDRaisedButton[1]', timeout=10)
# Checking Current screen(Payment screen) # Checking state of next tab Payment
self.assertExists("//ScreenManager[@current=\"payment\"]", timeout=5) self.assertExists(
'//Payment/MDTabs[0]//MDTabsLabel[@text=\"Extra-Messages\"][@state=\"normal\"]', timeout=5
)
# Clicking on Payment tab
self.cli.wait_click('//Payment/MDTabs[0]//MDTabsLabel[@text=\"Extra-Messages\"]', timeout=5)
# Checking state of payment tab after click
self.assertExists(
'//Payment/MDTabs[0]//MDTabsLabel[@text=\"Extra-Messages\"][@state=\"down\"]', timeout=5
)
self.cli.sleep(1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -5,3 +5,9 @@ from pybitmessage.bmconfigparser import config
def loadConfig(): def loadConfig():
"""Loading mock test data""" """Loading mock test data"""
config.read(os.path.join(os.environ['BITMESSAGE_HOME'], 'keys.dat')) config.read(os.path.join(os.environ['BITMESSAGE_HOME'], 'keys.dat'))
def total_encrypted_messages_per_month():
"""Loading mock total encrypted message """
encrypted_messages_per_month = 0
return encrypted_messages_per_month