Studio support for creating and editing libraries (PR 6046)
SOL-1, SOL-2, SOL-3
This commit is contained in:
committed by
E. Kolpakov
parent
80e0d56afd
commit
3e0f08ebc2
@@ -1,5 +1,10 @@
|
||||
"""
|
||||
Base classes used by studio tests.
|
||||
"""
|
||||
from bok_choy.web_app_test import WebAppTest
|
||||
from ...pages.studio.auto_auth import AutoAuthPage
|
||||
from ...fixtures.course import CourseFixture
|
||||
from ...fixtures.library import LibraryFixture
|
||||
from ..helpers import UniqueCourseTest
|
||||
from ...pages.studio.overview import CourseOutlinePage
|
||||
from ...pages.studio.utils import verify_ordering
|
||||
@@ -98,3 +103,46 @@ class ContainerBase(StudioCourseTest):
|
||||
# Reload the page to see that the change was persisted.
|
||||
container = self.go_to_nested_container_page()
|
||||
verify_ordering(self, container, expected_ordering)
|
||||
|
||||
|
||||
class StudioLibraryTest(WebAppTest):
|
||||
"""
|
||||
Base class for all Studio library tests.
|
||||
"""
|
||||
|
||||
def setUp(self, is_staff=False): # pylint: disable=arguments-differ
|
||||
"""
|
||||
Install a library with no content using a fixture.
|
||||
"""
|
||||
super(StudioLibraryTest, self).setUp()
|
||||
fixture = LibraryFixture(
|
||||
'test_org',
|
||||
self.unique_id,
|
||||
'Test Library {}'.format(self.unique_id),
|
||||
)
|
||||
self.populate_library_fixture(fixture)
|
||||
fixture.install()
|
||||
self.library_info = fixture.library_info
|
||||
self.library_key = fixture.library_key
|
||||
self.user = fixture.user
|
||||
self.log_in(self.user, is_staff)
|
||||
|
||||
def populate_library_fixture(self, library_fixture):
|
||||
"""
|
||||
Populate the children of the test course fixture.
|
||||
"""
|
||||
pass
|
||||
|
||||
def log_in(self, user, is_staff=False):
|
||||
"""
|
||||
Log in as the user that created the library.
|
||||
By default the user will not have staff access unless is_staff is passed as True.
|
||||
"""
|
||||
auth_page = AutoAuthPage(
|
||||
self.browser,
|
||||
staff=is_staff,
|
||||
username=user.get('username'),
|
||||
email=user.get('email'),
|
||||
password=user.get('password')
|
||||
)
|
||||
auth_page.visit()
|
||||
|
||||
67
common/test/acceptance/tests/studio/test_studio_home.py
Normal file
67
common/test/acceptance/tests/studio/test_studio_home.py
Normal file
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
Acceptance tests for Home Page (My Courses / My Libraries).
|
||||
"""
|
||||
from bok_choy.web_app_test import WebAppTest
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
|
||||
from ...pages.studio.auto_auth import AutoAuthPage
|
||||
from ...pages.studio.library import LibraryPage
|
||||
from ...pages.studio.index import DashboardPage
|
||||
|
||||
|
||||
class CreateLibraryTest(WebAppTest):
|
||||
"""
|
||||
Test that we can create a new content library on the studio home page.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Load the helper for the home page (dashboard page)
|
||||
"""
|
||||
super(CreateLibraryTest, self).setUp()
|
||||
|
||||
self.auth_page = AutoAuthPage(self.browser, staff=True)
|
||||
self.dashboard_page = DashboardPage(self.browser)
|
||||
|
||||
def test_subheader(self):
|
||||
"""
|
||||
From the home page:
|
||||
Verify that subheader is correct
|
||||
"""
|
||||
self.auth_page.visit()
|
||||
self.dashboard_page.visit()
|
||||
|
||||
self.assertIn("courses and libraries", self.dashboard_page.page_subheader)
|
||||
|
||||
def test_create_library(self):
|
||||
"""
|
||||
From the home page:
|
||||
Click "New Library"
|
||||
Fill out the form
|
||||
Submit the form
|
||||
We should be redirected to the edit view for the library
|
||||
Return to the home page
|
||||
The newly created library should now appear in the list of libraries
|
||||
"""
|
||||
name = "New Library Name"
|
||||
org = "TestOrgX"
|
||||
number = "TESTLIB"
|
||||
|
||||
self.auth_page.visit()
|
||||
self.dashboard_page.visit()
|
||||
self.assertFalse(self.dashboard_page.has_library(name=name, org=org, number=number))
|
||||
self.assertTrue(self.dashboard_page.has_new_library_button())
|
||||
|
||||
self.dashboard_page.click_new_library()
|
||||
self.assertTrue(self.dashboard_page.is_new_library_form_visible())
|
||||
self.dashboard_page.fill_new_library_form(name, org, number)
|
||||
self.assertTrue(self.dashboard_page.is_new_library_form_valid())
|
||||
self.dashboard_page.submit_new_library_form()
|
||||
|
||||
# The next page is the library edit view; make sure it loads:
|
||||
lib_page = LibraryPage(self.browser, LibraryLocator(org, number))
|
||||
lib_page.wait_for_page()
|
||||
|
||||
# Then go back to the home page and make sure the new library is listed there:
|
||||
self.dashboard_page.visit()
|
||||
self.assertTrue(self.dashboard_page.has_library(name=name, org=org, number=number))
|
||||
104
common/test/acceptance/tests/studio/test_studio_library.py
Normal file
104
common/test/acceptance/tests/studio/test_studio_library.py
Normal file
@@ -0,0 +1,104 @@
|
||||
"""
|
||||
Acceptance tests for Content Libraries in Studio
|
||||
"""
|
||||
|
||||
from .base_studio_test import StudioLibraryTest
|
||||
from ...pages.studio.utils import add_component
|
||||
from ...pages.studio.library import LibraryPage
|
||||
|
||||
|
||||
class LibraryEditPageTest(StudioLibraryTest):
|
||||
"""
|
||||
Test the functionality of the library edit page.
|
||||
"""
|
||||
def setUp(self): # pylint: disable=arguments-differ
|
||||
"""
|
||||
Ensure a library exists and navigate to the library edit page.
|
||||
"""
|
||||
super(LibraryEditPageTest, self).setUp(is_staff=True)
|
||||
self.lib_page = LibraryPage(self.browser, self.library_key)
|
||||
self.lib_page.visit()
|
||||
self.lib_page.wait_until_ready()
|
||||
|
||||
def test_page_header(self):
|
||||
"""
|
||||
Scenario: Ensure that the library's name is displayed in the header and title.
|
||||
Given I have a library in Studio
|
||||
And I navigate to Library Page in Studio
|
||||
Then I can see library name in page header title
|
||||
And I can see library name in browser page title
|
||||
"""
|
||||
self.assertIn(self.library_info['display_name'], self.lib_page.get_header_title())
|
||||
self.assertIn(self.library_info['display_name'], self.browser.title)
|
||||
|
||||
def test_add_duplicate_delete_actions(self):
|
||||
"""
|
||||
Scenario: Ensure that we can add an HTML block, duplicate it, then delete the original.
|
||||
Given I have a library in Studio with no XBlocks
|
||||
And I navigate to Library Page in Studio
|
||||
Then there are no XBlocks displayed
|
||||
When I add Text XBlock
|
||||
Then one XBlock is displayed
|
||||
When I duplicate first XBlock
|
||||
Then two XBlocks are displayed
|
||||
And those XBlocks locators' are different
|
||||
When I delete first XBlock
|
||||
Then one XBlock is displayed
|
||||
And displayed XBlock are second one
|
||||
"""
|
||||
self.assertEqual(len(self.lib_page.xblocks), 0)
|
||||
|
||||
# Create a new block:
|
||||
add_component(self.lib_page, "html", "Text")
|
||||
self.assertEqual(len(self.lib_page.xblocks), 1)
|
||||
first_block_id = self.lib_page.xblocks[0].locator
|
||||
|
||||
# Duplicate the block:
|
||||
self.lib_page.click_duplicate_button(first_block_id)
|
||||
self.assertEqual(len(self.lib_page.xblocks), 2)
|
||||
second_block_id = self.lib_page.xblocks[1].locator
|
||||
self.assertNotEqual(first_block_id, second_block_id)
|
||||
|
||||
# Delete the first block:
|
||||
self.lib_page.click_delete_button(first_block_id, confirm=True)
|
||||
self.assertEqual(len(self.lib_page.xblocks), 1)
|
||||
self.assertEqual(self.lib_page.xblocks[0].locator, second_block_id)
|
||||
|
||||
def test_add_edit_xblock(self):
|
||||
"""
|
||||
Scenario: Ensure that we can add an XBlock, edit it, then see the resulting changes.
|
||||
Given I have a library in Studio with no XBlocks
|
||||
And I navigate to Library Page in Studio
|
||||
Then there are no XBlocks displayed
|
||||
When I add Multiple Choice XBlock
|
||||
Then one XBlock is displayed
|
||||
When I edit first XBlock
|
||||
And I go to basic tab
|
||||
And set it's text to a fairly trivial question about Battlestar Galactica
|
||||
And save XBlock
|
||||
Then one XBlock is displayed
|
||||
And first XBlock student content contains at least part of text I set
|
||||
"""
|
||||
self.assertEqual(len(self.lib_page.xblocks), 0)
|
||||
# Create a new problem block:
|
||||
add_component(self.lib_page, "problem", "Multiple Choice")
|
||||
self.assertEqual(len(self.lib_page.xblocks), 1)
|
||||
problem_block = self.lib_page.xblocks[0]
|
||||
# Edit it:
|
||||
problem_block.edit()
|
||||
problem_block.open_basic_tab()
|
||||
problem_block.set_codemirror_text(
|
||||
"""
|
||||
>>Who is "Starbuck"?<<
|
||||
(x) Kara Thrace
|
||||
( ) William Adama
|
||||
( ) Laura Roslin
|
||||
( ) Lee Adama
|
||||
( ) Gaius Baltar
|
||||
"""
|
||||
)
|
||||
problem_block.save_settings()
|
||||
# Check that the save worked:
|
||||
self.assertEqual(len(self.lib_page.xblocks), 1)
|
||||
problem_block = self.lib_page.xblocks[0]
|
||||
self.assertIn("Laura Roslin", problem_block.student_content)
|
||||
Reference in New Issue
Block a user