Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create top-level nav item for docs #4853

Merged
merged 4 commits into from
Feb 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lint:
test:
bin/kalite manage test --bdd-only

test-bdd:
test-bdd: docs
bin/kalite manage test --bdd-only

test-nobdd:
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- "data"
- "sc-latest-linux"
override:
- pip install -r requirements_test.txt
- pip install -r requirements_sphinx.txt
- pip install -e .
# This cannot be done because pip on Circle doesn't understand our sdist
# - make sdist
Expand Down
20 changes: 17 additions & 3 deletions kalite/distributed/features/steps/ui_regression.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from behave import *
from behave import given, then, when
from django.core.urlresolvers import reverse

from kalite.testing.behave_helpers import *
from kalite.testing.behave_helpers import find_id_with_wait, assert_no_element_by_id, \
elem_is_visible_with_wait, build_url, login_as_coach

DROPDOWN_MENU_ID = "username"
NAVBAR_TOGGLE_ID = "navbar_toggle"
LOGOUT_LINK_ID = "nav_logout"
DOCS_LINK_ID = "nav_documentation"


@given("I'm logged in as a coach")
def step_impl(context):
login_as_coach(context)


@given("I can see the username dropdown menu")
@given(u"I can see the username dropdown menu")
def step_impl(context):
go_to_homepage(context)
context.dropdown_menu = dropdown_menu = find_id_with_wait(context, DROPDOWN_MENU_ID)
Expand All @@ -36,5 +38,17 @@ def step_impl(context):
assert elem_is_visible_with_wait(context, logout_link), "Logout link is not visible!"


@then(u"I see the documentation link")
def step_impl(context):
docs_link = find_id_with_wait(context, DOCS_LINK_ID)
assert elem_is_visible_with_wait(context, docs_link), "Documentation link is not visible!"


@then(u"I do not see the documentation link")
def step_impl(context):
find_id_with_wait(context, 'user-name') # Ensure the menu has loaded at all
assert_no_element_by_id(context, '#' + DOCS_LINK_ID)


def go_to_homepage(context):
context.browser.get(build_url(context, reverse("homepage")))
17 changes: 16 additions & 1 deletion kalite/distributed/features/ui_regression.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@ Feature: UI regression tests
Given superuser is deleted
Given I'm on update_videos page
Then I'm redirected to the homepage
Then I see only superusercreate modal
Then I see only superusercreate modal

@as_coach
Scenario: Documentation link shown to coaches
Given I am on the homepage
Then I see the documentation link

@as_admin
Scenario: Documentation link shown to admins
Given I am on the homepage
Then I see the documentation link

@as_learner
Scenario: Documentation link not shown to learners
Given I am on the homepage
Then I do not see the documentation link
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
<li role="menuitem"><a href="{{ url "facility_user_signup" }}" id="nav_signup">{{_ "Sign Up" }}</a></li>
{{/unless}}

{{#if docs_exist}}
{{#if is_admin}}
<li role="menuitem" id="nav_documentation">
<a role="menuitem" tabindex="-1" id="documentation_a" href="/static/html/usermanual/userman_main.html">
{{_ "User Manual" }}
</a>
</li>
{{/if}}
{{/if}}

<hr class="nav-divider">
{{#if is_admin}}
<hr class="nav-divider">
Expand Down Expand Up @@ -41,13 +51,6 @@
{{_ "Logout" }}
</a>
</li>
{{#if docs_exist}}
<li role="presentation" id="documentation">
<a role="menuitem" tabindex="-1" id="documentation_a" href="/static/html/index.html">
{{_ "Documentation" }}
</a>
</li>
{{/if}}
</ul>
</li>
{{/if}}
9 changes: 9 additions & 0 deletions kalite/testing/behave_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ def _assert_no_element_by(context, by, value, wait_time=MAX_PAGE_LOAD_TIME):
)


def assert_no_element_by_id(context, _id, wait_time=MAX_PAGE_LOAD_TIME):
"""
Assert that no element is found. Use a wait in case the element currently exists
on the page, and we want to wait for it to disappear before doing the assert.
Finds the element using an id.
"""
_assert_no_element_by(context, By.ID, _id, wait_time)


def assert_no_element_by_css_selector(context, css_value, wait_time=MAX_PAGE_LOAD_TIME):
"""
Assert that no element is found. Use a wait in case the element currently exists
Expand Down