aboutsummaryrefslogtreecommitdiffstats
path: root/tests/uiTests/test_left_nav_panel.py
blob: f564286d883529cd2b5eb2b6f6372154a0bfbfcf (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# ============LICENSE_START==========================================
# org.onap.vvp/test-engine
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
# ===================================================================
#
# Unless otherwise specified, all software contained herein is licensed
# under the Apache License, Version 2.0 (the “License”);
# you may not use this software except in compliance with the License.
# You may obtain a copy of the License at
#
#             http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#
# Unless otherwise specified, all documentation contained herein is licensed
# under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
# you may not use this documentation except in compliance with the License.
# You may obtain a copy of the License at
#
#             https://creativecommons.org/licenses/by/4.0/
#
# Unless required by applicable law or agreed to in writing, documentation
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ============LICENSE_END============================================
#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
from selenium.webdriver.support.select import Select

from iceci.decorator.exception_decor import exception
from services.constants import Constants
from services.frontend.base_actions.click import Click
from services.frontend.base_actions.enter import Enter
from services.frontend.base_actions.get import Get
from services.frontend.base_actions.wait import Wait
from services.helper import Helper
from services.logging_service import LoggingServiceFactory
from services.session import session
from services.types import API, Frontend, DB
from tests.uiTests.test_ui_base import TestUiBase


logger = LoggingServiceFactory.get_logger()


class TestLeftNavPanel(TestUiBase):
    user_content = None

    @classmethod
    def setUpClass(cls):
        super(TestLeftNavPanel, cls).setUpClass()
        cls.user_content = API.VirtualFunction.create_engagement(
            wait_for_gitlab=False)
        cls.eng_title = "%s: %s" % (
            cls.user_content['engagement_manual_id'],
            cls.user_content['vfName'])
        cls.left_panel_eng_id = "clickable-%s" % (cls.eng_title)

    def setUp(self):
        super(TestLeftNavPanel, self).setUp()
        Frontend.User.login(
            self.user_content['el_email'], Constants.Default.Password.TEXT)

    @exception()
    def test_starred_recent_searchbar(self):
        actualVfName = Get.by_id(self.left_panel_eng_id)
        Helper.internal_assert(self.eng_title, actualVfName)
        Click.id(self.left_panel_eng_id)
        Wait.id("title-id-" + self.eng_title)
        Helper.internal_assert(
            self.user_content['engagement_manual_id'] +
            ":",
            Get.by_id(
                "title-id-" +
                self.eng_title))
        Click.id(Constants.Dashboard.Overview.Star.ID, wait_for_page=True)
        Wait.id("title-id-" + self.eng_title)
        Click.id(Constants.Dashboard.Overview.Star.ID, wait_for_page=True)
        Wait.id("title-id-" + self.eng_title, wait_for_page=True)
        Helper.internal_assert(
            self.eng_title, Get.by_id(self.left_panel_eng_id))
        Enter.text_by_xpath(
            "//input[@type='text']",
            self.user_content['engagement_manual_id'],
            wait_for_page=True)
        Wait.text_by_css(
            Constants.Dashboard.LeftPanel.SearchBox.Results.CSS,
            self.eng_title)
        Click.css(
            Constants.Dashboard.LeftPanel.SearchBox.Results.CSS,
            wait_for_page=True)

    @exception()
    def test_search_bar(self):
        """ Create user and VF, log in, add VFC, search by EID, VF and VFC """
        vfFullName = self.user_content[
            'engagement_manual_id'] + ": " + self.user_content['vfName']
        try:
            Enter.text_by_id(
                Constants.Dashboard.LeftPanel.SearchBox.ID,
                self.user_content['vfName'])
            Wait.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS)
            Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS)
            Wait.text_by_id(
                Constants.Dashboard.Overview.Title.ID, vfFullName)
        except BaseException:
            errorMsg = "Failed to search by VF name."
            raise Exception(errorMsg)

        try:
            Enter.text_by_id(
                Constants.Dashboard.LeftPanel.SearchBox.ID,
                self.user_content['engagement_manual_id'])
            Enter.text_by_id(
                Constants.Dashboard.LeftPanel.SearchBox.ID,
                self.user_content['engagement_manual_id'])
            Wait.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS)
            Click.css(Constants.Dashboard.LeftPanel.SearchBox.Results.CSS)
            Wait.text_by_id(
                Constants.Dashboard.Overview.Title.ID, vfFullName)
        except BaseException:
            errorMsg = "Failed to search by Engagement Manual ID."
            raise Exception(errorMsg)
        Frontend.Overview.click_on_vf(self.user_content)
        detailedViewID = Constants.Dashboard.DetailedView.ID + vfFullName
        Wait.text_by_id(detailedViewID, "Detailed View", wait_for_page=True)
        Click.id(detailedViewID, wait_for_page=True)
        Click.id(
            Constants.Dashboard.DetailedView.VFC.Add.ID, wait_for_page=True)
        vfcName = Helper.rand_string("randomString")
        extRefID = Helper.rand_string("randomNumber")
        Enter.text_by_name("name", vfcName)
        Enter.text_by_name("extRefID", extRefID, wait_for_page=True)
        Select(session.ice_driver.find_element_by_id(
            Constants.Dashboard.DetailedView.VFC.Choose_Company.ID)).\
            select_by_visible_text(self.user_content['vendor'])
        Click.id(
            Constants.Dashboard.DetailedView.VFC.Save_button.ID,
            wait_for_page=True)
        try:
            Enter.text_by_id(
                Constants.Dashboard.LeftPanel.SearchBox.ID,
                vfcName,
                wait_for_page=True)
            Click.id(
                "search-" + self.user_content['vfName'], wait_for_page=True)
            Wait.id("clickable-" + vfFullName, wait_for_page=True)
        except Exception as e:
            errorMsg = "Failed to search by VFC name."
            raise Exception(errorMsg + str(e))

    @exception()
    def test_recent_bar_by_last_updated(self):
        countIdsActive = 0
        myVfName = self.user_content[
            'engagement_manual_id'] + ": " + self.user_content['vfName']
        actualVfNameid = "clickable-" + myVfName
        actualVfName = Get.by_id(actualVfNameid)
        Helper.internal_assert(myVfName, actualVfName)
        Click.id(actualVfNameid)
        uuid = DB.General.select_where_email(
            "uuid", "ice_user_profile", self.user_content['el_email'])
        ids2 = DB.User.select_recent_vf_of_user(uuid, 0)
        part_of_id_to_find = "clickable-"
        ids1 = session.ice_driver.find_elements_by_css_selector(
            '[id*="%s"]' % part_of_id_to_find)
        for ii in ids1:
            if "clickable-" in ii.get_attribute('id'):
                logger.debug("Fetched ID: " + ii.get_attribute('id'))
                vf_name = ii.get_attribute('id').split(" ")[1]
                vf_uuid = DB.General.select_where(
                    "uuid", "ice_vf", "name", vf_name, 1)
                if vf_uuid in ids2:
                    countIdsActive += 1
        if(countIdsActive == len(ids2.split())):
            logger.debug("Right result")

    @exception()
    def test_entering_engagement_from_dashboard(self):
        Wait.text_by_id(self.left_panel_eng_id, self.eng_title)
        DB.VirtualFunction.remove_engagement_from_recent(
            self.user_content['vf_uuid'])
        Frontend.General.refresh()
        Frontend.Dashboard.statuses_search_vf(
            self.user_content['engagement_manual_id'],
            self.user_content['vfName'])
        Wait.text_by_id(self.left_panel_eng_id, self.eng_title)

    @exception()
    def test_search_by_email(self):
        user_content = API.VirtualFunction.create_engagement(
            wait_for_gitlab=False)
        Frontend.User.relogin(
            user_content['email'], Constants.Default.Password.TEXT)
        Frontend.Dashboard.search_in_left_searchbox_by_param(
            user_content['engagement_manual_id'],
            user_content['vfName'],
            user_content['email'])

    @exception()
    def test_search_by_username(self):
        user_content = API.VirtualFunction.create_engagement(
            wait_for_gitlab=False)
        Frontend.User.relogin(
            user_content['email'], Constants.Default.Password.TEXT)
        Frontend.Dashboard.search_in_left_searchbox_by_param(
            user_content['engagement_manual_id'],
            user_content['vfName'],
            user_content['full_name'])