Search code examples
edxopenedx

How to test 'studio_view' in xblock-sdk?


I'm developing a custom-xblock, where course-creator can add some html in predefined and pre-designed block. I have installed xblock-sdk and using the same for xblock development. I can test student_view in xblock-sdk but I want to test studio_view in the same environment.

Right now in forward to test studio_view, I have to install my developed custom-xblock in edx-platform. If there is any way to test it in xblock-sdk then development can be faster and reliable.

I have dogwood release installed in edx-devstack.


Solution

  • Depends on what you mean by "test". If that's about manual testing - it is possible, but it is easier to just install it locally and check if it works in actual Studio. To access views other than student_view, just open scenario with an XBlock, than add /${view_name} to the URL - it should open that view (i.e. localhost:8080/scenario/test/student_view`)

    If you're talking about unittests - read along.

    There's xblock-utils repository that provides some quite useful base classes. One of those classes, SeleniumBaseTest might give you some insights on how to do that (these lines in particular).

    Or you can just subclass your test class from it and use it (example: in Poll XBlock tests). There's one possibly misleading/confusing thing about Studio views - there are two of them: * studio_view - is the view displayed when you click "edit" on a XBlock in a popup * author_view - what's shown in unit. Usually defaults to student_view to show the same content to students and authors.

    Note that full studio functionality won't be available there - some parts of it are external to block's studio_view and author_view, so they won't be there in sdk.