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',
'images/*.png', 'images/*.ico', 'images/*.icns',
'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:

View File

@ -1,71 +1,144 @@
#:import get_color_from_hex kivy.utils.get_color_from_hex
<Payment>:
name: "payment"
id: id_payment_screen
payment_plan_id: ""
MDTabs:
id: tab_panel
tab_display_mode:'text'
Tab:
title: app.tr._("Payment")
id: id_payment plan
padding: "12dp"
spacing: "12dp"
BoxLayout:
ScrollView:
bar_width:0
do_scroll_x: False
#scroll_y:0
BoxLayout:
spacing: dp(5)
padding: dp(5)
size_hint_y: None
height: self.minimum_height
orientation: "vertical"
ProductCategoryLayout:
MDCard:
orientation: "vertical"
padding: "8dp"
spacing: "12dp"
size_hint: None, None
size: "560dp", "40dp"
pos_hint: {"center_x": .5, "center_y": .5}
MDLabel:
text: f"You have {app.encrypted_messages_per_month} messages left"
bold: True
halign:'center'
size_hint_y: None
pos_hint: {"center_x": .5, "center_y": .5}
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: "Monthly-Subscriptions"
category_text: "Extra-Messages"
ProductLayout:
heading_text: "Gas (Play Billing Codelab)"
heading_text: "100 Encrypted messages "
price_text: "$0.99"
source: app.image_path + "/payment/buynew1.png"
description_text: "Buy gasoline to ride!"
description_text: "Buy extra one hundred encrypted messages!"
product_id: "SKUGASBILLING"
ProductLayout:
heading_text: "Upgrade your car (Play Billing Codelab)"
heading_text: "1000 Encrypted messages "
price_text: "$1.49"
source: app.image_path + "/payment/buynew1.png"
description_text: "Buy a premium outfit for your car!"
description_text: "Buy extra one thousand encrypted messages!"
product_id: "SKUUPGRADECAR"
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"
<ProductCategoryLayout@BoxLayout>:
size_hint_y: None
height: self.minimum_height
@ -94,7 +167,6 @@
MDLabel:
text: root.text_
font_size: sp(15)
<ProductLayout>:
heading_text: ""
price_text: ""
@ -117,7 +189,6 @@
#heading area
BoxLayout:
size_hint_y: 0.3
#text heading
BoxLayout:
Widget:
@ -169,7 +240,6 @@
MDLabel:
text: root.description_text
font_size: sp(15)
#Button Area
BoxLayout:
size_hint_y: 0.4
@ -201,7 +271,7 @@
RightLabel:
text: root.right_label_text
theme_text_color: "Custom"
text_color: 0,0,0,.4
text_color: 0,0,0,0.5
font_size: sp(12)
<PaymentMethodLayout>:
@ -239,14 +309,16 @@
ListItemWithLabel:
source: app.image_path + "/payment/btc.png"
text: "BTC"
text: "BTC (Currently this feature is not available)"
method_name: "btc"
theme_text_color: 'Secondary'
md_bg_color: [0, 0, 0,1]
ListItemWithLabel:
source: app.image_path + "/payment/paypal.png"
text: "Paypal"
text: "Paypal (Currently this feature is not available)"
method_name: "som"
theme_text_color: 'Secondary'
md_bg_color: [0, 0, 0,1]
ListItemWithLabel:
source: app.image_path + "/payment/buy.png"
text: "One more method"

View File

@ -185,7 +185,7 @@
on_release: app.root.ids.scr_mngr.current = 'set'
on_release: root.parent.set_state()
NavigationItem:
text: app.tr._('Purchase')
text: app.tr._('Payment plan')
icon: 'shopping'
divider: None
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.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')
@ -93,6 +93,7 @@ class NavigateApp(MDApp):
identity_list = get_identity_list()
image_path = load_image_path()
app_platform = platform
encrypted_messages_per_month = total_encrypted_messages_per_month()
tr = Lang("en") # for changing in franch replace en with fr
def __init__(self):

View File

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