summaryrefslogtreecommitdiff
path: root/service/test/functional/features/steps/tag_list.py
blob: ff7f848d3aeb51acb9621bd769307e5ed2da2b75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
from common import *


def click_first_element_with_class(context, classname):
    element = find_element_by_class_name(context, classname)
    element.click()


def is_side_nav_expanded(context):
    e = find_element_by_class_name(context, 'content')
    return u'move-right' in e.get_attribute("class")


def expand_side_nav(context):
    if is_side_nav_expanded(context):
        return

    toggle = find_element_by_class_name(context, 'side-nav-toggle')
    toggle.click()


@when('I select the tag \'{tag}\'')
def impl(context, tag):
    wait_for_user_alert_to_disapear(context)
    expand_side_nav(context)

    time.sleep(.5)  # need to find something that tells us that side nav is completely loaded

    wait_until_element_is_visible_by_locator(context, (By.ID, 'tag-%s' % tag), timeout=20)

    e = find_element_by_id(context, 'tag-%s' % tag)
    e.click()
    wait_until_element_is_visible_by_locator(context, (By.CSS_SELECTOR, "#mail-list li span a[href*='%s']" % tag), timeout=20)


@when('I am in  \'{tag}\'')
def impl(context, tag):
    expand_side_nav(context)

    wait_until_element_is_visible_by_locator(context, (By.ID, 'tag-%s' % tag), 20)
    e = find_element_by_id(context, 'tag-%s' % tag)
    assert "selected" in e.get_attribute("class")