-
Notifications
You must be signed in to change notification settings - Fork 2
/
08_masterRecord.test.js
167 lines (141 loc) · 5.51 KB
/
08_masterRecord.test.js
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
const { sleep, openMenuItem, login, waitForRowCountData, switchToFormPerspective,
inputByPressingKeys, switchLanguageTo, waitForFocus,
switchToTablePerspective, catchRequests, beforeEachTest, afterEachTest, xPathContainsClass, waitForRowCount,
waitForRowSelected
} = require('./testTools');
const {widgetsMenuItemId,topMenuHeader, allDataTypesLazyDataViewId,
masterDataViewId, sectionsMenuItemId, masterDetailLazyLoadedMenuItemId, allDataTypesLazyMenuItemsId, detailDataViewId
} = require("./modelIds");
const { clearScreenConfiguration, restoreWidgetSectionTestMasterForRefreshTest,
restoreAllDataTypesTable} = require("./dbTools");
const expect = require("expect");
const {openFilters, setFilter} = require("./filterTestTools");
const {installMouseHelper} = require("./instalMouseHelper_");
let browser;
let page;
beforeAll(async() => {
await clearScreenConfiguration();
await restoreWidgetSectionTestMasterForRefreshTest();
});
beforeEach(async () => {
[browser, page] = await beforeEachTest()
});
afterEach(async () => {
await afterEachTest(browser);
browser = undefined;
});
const allDataTypes_dataViewId = "dataView_e67865b0-ce91-413c-bed7-1da486399633";
const master_dataViewId = "dataView_775fa5ea-fa75-40a7-8c39-7828f7cdf508";
const details_dataViewId = "dataView_b11ffa85-7507-475c-af50-ef08fd56072c";
const subDetails_dataViewId = "dataView_3430ae94-8642-4cf8-9e68-9df36dcf571c";
const text1InputId = "editor_cb584956-8f34-4d95-852e-eff4680a2673";
async function cancelRowChange() {
const cancelButton = await page.waitForSelector(
`#cancelRecordChangeButton`,
{visible: true}
);
await cancelButton.click();
}
async function checkDataViewContainsSingleRow(page, dataViewId, tabName) {
const [button] = await page.$x(`//div[@title="${tabName}"]`);
if (!button) {
throw Error(`tab ${tabName} not found.`);
}
await button.click();
await sleep(300);
await waitForRowCountData(page, dataViewId, 1);
}
describe("Html client", () => {
it("Should ask user whether to save changes after changing row", async () => {
await restoreAllDataTypesTable();
await switchLanguageTo({locale: "cs-CZ", page: page});
await login(page);
await installMouseHelper(page);
await openMenuItem(
page,
[
topMenuHeader,
widgetsMenuItemId,
sectionsMenuItemId,
allDataTypesLazyMenuItemsId,
]);
await waitForRowCountData(page, allDataTypes_dataViewId,2099);
await sleep(500);
const formPerspectiveButton = await page.$(`#${allDataTypesLazyDataViewId} .formPerspectiveButton`);
await formPerspectiveButton.click();
await sleep(500);
const nextButton = await page.$(`#${allDataTypesLazyDataViewId} .nextRowButton`);
await nextButton.click();
await waitForRowSelected(page,allDataTypesLazyDataViewId, 2);
await page.focus(`#${text1InputId}`)
await page.waitForFunction(`document.activeElement == document.getElementById("${text1InputId}")`);
await page.keyboard.type("test")
await sleep(500);
const tablePerspectiveButton = await page.$(`#${allDataTypesLazyDataViewId} .tablePerspectiveButton `);
await tablePerspectiveButton.click();
const tableArea = await page.$(`#${allDataTypesLazyDataViewId} [class*='_cellAreaContainer']`);
const box = await tableArea.boundingBox();
// Click inside the table
await sleep(500);
await page.mouse.click(
box.x + 50,
box.y + 90
);
await cancelRowChange();
// Click add row button
await sleep(500);
const addRowButton = await page.$(`#${allDataTypesLazyDataViewId} .addRow`);
await addRowButton.click();
await cancelRowChange();
// Click copy row button
await sleep(500);
const copyRowButton = await page.$(`#${allDataTypesLazyDataViewId} .copyRow`);
await copyRowButton.click();
await cancelRowChange();
// Click first row button
await sleep(500);
const firstRowButton = await page.$(`#${allDataTypesLazyDataViewId} .firstRowButton`);
await firstRowButton.click();
await cancelRowChange();
// Click previous row button
await sleep(500);
const previousRowButton = await page.$(`#${allDataTypesLazyDataViewId} .previousRowButton`);
await previousRowButton.click();
await cancelRowChange();
// Click next row button
await sleep(500);
const nextRowButton = await page.$(`#${allDataTypesLazyDataViewId} .nextRowButton`);
await nextRowButton.click();
await cancelRowChange();
// Click last row button
await sleep(500);
const lastRowButton = await page.$(`#${allDataTypesLazyDataViewId} .lastRowButton`);
await lastRowButton.click();
await cancelRowChange();
});
it("Should reload all data after refresh is pressed", async () => {
await restoreAllDataTypesTable();
await switchLanguageTo({locale: "cs-CZ", page: page});
await login(page);
await installMouseHelper(page);
await openMenuItem(
page,
[
topMenuHeader,
widgetsMenuItemId,
sectionsMenuItemId,
masterDetailLazyLoadedMenuItemId,
]);
await waitForRowCountData(page, master_dataViewId, 2);
await sleep(500);
const [button] = await page.$x(`//div[@id="refreshButton"]`);
if (!button) {
throw Error(`#refreshButton not found.`);
}
await button.click();
await waitForRowCountData(page, master_dataViewId, 2);
await sleep(500);
await checkDataViewContainsSingleRow(page, details_dataViewId, "Details");
await checkDataViewContainsSingleRow(page, subDetails_dataViewId, "Details-Subdetail");
});
});