Skip to content

Commit 84eb48d

Browse files
authored
Merge pull request #19 from NativeScript/tgpetrov/datetime
feat. add new UI element for picking date time simultaneously
2 parents 9523312 + 6fbacef commit 84eb48d

27 files changed

+1555
-366
lines changed

README.md

Lines changed: 75 additions & 12 deletions
Large diffs are not rendered by default.
Loading
Loading

demo-angular/e2e/tests.e2e.ts

Lines changed: 103 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ describe("DateTimePicker", () => {
6565
expect(title).to.exist;
6666
});
6767

68+
it("Should expand date picker field examples", async () => {
69+
const dateFieldTitle = await driver.findElementByText("DatePickerField", SearchOptions.contains);
70+
expect(dateFieldTitle).to.exist;
71+
await dateFieldTitle.click();
72+
});
73+
6874
it("Should select date and verify value of picker field", async () => {
6975
const selectDateField = await driver.findElementByText("select date", SearchOptions.contains);
7076
await selectDateField.click();
@@ -74,15 +80,6 @@ describe("DateTimePicker", () => {
7480
expect(dateSelected).to.exist;
7581
});
7682

77-
it("Should select time and verify value of picker field", async () => {
78-
const selectTimeField = await driver.findElementByText("select time", SearchOptions.contains);
79-
await selectTimeField.click();
80-
const timeString = await getPickerTime(driver, 12);
81-
await clickOkBtn(driver);
82-
const timeSelected = await driver.findElementByText(timeString, SearchOptions.contains);
83-
expect(timeSelected).to.exist;
84-
});
85-
8683
it("Should select date from min/max limited field", async () => {
8784
const minMaxDatePicker = await driver.findElementByText("tap to select", SearchOptions.contains);
8885
await minMaxDatePicker.click();
@@ -93,22 +90,6 @@ describe("DateTimePicker", () => {
9390
expect(dateSelected).to.exist;
9491
});
9592

96-
it("Should open 12h time format and verify wheelers values", async () => {
97-
const twelveHourFormat = await driver.findElementByText("4:00 PM", SearchOptions.contains);
98-
await twelveHourFormat.click();
99-
const timeString = await getPickerTime(driver, 12);
100-
await clickOkBtn(driver);
101-
expect(timeString).to.equal("4:00 PM");
102-
});
103-
104-
it("Should open 24h format and verify wheeler value", async () => {
105-
const twentyFourFormat = await scrollToElement(driver, "16:00", Direction.down);
106-
await twentyFourFormat.click();
107-
const timeString = await getPickerTime(driver, 24);
108-
await clickOkBtn(driver);
109-
expect(timeString).to.equal("16:00");
110-
});
111-
11293
it("Should verify modified texts field for date picker", async () => {
11394
await scrollToElement(driver, "preferred locale: en_US", Direction.down);
11495
const pickers = await driver.findElementsByText("tap to choose");
@@ -126,23 +107,8 @@ describe("DateTimePicker", () => {
126107
expect(dateString).to.exist;
127108
});
128109

129-
it("Should verify modified texts field for time picker", async () => {
130-
const datePicker = await driver.findElementByText("tap to choose");
131-
await datePicker.click();
132-
const time = await getPickerTime(driver, 12);
133-
const approveBtn = await driver.findElementByText("Approve", SearchOptions.contains);
134-
const rejectBtn = await driver.findElementByText("Reject", SearchOptions.contains);
135-
const title = await driver.findElementByText("Confirm predefined time selection", SearchOptions.contains);
136-
expect(approveBtn).to.exist;
137-
expect(rejectBtn).to.exist;
138-
expect(title).to.exist;
139-
await approveBtn.click();
140-
const dateString = await driver.findElementByText(time);
141-
expect(dateString).to.exist;
142-
});
143-
144110
it("Should select date from de_De locale picker and verify format", async () => {
145-
await scrollToElement(driver, "zeit wählen", Direction.down);
111+
await scrollToElement(driver, "datum auswählen", Direction.down);
146112
const deLocale = await driver.findElementByText("preferred locale: de_DE");
147113
expect(deLocale).to.exist;
148114
const datePicker = await driver.findElementByText("datum auswählen", SearchOptions.contains);
@@ -181,56 +147,35 @@ describe("DateTimePicker", () => {
181147
expect(dateString).to.exist;
182148
});
183149

184-
it("Should select time from de_DE locale picker and verify format", async () => {
185-
const timePicker = await driver.findElementByText("zeit wählen", SearchOptions.contains);
186-
await timePicker.click();
187-
const time = await getPickerTime(driver, 24);
188-
let acceptBtn;
189-
let rejectBtn;
190-
if(driver.isAndroid){
191-
let buttons = await driver.findElementsByClassName("android.widget.Button");
192-
acceptBtn = buttons[5];
193-
rejectBtn = buttons[4];
194-
}
195-
else{
196-
acceptBtn = await driver.findElementByText("Bestätigen", SearchOptions.exact);
197-
rejectBtn = await driver.findElementByText("Stornieren", SearchOptions.exact);
198-
}
199-
const title = await driver.findElementByText("Zeit wählen", SearchOptions.exact);
200-
expect(acceptBtn).to.exist;
201-
expect(rejectBtn).to.exist;
202-
expect(title).to.exist;
203-
await acceptBtn.click();
204-
const dateField = await driver.findElementByText(time);
205-
expect(time).to.exist;
206-
});
207-
208150
it("Should scroll to custom format and verify values", async () => {
209151
await scrollToElement(driver, "binding", Direction.down);
210152
const customFromatLabel = await driver.findElementByText("custom format");
211153
expect(customFromatLabel).to.exist;
212154
const customFormatDate = await driver.findElementByText("date: 24 February 2019", SearchOptions.exact);
213155
expect(customFormatDate).to.exist;
214-
const customFormatTime = await driver.findElementByText("time: 01:00", SearchOptions.exact);
215-
expect(customFormatTime).to.exist;
156+
});
157+
158+
it("Should scroll to css styled DatePicker and verify picker style", async () => {
159+
let cssPickers = await driver.findElementsByText("Feb 24, 2019", SearchOptions.exact);
160+
await cssPickers[cssPickers.length - 1].click();
161+
await getPickerDate(driver);
162+
await driver.compareScreen("cssDatePicker");
163+
await clickOkBtn(driver);
216164
});
217165

218166
it("Should scroll to binding example and verify picker and label values", async () => {
219-
await scrollToElement(driver, "css applied", Direction.down);
167+
await scrollToElement(driver, "TimePickerField", Direction.down);
220168
const bindingLabel = await driver.findElementByText("binding", SearchOptions.exact);
221169
expect(bindingLabel).to.exist;
222170
let selector = driver.isAndroid ? "android.widget.EditText" : "XCUIElementTypeTextField"
223171
let fields = await driver.findElementsByClassName(selector);
224-
let timeField;
225172
let dateField;
226173
if(driver.isAndroid){
227-
timeField = fields[2];
228-
dateField = fields[1];
174+
dateField = fields[3];
229175
}
230176
else{
231-
let index = fields.length - 3;
177+
let index = fields.length;
232178
console.log("index: " + index);
233-
timeField = fields[index];
234179
dateField = fields[index - 1];
235180
}
236181
await dateField.click();
@@ -243,13 +188,84 @@ describe("DateTimePicker", () => {
243188
let bindingDate = await driver.findElementByText(dateLabel, SearchOptions.contains);
244189
});
245190

246-
it("Should scroll to css styled DatePicker and verify picker style", async () => {
247-
await scrollToElement(driver, "tap to select time", Direction.down);
248-
let cssPickers = await driver.findElementsByText("Feb 24, 2019", SearchOptions.exact);
249-
await cssPickers[cssPickers.length - 1].click();
250-
await getPickerDate(driver);
251-
await driver.compareScreen("cssDatePicker");
191+
it("Should expand time picker field examples", async () => {
192+
const timeFieldTitle = await driver.findElementByText("TimePickerField", SearchOptions.contains);
193+
expect(timeFieldTitle).to.exist;
194+
await timeFieldTitle.click();
195+
});
196+
197+
it("Should select time and verify value of picker field", async () => {
198+
const selectTimeField = await driver.findElementByText("select time", SearchOptions.contains);
199+
await selectTimeField.click();
200+
const timeString = await getPickerTime(driver, 12);
252201
await clickOkBtn(driver);
202+
const timeSelected = await driver.findElementByText(timeString, SearchOptions.contains);
203+
expect(timeSelected).to.exist;
204+
});
205+
206+
it("Should open 12h time format and verify wheelers values", async () => {
207+
const twelveHourFormat = await driver.findElementByText("4:00 PM", SearchOptions.contains);
208+
await twelveHourFormat.click();
209+
const timeString = await getPickerTime(driver, 12);
210+
await clickOkBtn(driver);
211+
expect(timeString).to.equal("4:00 PM");
212+
});
213+
214+
it("Should open 24h format and verify wheeler value", async () => {
215+
const twentyFourFormat = await scrollToElement(driver, "16:00", Direction.down);
216+
await twentyFourFormat.click();
217+
const timeString = await getPickerTime(driver, 24);
218+
await clickOkBtn(driver);
219+
expect(timeString).to.equal("16:00");
220+
});
221+
222+
it("Should verify modified texts field for time picker", async () => {
223+
await scrollToElement(driver, "tap to choose", Direction.down);
224+
const datePicker = await driver.findElementByText("tap to choose");
225+
await datePicker.click();
226+
const time = await getPickerTime(driver, 12);
227+
const approveBtn = await driver.findElementByText("Approve", SearchOptions.contains);
228+
const rejectBtn = await driver.findElementByText("Reject", SearchOptions.contains);
229+
const title = await driver.findElementByText("Confirm predefined time selection", SearchOptions.contains);
230+
expect(approveBtn).to.exist;
231+
expect(rejectBtn).to.exist;
232+
expect(title).to.exist;
233+
await approveBtn.click();
234+
const dateString = await driver.findElementByText(time);
235+
expect(dateString).to.exist;
236+
});
237+
238+
it("Should select time from de_DE locale picker and verify format", async () => {
239+
await scrollToElement(driver, "zeit wählen", Direction.down);
240+
const timePicker = await driver.findElementByText("zeit wählen", SearchOptions.contains);
241+
await timePicker.click();
242+
const time = await getPickerTime(driver, 24);
243+
let acceptBtn;
244+
let rejectBtn;
245+
if(driver.isAndroid){
246+
let buttons = await driver.findElementsByClassName("android.widget.Button");
247+
acceptBtn = buttons[5];
248+
rejectBtn = buttons[4];
249+
}
250+
else{
251+
acceptBtn = await driver.findElementByText("Bestätigen", SearchOptions.exact);
252+
rejectBtn = await driver.findElementByText("Stornieren", SearchOptions.exact);
253+
}
254+
const title = await driver.findElementByText("Zeit wählen", SearchOptions.exact);
255+
expect(acceptBtn).to.exist;
256+
expect(rejectBtn).to.exist;
257+
expect(title).to.exist;
258+
await acceptBtn.click();
259+
const dateField = await driver.findElementByText(time);
260+
expect(time).to.exist;
261+
});
262+
263+
it("Should scroll to custom format and verify values", async () => {
264+
await scrollToElement(driver, "binding", Direction.down);
265+
const customFromatLabel = await driver.findElementByText("custom format");
266+
expect(customFromatLabel).to.exist;
267+
const customFormatTime = await driver.findElementByText("time: 01:00", SearchOptions.exact);
268+
expect(customFormatTime).to.exist;
253269
});
254270

255271
it("Should scroll to css styled TimePicker and verify picker style", async () => {
@@ -260,7 +276,15 @@ describe("DateTimePicker", () => {
260276
await clickOkBtn(driver);
261277
});
262278

279+
it("Should expand custom buttons examples", async () => {
280+
await scrollToElement(driver, "Custom Buttons", Direction.down);
281+
const customButtonsTitle = await driver.findElementByText("Custom Buttons", SearchOptions.contains);
282+
expect(customButtonsTitle).to.exist;
283+
await customButtonsTitle.click();
284+
});
285+
263286
it("Should tap button to select date and verify button text", async () => {
287+
await scrollToElement(driver, "tap to select date and time", Direction.down);
264288
let dateButton = await driver.findElementByText("tap to select date", SearchOptions.contains);
265289
await dateButton.click();
266290
const date = await getPickerDate(driver);

demo-angular/src/app/home/home.component.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
color: #303F9F;
77
}
88

9+
.header {
10+
font-size: 16;
11+
margin-top: 12;
12+
margin-bottom: 6;
13+
color: white;
14+
background-color: #2196F3;
15+
text-align: center;
16+
}
17+
918
label {
1019
padding: 6 4;
1120
}

0 commit comments

Comments
 (0)