1 |
3a4cfa9b
|
hlavja
|
import {DashboardPo} from './dashboard.po';
|
2 |
25e66baf
|
hlavja
|
import {LoginPo} from '../login/login.po';
|
3 |
|
|
import {browser, by, element} from 'protractor';
|
4 |
|
|
import * as moment from 'moment-timezone';
|
5 |
|
|
import {NavBarPo} from '../nav-bar/nav-bar.po';
|
6 |
3a4cfa9b
|
hlavja
|
|
7 |
|
|
|
8 |
7fefc7af
|
hlavja
|
describe('Dashboard Module', () => {
|
9 |
3a4cfa9b
|
hlavja
|
let dashboardPo: DashboardPo;
|
10 |
|
|
let loginPo: LoginPo
|
11 |
25e66baf
|
hlavja
|
let navBarPo: NavBarPo
|
12 |
|
|
let today = moment().format('YYYYMMDDHHMMSS').toString();
|
13 |
3a4cfa9b
|
hlavja
|
|
14 |
25e66baf
|
hlavja
|
beforeEach(async () => {
|
15 |
3a4cfa9b
|
hlavja
|
dashboardPo = new DashboardPo();
|
16 |
|
|
loginPo = new LoginPo();
|
17 |
25e66baf
|
hlavja
|
navBarPo = new NavBarPo();
|
18 |
|
|
await loginPo.navigateTo();
|
19 |
|
|
await loginPo.processForm();
|
20 |
3a4cfa9b
|
hlavja
|
});
|
21 |
|
|
|
22 |
25e66baf
|
hlavja
|
afterEach(async () => {
|
23 |
|
|
await loginPo.logout();
|
24 |
3a4cfa9b
|
hlavja
|
});
|
25 |
|
|
|
26 |
25e66baf
|
hlavja
|
it('Show test unit sensors!', async () => {
|
27 |
|
|
expect(await dashboardPo.xpathIsVisible('//h4[contains(text(), \'test sensor Temp\')]')).toEqual(false);
|
28 |
|
|
await dashboardPo.clickToAccordionTab();
|
29 |
|
|
await browser.sleep(500);
|
30 |
|
|
expect(await dashboardPo.xpathIsVisible('//h4[contains(text(), \'test sensor Temp\')]')).toEqual(true);
|
31 |
3a4cfa9b
|
hlavja
|
});
|
32 |
|
|
|
33 |
25e66baf
|
hlavja
|
it('Add unit ' + today + ' !', async () => {
|
34 |
|
|
await navBarPo.showUnitInsert();
|
35 |
|
|
expect(await navBarPo.popupShown()).toEqual(true);
|
36 |
|
|
await navBarPo.sendUnitForm(today);
|
37 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
38 |
|
|
});
|
39 |
|
|
|
40 |
|
|
it('Added unit ' + today + ' shown!', async () => {
|
41 |
|
|
expect(await dashboardPo.xpathIsVisible('//h3[contains(text(), \''+ today +'\')]')).toEqual(true);
|
42 |
|
|
});
|
43 |
|
|
|
44 |
|
|
it('Unit ' + today + ' manipulation buttons test!', async () => {
|
45 |
|
|
expect(await dashboardPo.buttonByTextIsVisible('Sensors graph')).toEqual(true);
|
46 |
|
|
await dashboardPo.clickManipulationUnitButton(today);
|
47 |
|
|
expect(await dashboardPo.xpathIsVisible('//span[contains(text(), \'Edit unit\')]')).toEqual(true);
|
48 |
|
|
expect(await dashboardPo.xpathIsVisible('//span[contains(text(), \'Insert position\')]')).toEqual(true);
|
49 |
|
|
expect(await dashboardPo.xpathIsVisible('//span[contains(text(), \'Delete unit\')]')).toEqual(true);
|
50 |
|
|
expect(await dashboardPo.xpathIsVisible('//span[contains(text(), \'Add sensor\')]')).toEqual(true);
|
51 |
|
|
});
|
52 |
|
|
|
53 |
|
|
it('Edit unit!', async () => {
|
54 |
|
|
await dashboardPo.clickManipulationUnitButton(today);
|
55 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Edit unit\')]');
|
56 |
|
|
expect(await dashboardPo.xpathIsVisible('//div[contains(@class, \'p-dialog\')]')).toEqual(true);
|
57 |
|
|
expect(await dashboardPo.xpathIsVisible('//span[contains(text(), \'Edit unit\')]')).toEqual(true);
|
58 |
|
|
expect(await dashboardPo.xpathIsVisible('//span[contains(@class, \'p-dialog-title\')]')).toEqual(true);
|
59 |
|
|
today = today+'edit';
|
60 |
|
|
await dashboardPo.setUnitDescription('//input', today);
|
61 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Save\')]');
|
62 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
63 |
|
|
expect(await dashboardPo.xpathIsVisible('//h3[contains(text(), \''+ today +'\')]')).toEqual(true);
|
64 |
|
|
});
|
65 |
|
|
|
66 |
|
|
it('Insert position!', async () => {
|
67 |
|
|
await dashboardPo.clickManipulationUnitButton(today.substr(0, today.length-4));
|
68 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Insert position\')]');
|
69 |
|
|
await dashboardPo.fillPosition();
|
70 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Save\')]');
|
71 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
72 |
|
|
expect(await dashboardPo.xpathIsVisible('//h3[contains(text(), \''+ today +'\')]')).toEqual(true);
|
73 |
|
|
});
|
74 |
|
|
|
75 |
|
|
it('Add sensor!', async () => {
|
76 |
|
|
const sensor = today.substr(0, today.length-4)
|
77 |
|
|
await dashboardPo.clickManipulationUnitButton(today.substr(0, today.length-4));
|
78 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Add sensor\')]');
|
79 |
|
|
await browser.sleep(1000);
|
80 |
|
|
await dashboardPo.clickButtonByText('Add Sensor');
|
81 |
|
|
await browser.sleep(1000);
|
82 |
|
|
await dashboardPo.clickButtonByText('Add Sensor');
|
83 |
|
|
expect(await dashboardPo.numberOfxPaths('//input[contains(@id, \'sensorId\')]')).toEqual(3);
|
84 |
|
|
await dashboardPo.clickButtonByText('Remove last sensor');
|
85 |
|
|
await dashboardPo.clickButtonByText('Remove last sensor');
|
86 |
|
|
await dashboardPo.fillSensorForm(sensor);
|
87 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Save\')]');
|
88 |
|
|
await browser.sleep(1000);
|
89 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
90 |
|
|
await browser.sleep(5000);
|
91 |
|
|
expect(await dashboardPo.xpathIsVisible('//h3[contains(text(), \''+ sensor +'\')]')).toEqual(true);
|
92 |
|
|
await dashboardPo.clickToAccordionTabByXpath('(.//a[contains(@class, \'p-accordion-header-link\')])[last()]');
|
93 |
|
|
await browser.sleep(500);
|
94 |
|
|
expect(await dashboardPo.xpathIsVisible('//h4[contains(text(), \''+ sensor +'\')]')).toEqual(true);
|
95 |
|
|
});
|
96 |
|
|
|
97 |
|
|
it('Edit sensor!', async () => {
|
98 |
|
|
const sensor = today.substr(0, today.length-4)
|
99 |
|
|
await dashboardPo.clickToAccordionTabByXpath('(.//a[contains(@class, \'p-accordion-header-link\')])[last()]');
|
100 |
|
|
await browser.sleep(500);
|
101 |
|
|
await dashboardPo.clickManipulationUnitButton('sensor_'+sensor);
|
102 |
|
|
await browser.sleep(500);
|
103 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Edit sensor\')]');
|
104 |
|
|
await dashboardPo.fillEditSensorForm(sensor+'_test');
|
105 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Save\')]');
|
106 |
|
|
await browser.sleep(1000);
|
107 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
108 |
|
|
expect(await dashboardPo.xpathIsVisible('//h4[contains(text(), \''+ sensor +'_test\')]')).toEqual(true);
|
109 |
|
|
});
|
110 |
|
|
|
111 |
|
|
it('Delete sensor!', async () => {
|
112 |
|
|
const sensor = today.substr(0, today.length-4)
|
113 |
|
|
await dashboardPo.clickToAccordionTabByXpath('(.//a[contains(@class, \'p-accordion-header-link\')])[last()]');
|
114 |
|
|
await browser.sleep(500);
|
115 |
|
|
await dashboardPo.clickManipulationUnitButton('sensor_'+sensor);
|
116 |
|
|
await browser.sleep(500);
|
117 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Delete sensor\')]');
|
118 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Yes\')]');
|
119 |
|
|
await browser.sleep(1000);
|
120 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
121 |
|
|
expect(await element(by.xpath('//h4[contains(text(), \''+ sensor +'\')]')).isPresent()).toEqual(false);
|
122 |
|
|
});
|
123 |
|
|
|
124 |
|
|
it('Delete unit!', async () => {
|
125 |
|
|
await dashboardPo.clickManipulationUnitButton(today.substr(0, today.length-4));
|
126 |
|
|
await browser.sleep(500);
|
127 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Delete unit\')]');
|
128 |
|
|
await dashboardPo.clickByXpath('//span[contains(text(), \'Yes\')]');
|
129 |
|
|
await browser.sleep(1000);
|
130 |
|
|
expect(await navBarPo.success()).toEqual(true);
|
131 |
|
|
expect(await element(by.xpath('//h3[contains(text(), \''+ today +'\')]')).isPresent()).toEqual(false);
|
132 |
|
|
});
|
133 |
3a4cfa9b
|
hlavja
|
});
|