Complete Order History tab for students on account settings page.
ECOM-2361
This commit is contained in:
64
common/djangoapps/terrain/stubs/ecommerce.py
Normal file
64
common/djangoapps/terrain/stubs/ecommerce.py
Normal file
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
Stub implementation of ecommerce service for acceptance tests
|
||||
"""
|
||||
|
||||
import re
|
||||
import urlparse
|
||||
from .http import StubHttpRequestHandler, StubHttpService
|
||||
|
||||
|
||||
class StubEcommerceServiceHandler(StubHttpRequestHandler): # pylint: disable=missing-docstring
|
||||
|
||||
def do_GET(self): # pylint: disable=invalid-name, missing-docstring
|
||||
pattern_handlers = {
|
||||
'/api/v2/orders/$': self.get_orders_list,
|
||||
}
|
||||
if self.match_pattern(pattern_handlers):
|
||||
return
|
||||
self.send_response(404, content='404 Not Found')
|
||||
|
||||
def match_pattern(self, pattern_handlers):
|
||||
"""
|
||||
Find the correct handler method given the path info from the HTTP request.
|
||||
"""
|
||||
path = urlparse.urlparse(self.path).path
|
||||
for pattern in pattern_handlers:
|
||||
match = re.match(pattern, path)
|
||||
if match:
|
||||
pattern_handlers[pattern](**match.groupdict())
|
||||
return True
|
||||
return None
|
||||
|
||||
def get_orders_list(self):
|
||||
"""
|
||||
Stubs the orders list endpoint.
|
||||
"""
|
||||
orders = {
|
||||
'results': [
|
||||
{
|
||||
'status': 'Complete',
|
||||
'number': 'Edx-123',
|
||||
'total_excl_tax': '100.0',
|
||||
'date_placed': '2016-04-21T23:14:23Z',
|
||||
'lines': [
|
||||
{
|
||||
'title': 'Test Course',
|
||||
'product': {
|
||||
'attribute_values': [
|
||||
{
|
||||
'name': 'certificate_type',
|
||||
'value': 'verified'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
orders = self.server.config.get('orders', orders)
|
||||
self.send_json_response(orders)
|
||||
|
||||
|
||||
class StubEcommerceService(StubHttpService): # pylint: disable=missing-docstring
|
||||
HANDLER_CLASS = StubEcommerceServiceHandler
|
||||
@@ -4,7 +4,9 @@ Command-line utility to start a stub service.
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
|
||||
from .comments import StubCommentsService
|
||||
from .ecommerce import StubEcommerceService
|
||||
from .xqueue import StubXQueueService
|
||||
from .youtube import StubYouTubeService
|
||||
from .lti import StubLtiService
|
||||
@@ -23,6 +25,7 @@ SERVICES = {
|
||||
'video': VideoSourceHttpService,
|
||||
'edxnotes': StubEdxNotesService,
|
||||
'programs': StubProgramsService,
|
||||
'ecommerce': StubEcommerceService,
|
||||
}
|
||||
|
||||
# Log to stdout, including debug messages
|
||||
|
||||
@@ -63,3 +63,19 @@ class AccountSettingsPage(FieldsMixin, PageObject):
|
||||
Switch between the different account settings tabs.
|
||||
"""
|
||||
self.q(css='#{}'.format(tab_id)).click()
|
||||
|
||||
@property
|
||||
def is_order_history_tab_visible(self):
|
||||
""" Check if tab with the name "Order History" is visible."""
|
||||
return self.q(css='.u-field-orderHistory').visible
|
||||
|
||||
def get_value_of_order_history_row_item(self, field_id, field_name):
|
||||
""" Return the text value of the provided order field name."""
|
||||
query = self.q(css='.u-field-{} .u-field-order-{}'.format(field_id, field_name))
|
||||
return query.text[0] if query.present else None
|
||||
|
||||
def order_button_is_visible(self, field_id):
|
||||
""" Check that if hovering over the order history row shows the
|
||||
order detail link or not.
|
||||
"""
|
||||
return self.q(css='.u-field-{} .u-field-{}'.format(field_id, 'link')).visible
|
||||
|
||||
@@ -444,6 +444,28 @@ class AccountSettingsPageTest(AccountSettingsTestMixin, WebAppTest):
|
||||
self.assertEqual(self.account_settings_page.title_for_field(field_id), title)
|
||||
self.assertEqual(self.account_settings_page.link_title_for_link_field(field_id), link_title)
|
||||
|
||||
def test_order_history(self):
|
||||
"""
|
||||
Test that we can see orders on Order History tab.
|
||||
"""
|
||||
# switch to "Order History" tab
|
||||
self.account_settings_page.switch_account_settings_tabs('orders-tab')
|
||||
# verify that we are on correct tab
|
||||
self.assertTrue(self.account_settings_page.is_order_history_tab_visible)
|
||||
|
||||
expected_order_data = {
|
||||
'title': 'Test Course',
|
||||
'date': 'Date Placed:\nApr 21, 2016',
|
||||
'price': 'Cost:\n$100.0',
|
||||
'number': 'Order Number:\nEdx-123'
|
||||
}
|
||||
for field_name, value in expected_order_data.iteritems():
|
||||
self.assertEqual(
|
||||
self.account_settings_page.get_value_of_order_history_row_item('order-Edx-123', field_name), value
|
||||
)
|
||||
|
||||
self.assertTrue(self.account_settings_page.order_button_is_visible('order-Edx-123'))
|
||||
|
||||
|
||||
@attr('a11y')
|
||||
class AccountSettingsA11yTest(AccountSettingsTestMixin, WebAppTest):
|
||||
|
||||
10
common/test/db_fixtures/commerce_config.json
Normal file
10
common/test/db_fixtures/commerce_config.json
Normal file
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "commerce.commerceconfiguration",
|
||||
"fields": {
|
||||
"enabled": 1,
|
||||
"change_date": "2016-04-21 10:19:32.034856"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user