Skip to content

Commit dd283c5

Browse files
authored
Go to current changed place (#241)
* changing go to current button position * lint fix * fixing e2e
1 parent ec692cd commit dd283c5

33 files changed

+632
-165
lines changed

CAHNGELOG.md renamed to CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
<a name="2.6.0"></a>
5+
# [2.6.0] (2017-00-00)
6+
7+
### Features
8+
- none
9+
10+
### UI/UX Changes
11+
- Moving go to current button inside the navigation component (#commit).
12+
13+
### Bug Fixed
14+
- none
15+
16+
### Breaking Changes
17+
- Go to current button moved from input element to the navigation component (#commit).
18+
19+
20+
421
<a name="2.5.1"></a>
522
# [2.5.1] (2017-10-12)
623

e2e/app.po.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {$, $$, browser, by, element} from 'protractor';
22

33
export class DemoPage {
4-
private popupSelector = 'body > div .dp-popup';
4+
private popupSelector = '.dp-popup.dp-main';
55
body = $('body');
66
dayPickerInput = $('#datePicker input');
77
timePickerInput = $('#timePicker input');
88
daytimePickerInput = $('#daytimePicker input');
99
daytimeDirectiveInput = $('#daytimeDirective input');
1010
dayDirectiveInput = $('#dayDirective input');
11-
dayReactiveDirectivePickerInput = $('#datePickerDirDayReactive input');
11+
dayDirectiveReactiveInput = $('#datePickerDirDayReactive input');
1212
monthDirectiveInput = $('#datePickerDirMonth input');
1313
timeSelectDirectiveInput = $('#timePickerDirDay input');
1414
datePickerPopup = $(this.popupSelector);
@@ -28,7 +28,7 @@ export class DemoPage {
2828
weekDayNames = $$(`${this.popupSelector} .dp-weekdays`);
2929
weekDayInline = $$(`.dp-demo-container .dp-weekdays`);
3030
calendarContainer = $$(`${this.popupSelector} .dp-calendar-container `);
31-
currentLocationBtn = $(`#datePicker .dp-current-location-btn`);
31+
currentLocationBtn = $(`${this.popupSelector} .dp-current-location-btn`);
3232
themeOnRadio = $('#themeOn');
3333
themeOffRadio = $('#themeOff');
3434
openOnFocusRadioOn = $('#yesOpenOnFocus');
@@ -55,6 +55,7 @@ export class DemoPage {
5555
yearFormat = $('#yearFormat');
5656
localeOptions = $('#locale');
5757
hideGoToCurrentRadio = $('#hideGoToCurrent');
58+
showGoToCurrentRadio = $('#showGoToCurrent');
5859
pickerEnabledRadio = $('#inputEnabledRadio');
5960
pickerDisabledRadio = $('#inputDisabledRadio');
6061
enableRequiredValidationRadio = $('#enableRequiredRadio');
File renamed without changes.

e2e/current-btn-e2e.spec.ts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import {DemoPage} from './app.po';
2+
import * as moment from 'moment';
3+
import {browser, ElementFinder} from 'protractor';
4+
5+
describe('dpDayPicker dayPicker', () => {
6+
7+
let page: DemoPage;
8+
9+
beforeEach(() => {
10+
page = new DemoPage();
11+
page.navigateTo();
12+
});
13+
14+
it('should check if go to current location btn is working as expected', () => {
15+
const currentMonth = moment().format('MMM, YYYY');
16+
const currentYear = moment().format('YYYY');
17+
const prevMonth = moment().subtract(1, 'month').format('MMM, YYYY');
18+
const prevYear = moment().subtract(1, 'year').format('YYYY');
19+
20+
const commonDayCalendar = (menu: ElementFinder, input: ElementFinder) => {
21+
menu.click();
22+
input.click();
23+
page.showGoToCurrentRadio.click();
24+
expect(page.currentLocationBtn.isPresent()).toBe(true);
25+
expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(currentMonth);
26+
page.dayCalendarLeftNavBtn.click();
27+
expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(prevMonth);
28+
page.currentLocationBtn.click();
29+
expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(currentMonth);
30+
page.dayCalendarNavHeaderBtn.click();
31+
expect(page.dayCalendarNavMonthHeaderBtn.getText()).toEqual(currentYear);
32+
page.monthCalendarLeftNavBtn.click();
33+
expect(page.dayCalendarNavMonthHeaderBtn.getText()).toEqual(prevYear);
34+
page.dayCalendarNavMonthHeaderBtn.click();
35+
36+
page.currentLocationBtn.click();
37+
expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(currentMonth);
38+
39+
page.hideGoToCurrentRadio.click();
40+
input.click();
41+
expect(page.currentLocationBtn.isPresent()).toBe(false);
42+
page.dayCalendarNavHeaderBtn.click();
43+
expect(page.currentLocationBtn.isPresent()).toBe(false);
44+
};
45+
46+
const commonMonth = (menu: ElementFinder, input?: ElementFinder) => {
47+
menu.click();
48+
input.click();
49+
page.showGoToCurrentRadio.click();
50+
expect(page.currentLocationBtn.isPresent()).toBe(true);
51+
expect(page.deyCalendarMonthNavHeader.getText()).toEqual(currentYear);
52+
page.monthCalendarLeftNavBtn.click();
53+
expect(page.deyCalendarMonthNavHeader.getText()).toEqual(prevYear);
54+
page.currentLocationBtn.click();
55+
expect(page.deyCalendarMonthNavHeader.getText()).toEqual(currentYear);
56+
57+
page.hideGoToCurrentRadio.click();
58+
input.click();
59+
expect(page.currentLocationBtn.isPresent()).toBe(false);
60+
};
61+
62+
commonDayCalendar(page.daytimePickerMenu, page.daytimePickerInput);
63+
commonDayCalendar(page.daytimeDirectiveMenu, page.daytimeDirectiveInput);
64+
65+
commonDayCalendar(page.dayPickerMenu, page.dayPickerInput);
66+
commonDayCalendar(page.dayDirectiveMenu, page.dayDirectiveInput);
67+
commonDayCalendar(page.dayDirectiveReactiveMenu, page.dayDirectiveReactiveInput);
68+
69+
commonMonth(page.monthPickerMenu, page.monthPickerInput);
70+
commonMonth(page.monthDirectiveMenu, page.monthDirectiveInput);
71+
});
72+
73+
it('should hide current date button when not between min and max', () => {
74+
page.dayPickerMenu.click();
75+
page.minSelectableInput.sendKeys(moment().add(3, 'month').format('DD-MM-YYYY'));
76+
page.dayPickerInput.click();
77+
expect(page.currentLocationBtn.isPresent()).toBe(false);
78+
});
79+
});

0 commit comments

Comments
 (0)