Revize 25e66baf
Přidáno uživatelem Jakub Hlaváč před téměř 4 roky(ů)
e2e/src/1login/login.e2e-spec.ts | ||
---|---|---|
1 |
import {LoginPo} from './login.po'; |
|
2 |
|
|
3 |
|
|
4 |
describe('Login Module', () => { |
|
5 |
let loginPo: LoginPo; |
|
6 |
|
|
7 |
beforeEach(() => { |
|
8 |
loginPo = new LoginPo(); |
|
9 |
}); |
|
10 |
|
|
11 |
it('Check if login form displayed!', async () => { |
|
12 |
await loginPo.navigateTo(); |
|
13 |
expect(await loginPo.getTitleText()).toEqual('Sign in'); |
|
14 |
}); |
|
15 |
|
|
16 |
it('Process login form!', async () => { |
|
17 |
await loginPo.navigateTo(); |
|
18 |
await loginPo.processForm(); |
|
19 |
expect(await loginPo.dashboardPresent()).toEqual(true); |
|
20 |
expect(await loginPo.loggedUser()).toEqual(' TESTINS'); |
|
21 |
}); |
|
22 |
}); |
e2e/src/1login/login.po.ts | ||
---|---|---|
1 |
import { browser, by, element } from 'protractor'; |
|
2 |
|
|
3 |
export class LoginPo { |
|
4 |
async navigateTo(): Promise<unknown> { |
|
5 |
return browser.get(browser.baseUrl); |
|
6 |
} |
|
7 |
|
|
8 |
async getTitleText(): Promise<string> { |
|
9 |
return element(by.className('login-heading')).getText(); |
|
10 |
} |
|
11 |
|
|
12 |
async processForm(): Promise<unknown> { |
|
13 |
element(by.id('username')).sendKeys('testins'); |
|
14 |
element(by.id('password')).sendKeys('insert'); |
|
15 |
return element(by.id('loginButton')).click(); |
|
16 |
} |
|
17 |
|
|
18 |
async dashboardPresent(): Promise<unknown> { |
|
19 |
return element(by.className('dashboard')).isPresent(); |
|
20 |
} |
|
21 |
|
|
22 |
async loggedUser(): Promise<string> { |
|
23 |
return element(by.id('loggedUser')).getText(); |
|
24 |
} |
|
25 |
} |
e2e/src/dashboard/dashboard.e2e-spec.ts | ||
---|---|---|
1 | 1 |
import {DashboardPo} from './dashboard.po'; |
2 |
import {LoginPo} from '../1login/login.po'; |
|
3 |
import {browser} from 'protractor'; |
|
2 |
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'; |
|
4 | 6 |
|
5 | 7 |
|
6 | 8 |
describe('Dashboard Module', () => { |
7 | 9 |
let dashboardPo: DashboardPo; |
8 | 10 |
let loginPo: LoginPo |
11 |
let navBarPo: NavBarPo |
|
12 |
let today = moment().format('YYYYMMDDHHMMSS').toString(); |
|
9 | 13 |
|
10 |
beforeEach(() => { |
|
14 |
beforeEach(async () => {
|
|
11 | 15 |
dashboardPo = new DashboardPo(); |
12 | 16 |
loginPo = new LoginPo(); |
17 |
navBarPo = new NavBarPo(); |
|
18 |
await loginPo.navigateTo(); |
|
19 |
await loginPo.processForm(); |
|
13 | 20 |
}); |
14 | 21 |
|
15 |
it('Add user!', async () => { |
|
16 |
await dashboardPo.showUserInsert(); |
|
17 |
expect(await dashboardPo.popupShown()).toEqual(true); |
|
18 |
await dashboardPo.sendUserForm(); |
|
19 |
expect(await dashboardPo.success()).toEqual(true); |
|
22 |
afterEach(async () => { |
|
23 |
await loginPo.logout(); |
|
20 | 24 |
}); |
21 | 25 |
|
22 |
it('Add unit!', async () => {
|
|
23 |
await dashboardPo.showUnitInsert();
|
|
24 |
expect(await dashboardPo.popupShown()).toEqual(true);
|
|
25 |
await dashboardPo.sendUnitForm();
|
|
26 |
expect(await dashboardPo.success()).toEqual(true);
|
|
26 |
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);
|
|
27 | 31 |
}); |
28 | 32 |
|
33 |
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 |
}); |
|
29 | 133 |
}); |
e2e/src/dashboard/dashboard.po.ts | ||
---|---|---|
1 |
import { browser, by, element } from 'protractor'; |
|
2 |
import * as moment from 'moment-timezone'; |
|
1 |
import {by, element, protractor} from 'protractor'; |
|
3 | 2 |
|
4 | 3 |
export class DashboardPo { |
5 |
async navigateTo(): Promise<unknown> { |
|
6 |
return browser.get(browser.baseUrl); |
|
4 |
|
|
5 |
async clickToAccordionTab(): Promise<unknown> { |
|
6 |
return element(by.id('p-accordiontab-0')).click(); |
|
7 |
} |
|
8 |
|
|
9 |
async clickButtonByText(text: string): Promise<unknown> { |
|
10 |
return element(by.buttonText(text)).click(); |
|
7 | 11 |
} |
8 | 12 |
|
9 |
async showUserInsert(): Promise<unknown> {
|
|
10 |
return element(by.id('addUser')).click();
|
|
13 |
async xpathIsVisible(xPath: string): Promise<boolean> {
|
|
14 |
return element(by.xpath(xPath)).isDisplayed();
|
|
11 | 15 |
} |
12 | 16 |
|
13 |
async popupShown(): Promise<boolean> {
|
|
14 |
return element(by.className('p-dialog-resizable')).isPresent();
|
|
17 |
async buttonByTextIsVisible(buttonText: string): Promise<boolean> {
|
|
18 |
return element(by.buttonText(buttonText)).isDisplayed();
|
|
15 | 19 |
} |
16 | 20 |
|
17 |
async sendUserForm(): Promise<unknown> { |
|
18 |
const today = moment().format('YYYYMMDDHHMMSS').toString(); |
|
19 |
element(by.id('username')).sendKeys(today); |
|
20 |
element(by.id('password')).sendKeys('testuser'); |
|
21 |
element(by.id('userRealName')).sendKeys('testuser'); |
|
22 |
element(by.cssContainingText('option', 'testing units')).click(); |
|
23 |
element(by.cssContainingText('option', 'General user')).click(); |
|
24 |
return element(by.buttonText('Save')).click(); |
|
21 |
async clickManipulationUnitButton(id: string): Promise<unknown> { |
|
22 |
return element(by.id('manipulation_'+id)).click(); |
|
25 | 23 |
} |
26 | 24 |
|
27 |
async success(): Promise<boolean> {
|
|
28 |
return element(by.cssContainingText('.p-toast-summary', 'Success')).isPresent();
|
|
25 |
async clickByXpath(xPath: string): Promise<unknown> {
|
|
26 |
return element(by.xpath(xPath)).click();
|
|
29 | 27 |
} |
30 | 28 |
|
31 |
async showUnitInsert(): Promise<unknown> { |
|
32 |
return element(by.id('addUnit')).click(); |
|
29 |
async setUnitDescription(xPath: string, text: string): Promise<unknown> { |
|
30 |
element(by.xpath(xPath)).clear() |
|
31 |
return element(by.xpath(xPath)).sendKeys(text); |
|
33 | 32 |
} |
34 | 33 |
|
35 |
async sendUnitForm() { |
|
36 |
const today = moment().format('YYYYMMDDHHMMSS').toString(); |
|
37 |
element(by.id('unitId')).sendKeys(today); |
|
38 |
element(by.id('unitDescription')).sendKeys(today); |
|
39 |
element(by.id('lat')).sendKeys(10); |
|
40 |
element(by.id('lon')).sendKeys(10); |
|
41 |
await browser.sleep(3000) |
|
42 |
element(by.buttonText('Add sensor')).click(); |
|
43 |
await browser.sleep(3000); |
|
44 |
element(by.id('sensorId')).sendKeys(today); |
|
45 |
element(by.id('sensorName')).sendKeys(today) |
|
34 |
async fillPosition(): Promise<unknown> { |
|
35 |
element(by.id('lat')).click() |
|
36 |
element(by.id('lat')).sendKeys(protractor.Key.UP, '10'); |
|
37 |
element(by.id('lat')).sendKeys(protractor.Key.UP); |
|
38 |
element(by.id('lat')).sendKeys(protractor.Key.UP); |
|
39 |
element(by.id('lon')).click() |
|
40 |
element(by.id('lon')).sendKeys(protractor.Key.UP); |
|
41 |
element(by.id('lon')).sendKeys(protractor.Key.UP); |
|
42 |
element(by.id('lon')).sendKeys(protractor.Key.UP); |
|
43 |
element(by.id('alt')).sendKeys('10'); |
|
44 |
element(by.id('speed')).sendKeys('10'); |
|
45 |
return element(by.id('dop')).sendKeys('10'); |
|
46 |
} |
|
47 |
|
|
48 |
async numberOfxPaths(xPath: string): Promise<unknown> { |
|
49 |
return element.all(by.xpath(xPath)).count(); |
|
50 |
} |
|
51 |
|
|
52 |
async fillSensorForm(text: string): Promise<unknown> { |
|
53 |
element(by.id('sensorId')).clear(); |
|
54 |
element(by.id('sensorId')).sendKeys(text); |
|
55 |
element(by.id('sensorName')).clear() |
|
56 |
element(by.id('sensorName')).sendKeys(text) |
|
46 | 57 |
element(by.cssContainingText('option', 'test')).click(); |
47 |
element(by.cssContainingText('option', 'Strikes ( )')).click(); |
|
48 |
await browser.sleep(3000) |
|
49 |
return element(by.buttonText('Save')).click(); |
|
58 |
return element(by.cssContainingText('option', 'Strikes ( )')).click(); |
|
59 |
} |
|
60 |
|
|
61 |
async fillEditSensorForm(text: string): Promise<unknown> { |
|
62 |
element(by.id('sensorName')).clear() |
|
63 |
return element(by.id('sensorName')).sendKeys(text) |
|
64 |
} |
|
65 |
|
|
66 |
async clickToAccordionTabByXpath(xPath: string): Promise<unknown> { |
|
67 |
return element(by.xpath(xPath)).click(); |
|
50 | 68 |
} |
51 | 69 |
} |
e2e/src/login/login.e2e-spec.ts | ||
---|---|---|
1 |
import {LoginPo} from './login.po'; |
|
2 |
|
|
3 |
|
|
4 |
describe('Login Module', () => { |
|
5 |
let loginPo: LoginPo; |
|
6 |
|
|
7 |
beforeEach(() => { |
|
8 |
loginPo = new LoginPo(); |
|
9 |
}); |
|
10 |
|
|
11 |
it('Check if login form displayed!', async () => { |
|
12 |
await loginPo.navigateTo(); |
|
13 |
expect(await loginPo.getTitleText()).toEqual('Sign in'); |
|
14 |
}); |
|
15 |
|
|
16 |
it('Process login form!', async () => { |
|
17 |
await loginPo.navigateTo(); |
|
18 |
await loginPo.processForm(); |
|
19 |
expect(await loginPo.dashboardPresent()).toEqual(true); |
|
20 |
expect(await loginPo.loggedUser()).toEqual(' TESTINS'); |
|
21 |
await loginPo.logout(); |
|
22 |
}); |
|
23 |
}); |
e2e/src/login/login.po.ts | ||
---|---|---|
1 |
import { browser, by, element } from 'protractor'; |
|
2 |
|
|
3 |
export class LoginPo { |
|
4 |
async navigateTo(): Promise<unknown> { |
|
5 |
return browser.get(browser.baseUrl); |
|
6 |
} |
|
7 |
|
|
8 |
async getTitleText(): Promise<string> { |
|
9 |
return element(by.className('login-heading')).getText(); |
|
10 |
} |
|
11 |
|
|
12 |
async processForm(): Promise<unknown> { |
|
13 |
element(by.id('username')).sendKeys('testins'); |
|
14 |
element(by.id('password')).sendKeys('insert'); |
|
15 |
return element(by.id('loginButton')).click(); |
|
16 |
} |
|
17 |
|
|
18 |
async dashboardPresent(): Promise<unknown> { |
|
19 |
return element(by.className('dashboard')).isPresent(); |
|
20 |
} |
|
21 |
|
|
22 |
async loggedUser(): Promise<string> { |
|
23 |
return element(by.id('loggedUser')).getText(); |
|
24 |
} |
|
25 |
|
|
26 |
async logout(): Promise<unknown> { |
|
27 |
return element(by.id('logOut')).click(); |
|
28 |
} |
|
29 |
} |
e2e/src/nav-bar/nav-bar.e2e-spec.ts | ||
---|---|---|
1 |
import {LoginPo} from '../login/login.po'; |
|
2 |
import {NavBarPo} from './nav-bar.po'; |
|
3 |
|
|
4 |
|
|
5 |
describe('NavBar Module', () => { |
|
6 |
let navBarPo: NavBarPo; |
|
7 |
let loginPo: LoginPo |
|
8 |
|
|
9 |
beforeEach(async () => { |
|
10 |
navBarPo = new NavBarPo(); |
|
11 |
loginPo = new LoginPo(); |
|
12 |
await loginPo.navigateTo(); |
|
13 |
await loginPo.processForm(); |
|
14 |
}); |
|
15 |
|
|
16 |
afterEach(async () => { |
|
17 |
await loginPo.logout(); |
|
18 |
}); |
|
19 |
|
|
20 |
it('Add user!', async () => { |
|
21 |
await navBarPo.showUserInsert(); |
|
22 |
expect(await navBarPo.popupShown()).toEqual(true); |
|
23 |
await navBarPo.sendUserForm(); |
|
24 |
expect(await navBarPo.success()).toEqual(true); |
|
25 |
}); |
|
26 |
}); |
e2e/src/nav-bar/nav-bar.po.ts | ||
---|---|---|
1 |
import { browser, by, element } from 'protractor'; |
|
2 |
import * as moment from 'moment-timezone'; |
|
3 |
|
|
4 |
export class NavBarPo { |
|
5 |
async navigateTo(): Promise<unknown> { |
|
6 |
return browser.get(browser.baseUrl); |
|
7 |
} |
|
8 |
|
|
9 |
async showUserInsert(): Promise<unknown> { |
|
10 |
return element(by.id('addUser')).click(); |
|
11 |
} |
|
12 |
|
|
13 |
async popupShown(): Promise<boolean> { |
|
14 |
return element(by.className('p-dialog-resizable')).isPresent(); |
|
15 |
} |
|
16 |
|
|
17 |
async sendUserForm(): Promise<unknown> { |
|
18 |
const today = moment().format('YYYYMMDDHHMMSS').toString(); |
|
19 |
element(by.id('username')).sendKeys(today); |
|
20 |
element(by.id('password')).sendKeys('testuser'); |
|
21 |
element(by.id('userRealName')).sendKeys('testuser'); |
|
22 |
element(by.cssContainingText('option', 'testing units')).click(); |
|
23 |
element(by.cssContainingText('option', 'General user')).click(); |
|
24 |
return element(by.buttonText('Save')).click(); |
|
25 |
} |
|
26 |
|
|
27 |
async success(): Promise<boolean> { |
|
28 |
return element(by.cssContainingText('.p-toast-summary', 'Success')).isPresent(); |
|
29 |
} |
|
30 |
|
|
31 |
async showUnitInsert(): Promise<unknown> { |
|
32 |
return element(by.id('addUnit')).click(); |
|
33 |
} |
|
34 |
|
|
35 |
async sendUnitForm(today: string) { |
|
36 |
element(by.id('unitId')).sendKeys(today); |
|
37 |
element(by.id('unitDescription')).sendKeys(today); |
|
38 |
element(by.id('lat')).sendKeys(10); |
|
39 |
element(by.id('lon')).sendKeys(10); |
|
40 |
element(by.buttonText('Add sensor')).click(); |
|
41 |
await browser.sleep(3000); |
|
42 |
element(by.id('sensorId')).sendKeys(today); |
|
43 |
element(by.id('sensorName')).sendKeys(today) |
|
44 |
element(by.cssContainingText('option', 'test')).click(); |
|
45 |
element(by.cssContainingText('option', 'Strikes ( )')).click(); |
|
46 |
await browser.sleep(3000); |
|
47 |
return element(by.buttonText('Save')).click(); |
|
48 |
} |
|
49 |
|
|
50 |
async unitInList(today: string) { |
|
51 |
return element(by.cssContainingText('#p-accordiontab-0 .unitName', today)); |
|
52 |
} |
|
53 |
} |
e2e/src/sensor/sensor.e2e-spec.ts | ||
---|---|---|
1 |
import {LoginPo} from '../login/login.po'; |
|
2 |
import {DashboardPo} from '../dashboard/dashboard.po'; |
|
3 |
import {NavBarPo} from '../nav-bar/nav-bar.po'; |
|
4 |
import {SensorPo} from './sensor.po'; |
|
5 |
import {browser, by, element} from 'protractor'; |
|
6 |
|
|
7 |
|
|
8 |
describe('Sensor Module', () => { |
|
9 |
let loginPo: LoginPo; |
|
10 |
let navBarPo: NavBarPo; |
|
11 |
let sensorPo: SensorPo; |
|
12 |
let dashboardPo: DashboardPo |
|
13 |
|
|
14 |
beforeEach(async () => { |
|
15 |
sensorPo = new SensorPo(); |
|
16 |
loginPo = new LoginPo(); |
|
17 |
navBarPo = new NavBarPo(); |
|
18 |
dashboardPo = new DashboardPo(); |
|
19 |
await loginPo.navigateTo(); |
|
20 |
await loginPo.processForm(); |
|
21 |
}); |
|
22 |
|
|
23 |
afterEach(async () => { |
|
24 |
await loginPo.logout(); |
|
25 |
}); |
|
26 |
|
|
27 |
it('Display sensor page', async () => { |
|
28 |
await dashboardPo.clickToAccordionTab(); |
|
29 |
await browser.sleep(500); |
|
30 |
await sensorPo.clickById('test sensor Temp'); |
|
31 |
expect(await element(by.className('container graph')).isPresent()).toEqual(true); |
|
32 |
expect(await element(by.id('view')).isPresent()).toEqual(true); |
|
33 |
expect(await element(by.xpath('//div[contains(text(), \'test sensor Temp\')]')).isPresent()).toEqual(true); |
|
34 |
expect(await element(by.xpath('//div[contains(@class, \'p-listbox-list-wrapper\')]')).isPresent()).toEqual(false); |
|
35 |
expect(await element(by.xpath('//span[contains(text(), \'Get data\')]')).isPresent()).toEqual(false); |
|
36 |
await sensorPo.setDateInXpath('//*[contains(@id, \'from\')]//input'); |
|
37 |
expect(await element(by.xpath('//div[contains(@class, \'p-listbox-list-wrapper\')]')).isPresent()).toEqual(true); |
|
38 |
expect(await element(by.xpath('//span[contains(text(), \'Get data\')]')).isPresent()).toEqual(true); |
|
39 |
}); |
|
40 |
|
|
41 |
}); |
e2e/src/sensor/sensor.po.ts | ||
---|---|---|
1 |
import {browser, by, element} from 'protractor'; |
|
2 |
|
|
3 |
export class SensorPo { |
|
4 |
async clickByXpath(xPath: string): Promise<unknown> { |
|
5 |
return element(by.xpath(xPath)).click(); |
|
6 |
} |
|
7 |
|
|
8 |
async clickById(id: string): Promise<unknown> { |
|
9 |
return element(by.id(id)).click(); |
|
10 |
} |
|
11 |
|
|
12 |
async setDateInXpath(xPath: string): Promise<unknown> { |
|
13 |
element(by.xpath(xPath)).click(); |
|
14 |
await browser.sleep(500); |
|
15 |
element(by.className('p-datepicker-prev-icon')).click(); |
|
16 |
await browser.sleep(500); |
|
17 |
return element(by.xpath('//td[contains(@class, \'ng-star-inserted\') and not(contains(@class, \'p-datepicker-other-month\'))]')) |
|
18 |
.click(); |
|
19 |
} |
|
20 |
} |
e2e/src/unit/unit.e2e-spec.ts | ||
---|---|---|
1 |
import {LoginPo} from '../login/login.po'; |
|
2 |
import {DashboardPo} from '../dashboard/dashboard.po'; |
|
3 |
import {NavBarPo} from '../nav-bar/nav-bar.po'; |
|
4 |
import {browser, by, element} from 'protractor'; |
|
5 |
import {UnitPo} from './unit.po'; |
|
6 |
|
|
7 |
|
|
8 |
describe('Unit Module', () => { |
|
9 |
let loginPo: LoginPo; |
|
10 |
let navBarPo: NavBarPo; |
|
11 |
let unitPo: UnitPo; |
|
12 |
let dashboardPo: DashboardPo |
|
13 |
|
|
14 |
beforeEach(async () => { |
|
15 |
unitPo = new UnitPo(); |
|
16 |
loginPo = new LoginPo(); |
|
17 |
navBarPo = new NavBarPo(); |
|
18 |
dashboardPo = new DashboardPo(); |
|
19 |
await loginPo.navigateTo(); |
|
20 |
await loginPo.processForm(); |
|
21 |
}); |
|
22 |
|
|
23 |
afterEach(async () => { |
|
24 |
await loginPo.logout(); |
|
25 |
}); |
|
26 |
|
|
27 |
it('Display Unit page', async () => { |
|
28 |
await unitPo.clickById('test insert unit4'); |
|
29 |
expect(await element(by.className('container graph')).isPresent()).toEqual(true); |
|
30 |
expect(await element(by.id('vega_container_10300')).isPresent()).toEqual(true); |
|
31 |
expect(await element(by.id('vega_container_12300')).isPresent()).toEqual(true); |
|
32 |
expect(await element(by.xpath('//div[contains(text(), \'test insert unit4\')]')).isPresent()).toEqual(true); |
|
33 |
expect(await element(by.xpath('//div[contains(@class, \'p-listbox-list-wrapper\')]')).isPresent()).toEqual(false); |
|
34 |
expect(await element(by.xpath('//span[contains(text(), \'Get data\')]')).isPresent()).toEqual(false); |
|
35 |
await unitPo.setDateInXpath('//*[contains(@id, \'from\')]//input'); |
|
36 |
expect(await element(by.xpath('//div[contains(@class, \'p-listbox-list-wrapper\')]')).isPresent()).toEqual(true); |
|
37 |
expect(await element(by.xpath('//span[contains(text(), \'Get data\')]')).isPresent()).toEqual(true); |
|
38 |
expect(await element(by.id('1030001')).isPresent()).toEqual(true); |
|
39 |
expect(await element(by.id('1230001')).isPresent()).toEqual(true); |
|
40 |
await browser.sleep(500); |
|
41 |
await unitPo.selectSensor('1030001'); |
|
42 |
expect(await element(by.xpath('//input[contains(@id, \'1030001\')]')).isSelected()).toEqual(true); |
|
43 |
await unitPo.selectSensor('1230001'); |
|
44 |
await browser.sleep(500); |
|
45 |
expect(await element(by.xpath('//input[contains(@id, \'1230001\')]')).isSelected()).toEqual(true); |
|
46 |
}); |
|
47 |
|
|
48 |
}); |
e2e/src/unit/unit.po.ts | ||
---|---|---|
1 |
import {browser, by, element} from 'protractor'; |
|
2 |
|
|
3 |
export class UnitPo { |
|
4 |
async clickByXpath(xPath: string): Promise<unknown> { |
|
5 |
return element(by.xpath(xPath)).click(); |
|
6 |
} |
|
7 |
|
|
8 |
async clickById(id: string): Promise<unknown> { |
|
9 |
return element(by.id(id)).click(); |
|
10 |
} |
|
11 |
|
|
12 |
async setDateInXpath(xPath: string): Promise<unknown> { |
|
13 |
element(by.xpath(xPath)).click(); |
|
14 |
await browser.sleep(500); |
|
15 |
element(by.className('p-datepicker-prev-icon')).click(); |
|
16 |
await browser.sleep(500); |
|
17 |
return element(by.xpath('//td[contains(@class, \'ng-star-inserted\') and not(contains(@class, \'p-datepicker-other-month\'))]')) |
|
18 |
.click(); |
|
19 |
} |
|
20 |
|
|
21 |
async selectSensor(selectSensorId: string): Promise<unknown> { |
|
22 |
return element(by.id(selectSensorId)).click(); |
|
23 |
} |
|
24 |
} |
src/app/dashboard/components/dashboard.component.html | ||
---|---|---|
5 | 5 |
<p-accordionTab *ngFor="let unit of units"> |
6 | 6 |
<p-header [className]="'dashboard-unit-wrapper'"> |
7 | 7 |
<div [className]="'row dashboard-unit'"> |
8 |
<div class="col-sm-5 col-md-7 col-xl-9"><h3>{{ unit.unit.description}}</h3></div> |
|
8 |
<div class="col-sm-5 col-md-7 col-xl-9"><h3 class="unitName">{{ unit.unit.description}}</h3></div>
|
|
9 | 9 |
<div class="col-sm-7 col-md-5 col-xl-3 dashboard-unit-heading"> |
10 |
<p-button label="Sensors graph" icon="pi pi-chart-line" [routerLink]="['/dashboard/unit', unit.unit.unitId]" [queryParams]="{unitDescription: unit.unit.description}"></p-button> |
|
10 |
<p-button [id]="unit.unit.description" label="Sensors graph" icon="pi pi-chart-line" [routerLink]="['/dashboard/unit', unit.unit.unitId]" [queryParams]="{unitDescription: unit.unit.description}"></p-button>
|
|
11 | 11 |
<div class="dashboard-button-separator"></div> |
12 |
<p-button icon="pi pi-cog" styleClass="p-button-warning" (click)="showItems($event, unit.unit); menu.toggle($event)"></p-button> |
|
12 |
<p-button [id]="'manipulation_'+unit.unit.unitId" icon="pi pi-cog" styleClass="p-button-warning" (click)="showItems($event, unit.unit); menu.toggle($event)"></p-button>
|
|
13 | 13 |
<p-menu #menu [popup]="true" [model]="items" [appendTo]="'body'" [baseZIndex]="50"></p-menu> |
14 | 14 |
</div> |
15 | 15 |
</div> |
src/app/dashboard/components/sensor-insert-popup/sensor-insert-popup.component.html | ||
---|---|---|
48 | 48 |
<p-footer> |
49 | 49 |
<div class="popup-buttons-wrapper"> |
50 | 50 |
<p-button type="button" (click)="addSensor()" class="pr-2">Add Sensor</p-button> |
51 |
<p-button *ngIf="sensors > 1" type="button" (click)="removeSensor()" class="pr-2">Remove last sensor</p-button> |
|
51 | 52 |
<div> |
52 | 53 |
<p-button icon="pi pi-times" (click)="close()" label="Close" class="pr-2"></p-button> |
53 | 54 |
<p-button icon="pi pi-check" (click)="processSensorInsertion()" type="submit" label="Save" class="pr-2"></p-button> |
src/app/dashboard/components/sensors/sensors.component.html | ||
---|---|---|
5 | 5 |
</div> |
6 | 6 |
</div> |
7 | 7 |
<div class="col-sm-5 col-md-4 col-lg-3 col-xl-2 dashboard-sensor-heading"> |
8 |
<button pButton type="button" label="View graph" [routerLink]="['/dashboard/unit', unit.unitId, 'sensor', sensor.sensorId]" [queryParams]="{unitName: unit.description}" title="Sensor" icon="pi pi-chart-line"></button> |
|
8 |
<button [id]="sensor.sensorName" pButton type="button" label="View graph" [routerLink]="['/dashboard/unit', unit.unitId, 'sensor', sensor.sensorId]" [queryParams]="{unitName: unit.description}" title="Sensor" icon="pi pi-chart-line"></button>
|
|
9 | 9 |
<ng-container *ngIf="loggedUser?.userInfo?.rightsId == 0 || loggedUser?.userInfo?.rightsId == 1"> |
10 | 10 |
<div class="dashboard-button-separator"></div> |
11 |
<p-button icon="pi pi-cog" styleClass="p-button-warning" (click)="showItems($event, sensor); menu.toggle($event)"></p-button> |
|
11 |
<p-button [id]="'manipulation_sensor_'+sensor.sensorId" icon="pi pi-cog" styleClass="p-button-warning" (click)="showItems($event, sensor); menu.toggle($event)"></p-button>
|
|
12 | 12 |
<p-menu #menu [popup]="true" [model]="items" [appendTo]="'body'" [baseZIndex]="50"></p-menu> |
13 | 13 |
</ng-container> |
14 | 14 |
</div> |
src/app/sensor/components/sensor.component.html | ||
---|---|---|
29 | 29 |
<div class="input-group-prepend"> |
30 | 30 |
<span class="input-group-text text-color-date background-date-color"><i class="fa fa-calendar-alt" aria-hidden="false"></i></span> |
31 | 31 |
</div> |
32 |
<p-calendar [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [(ngModel)]="from" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar>
|
|
32 |
<p-calendar id="from" [(ngModel)]="from" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar>
|
|
33 | 33 |
</div> |
34 | 34 |
</div> |
35 | 35 |
<div class="graph-range-dates-separator"></div> |
... | ... | |
38 | 38 |
<div class="input-group-prepend"> |
39 | 39 |
<span class="input-group-text text-color-date background-date-color"><i class="fa fa-calendar-alt" aria-hidden="false"></i></span> |
40 | 40 |
</div> |
41 |
<p-calendar [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [(ngModel)]="to" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar>
|
|
41 |
<p-calendar id="to" [(ngModel)]="to" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar>
|
|
42 | 42 |
</div> |
43 | 43 |
</div> |
44 | 44 |
<div> |
src/app/shared/nav-bar/components/nav-bar.component.html | ||
---|---|---|
30 | 30 |
<h2 id="loggedUser"><i class="fas fa-user"></i> <strong>{{loggedUser?.userInfo?.userName.toUpperCase()}}</strong></h2> |
31 | 31 |
</li> |
32 | 32 |
<li class="nav-item"> |
33 |
<a class='nav-link' [routerLink]="['/login']" (click)="logOut()"><h2><i class="fas fa-sign-out-alt"></i> Logout</h2></a> |
|
33 |
<a class='nav-link' id="logOut" [routerLink]="['/login']" (click)="logOut()"><h2><i class="fas fa-sign-out-alt"></i> Logout</h2></a>
|
|
34 | 34 |
</li> |
35 | 35 |
</ul> |
36 | 36 |
</div> |
src/app/unit/components/unit.component.html | ||
---|---|---|
13 | 13 |
<div class="input-group-prepend"> |
14 | 14 |
<span class="input-group-text text-color-date background-date-color"><i class="fa fa-calendar-alt" aria-hidden="false"></i></span> |
15 | 15 |
</div> |
16 |
<p-calendar [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [(ngModel)]="from" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar> |
|
16 |
<p-calendar id="from" [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [(ngModel)]="from" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar>
|
|
17 | 17 |
</div> |
18 | 18 |
</div> |
19 | 19 |
<div class="graph-range-dates-separator"></div> |
... | ... | |
22 | 22 |
<div class="input-group-prepend"> |
23 | 23 |
<span class="input-group-text text-color-date background-date-color"><i class="fa fa-calendar-alt" aria-hidden="false"></i></span> |
24 | 24 |
</div> |
25 |
<p-calendar [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [(ngModel)]="to" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar> |
|
25 |
<p-calendar id="to" [style]="{'width':'100%'}" [inputStyle]="{'width':'100%'}" [(ngModel)]="to" [showTime]="true" (onSelect)="aggregationShow()" [maxDate]="today" showButtonBar="true"></p-calendar>
|
|
26 | 26 |
</div> |
27 | 27 |
</div> |
28 | 28 |
<div> |
... | ... | |
50 | 50 |
</div> |
51 | 51 |
<ng-container *ngFor="let sensor of sensors"> |
52 | 52 |
<div *ngIf="sensor.sensorId.toString().slice(0, 5) === group" class="p-field-checkbox"> |
53 |
<p-checkbox name="{{group}}" [value]="sensor.sensorId.toString()" [(ngModel)]="selectedSensors" [inputId]="sensor.sensorId.toString()" (onChange)="addSensorToGraph(sensor.sensorId.toString(), $event)"></p-checkbox> |
|
53 |
<p-checkbox [id]="sensor.sensorId" name="{{group}}" [value]="sensor.sensorId.toString()" [(ngModel)]="selectedSensors" [inputId]="sensor.sensorId.toString()" (onChange)="addSensorToGraph(sensor.sensorId.toString(), $event)"></p-checkbox>
|
|
54 | 54 |
<label>{{sensor.sensorName}}</label> |
55 | 55 |
</div> |
56 | 56 |
</ng-container> |
Také k dispozici: Unified diff
Re #8858 - Testování aplikace
+ new tests to implemented use cases