Revize 25e66baf
Přidáno uživatelem Jakub Hlaváč před téměř 4 roky(ů)
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 |
} |
Také k dispozici: Unified diff
Re #8858 - Testování aplikace
+ new tests to implemented use cases