Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
0d6d0aa
[DateRangePicker] Improvements: parsing, formatting, settings panel, …
acstll Mar 27, 2026
3feeba7
[Data] Add timepicker:useDateRangePicker UI setting
acstll Mar 29, 2026
23d93cc
[Unified Search] Replace EuiSuperDatePicker with DateRangePicker in q…
acstll Mar 29, 2026
51a6396
chore(unified_search): add react-day-picker mock to jest config
weronikaolejniczak Mar 13, 2026
8d0357c
[Unified Search] Update query_bar_top_row tests for dual date picker …
acstll Mar 29, 2026
e5e5ca5
[DateRangePicker] Add data-test-subj to custom time range panel form …
acstll Mar 29, 2026
877bb6c
chore(jest): resolve react-day-picker to mock in global jest resolver
acstll Mar 29, 2026
b803318
chore(unified_search): remove redundant react-day-picker moduleNameMa…
acstll Mar 29, 2026
c478dc8
[FTR] Update time_picker page object to support both DateRangePicker …
acstll Mar 29, 2026
5c31e07
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Mar 29, 2026
62af44f
Changes from node scripts/lint_ts_projects --fix
kibanamachine Mar 29, 2026
8e86fe2
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Mar 29, 2026
0833a36
[FTR] Fix getShowDatesButtonText return type to ensure non-null string
acstll Mar 29, 2026
6be0716
[Scout] Update DatePicker page object to support both DateRangePicker…
acstll Mar 29, 2026
dd19307
fix(security-solution-cypress): update date picker tasks/screens for …
weronikaolejniczak Mar 24, 2026
7cfabf3
[Data] Temporarily default timepicker:useDateRangePicker to false for…
acstll Mar 29, 2026
083c3c3
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Mar 29, 2026
b4846d1
[Scout] Add typeAbsoluteRange alias for backwards compatibility
acstll Mar 29, 2026
d032800
[Unified Search] Disable DateRangePicker collapsed mode
acstll Mar 29, 2026
cd428b7
[DateRangePicker] Fix parser to normalize absolute dates to ISO strings
acstll Mar 29, 2026
7941d60
[Data] Restore timepicker:useDateRangePicker default to true
acstll Mar 29, 2026
2903826
[FTR] Fix time_picker page object UTC handling and update relative da…
acstll Mar 29, 2026
b202b4c
[Tests] Fix APM, Streams, and Discover tests for DateRangePicker migr…
acstll Mar 30, 2026
bab0b90
[Tests] Fix Scout DatePicker container detection, portal scoping, and…
acstll Mar 30, 2026
7b64dab
Revert APM and Streams test fixes for DateRangePicker migration
acstll Mar 30, 2026
b12c115
[Unified Search] Scope DateRangePicker to Discover and Dashboard via …
acstll Mar 30, 2026
bafae3f
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Mar 30, 2026
f6454c3
[Unified Search] Fix DateRangePicker prop passthrough in stateful sea…
acstll Mar 30, 2026
8bc5128
[Unified Search] Pass useDateRangePicker prop in dual-picker jest tests
acstll Mar 30, 2026
75ba17e
[Unified Search] Make FTR time picker page object timezone-aware
acstll Mar 30, 2026
2aba742
[Unified Search] Fix preset test-subj spacing in FTR page object and …
acstll Mar 30, 2026
ef3c1ec
[Jest] Replace react-day-picker jest mock with proper ESM transform
acstll Mar 31, 2026
d2190ff
[DateRangePicker] Limit dateFormat prop to parsing only
acstll Mar 31, 2026
6e92005
[DateRangePicker] Simplify collapsed prop to boolean and hide badge f…
acstll Mar 31, 2026
ec457f5
Address feedback
acstll Mar 31, 2026
7ed2f09
[Unified Search] Collapse DateRangePicker on mobile and query input f…
acstll Mar 31, 2026
5e335b6
[Unified Search] Wire dateFormat UI setting to DateRangePicker
acstll Mar 31, 2026
d60e9a1
Merge remote-tracking branch 'upstream/main' into unified-search/date…
acstll Mar 31, 2026
20c9167
[Security] Revert unnecessary DateRangePicker selector changes in Cyp…
acstll Mar 31, 2026
fbee0a7
[Unified Search] Wait for picker element in promotion tracking journey
acstll Mar 31, 2026
73fb2db
[Unified Search] Rename useDateRangePicker prop to enableDateRangePicker
acstll Mar 31, 2026
a96decb
[DateRangePicker] Remove typo-ish in translations file
acstll Mar 31, 2026
7138559
[Unified Search] Dismiss popover and tooltip after DateRangePicker in…
acstll Mar 31, 2026
7e0839b
[Unified Search] Support custom dateFormat in FTR setAbsoluteRange
acstll Mar 31, 2026
17277fe
[Unified Search] Remove picker detection cache in FTR page object
acstll Mar 31, 2026
fb5907a
[Unified Search] Fix pauseAutoRefresh to disable via settings panel t…
acstll Mar 31, 2026
d285291
[Unified Search] Wait for page load before detecting picker variant i…
acstll Mar 31, 2026
2721fbf
Merge remote-tracking branch 'upstream/main' into unified-search/date…
acstll Apr 1, 2026
032692d
[Unified Search] Add hidden disabled-state marker span for DateRangeP…
acstll Apr 1, 2026
9b87111
[Unified Search] Fix FTR time_picker page object for DateRangePicker
acstll Apr 1, 2026
8bf78fb
[Unified Search] Support new DateRangePicker in transform FTR date pi…
acstll Apr 1, 2026
063ea98
[Unified Search] Fix TypeScript type error in getRefreshConfigNewPicker
acstll Apr 1, 2026
4dad64c
[Unified Search] Fix invalid time range assertion in serverless Disco…
acstll Apr 1, 2026
bd6722c
[Unified Search] Support new DateRangePicker in Security Cypress date…
acstll Apr 1, 2026
3cd6c0a
[Unified Search] Remove data-test-subj in DateRangePicker
acstll Apr 1, 2026
8c83e70
[Unified Search] Fix cypress/unsafe-to-chain-command lint error in Se…
acstll Apr 1, 2026
c03602a
[Unified Search] Fix three kbn-scout DatePicker issues flagged in cod…
acstll Apr 1, 2026
d5bec92
[Unified Search] Guard setRecentlyUsedTime against malformed option s…
acstll Apr 1, 2026
8e9b844
[Unified Search] Add react-day-picker to CSP Jest transformIgnorePatt…
acstll Apr 1, 2026
49d7e15
[Unified Search] Revert validateDates to toBeVisible in typeAbsoluteR…
acstll Apr 1, 2026
c126c21
[Feedback] Comments in test files
acstll Apr 2, 2026
df6de07
[Telemetry] Improve description for timepicker:useDateRangePicker set…
acstll Apr 2, 2026
b202ac7
Changes from node scripts/telemetry_check
kibanamachine Apr 2, 2026
042b525
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 3, 2026
62c88b5
[DateRangePicker] Rename auto-refresh props for clarity
acstll Apr 3, 2026
aa43c43
[DateRangePicker] Round hours to minutes in ROUND_UNIT_MAP
acstll Apr 3, 2026
1c9261a
[DateRangePicker] Rename auto-refresh props for clarity
acstll Apr 3, 2026
199800b
[DateRangePicker] Round hours to minutes in ROUND_UNIT_MAP
acstll Apr 3, 2026
7f31e11
[Unified Search] Adapt query bar to renamed auto-refresh props
acstll Apr 3, 2026
44840f7
Merge branch 'main' into date-range-picker/improvements2
elasticmachine Apr 7, 2026
9d05100
[DateRangePicker] Hide Advanced Settings links for non-admin users
acstll Apr 8, 2026
962a2c2
Revert "[DateRangePicker] Round hours to minutes in ROUND_UNIT_MAP"
acstll Apr 8, 2026
2d95c7e
[DateRangePicker] Change docs panel heading to Shorthand syntax
acstll Apr 8, 2026
1f02ae1
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 8, 2026
a658d95
[DateRangePicker] Hide Advanced Settings links for non-admin users
acstll Apr 8, 2026
bb84d6e
[Unified Search] Pass canAccessAdvancedSettings to DateRangePicker
acstll Apr 8, 2026
cf54517
Revert "[DateRangePicker] Round hours to minutes in ROUND_UNIT_MAP"
acstll Apr 8, 2026
0d04fa5
[DateRangePicker] Change docs panel heading to Shorthand syntax
acstll Apr 8, 2026
e3f027c
[DateRangePicker] Default canAccessAdvancedSettings to false
acstll Apr 8, 2026
c377fa1
[DateRangePicker] Default canAccessAdvancedSettings to false
acstll Apr 8, 2026
cfb3bb0
[DateRangePicker] Update JSDoc for canAccessAdvancedSettings prop
acstll Apr 8, 2026
3e87774
[Unified Search] Replace timepicker:useDateRangePicker UI setting wit…
acstll Apr 8, 2026
25e01fd
[DateRangePicker] Address review comments on test helpers
acstll Apr 8, 2026
3af27cb
Merge remote-tracking branch 'origin/date-range-picker/improvements2'…
acstll Apr 8, 2026
7610b8a
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 8, 2026
fdbf42e
[DateRangePicker] Fix auto-refresh wiring in unified search
acstll Apr 8, 2026
3f2c423
[DateRangePicker] Refine auto-refresh isEnabled initialisation and en…
acstll Apr 8, 2026
3d23b3d
[DateRangePicker] Revert Discover ES|QL FTR assertions to legacy pick…
acstll Apr 8, 2026
275ed13
[DateRangePicker] Use uiSettings defaults for dateRangeValue fallback
acstll Apr 8, 2026
d826476
[DateRangePicker] Scope typeahead dismissal to containerLocator in en…
acstll Apr 9, 2026
994c817
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 9, 2026
14505a0
[DateRangePicker] Fix test mocks missing timefilter service
acstll Apr 9, 2026
3824103
Merge branch 'main' into unified-search/date-range-picker-integration
acstll Apr 9, 2026
f362b6d
[DateRangePicker] Address review feedback on Scout DatePicker helpers
acstll Apr 10, 2026
f9cabe6
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 10, 2026
fe00a02
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 11, 2026
2f9f891
Merge branch 'main' into unified-search/date-range-picker-integration
elasticmachine Apr 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
acstll marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,38 @@ export class DatePicker {
);
}

/**
* Detects whether the page is using the new DateRangePicker or the legacy
* EuiSuperDatePicker. Not cached because the lazy page object proxy lacks a
* `set` trap, so instance property writes through the proxy are lost.
*
* When a containerLocator is provided, the detection is scoped to that
* container (useful when the only DateRangePicker lives inside a panel).
*/
private async isNewDateRangePicker(containerLocator?: Locator): Promise<boolean> {
try {
await this.getTestSubjLocator('dateRangePickerControlButton', containerLocator).waitFor({
timeout: 5000,
});
return true;
} catch {
return false;
}
}

private getTestSubjLocator(selector: string, containerLocator?: Locator) {
return containerLocator
? containerLocator.getByTestId(selector)
: this.page.testSubj.locator(selector);
}

// ---------------------------------------------------------------------------
// Legacy EuiSuperDatePicker helpers
// ---------------------------------------------------------------------------

private async showStartEndTimes(containerLocator?: Locator) {
const getTestSubjLocator = (selector: string) =>
containerLocator
? containerLocator.getByTestId(selector)
: this.page.testSubj.locator(selector);
this.getTestSubjLocator(selector, containerLocator);
const getLocator = (selector: string) =>
containerLocator ? containerLocator.locator(selector) : this.page.locator(selector);

Expand All @@ -49,30 +76,9 @@ export class DatePicker {
await getLocator('div.kbnTypeahead').waitFor({ state: 'hidden' });
}

// Initial check if show/end buttons are visible
const showBtn = getTestSubjLocator('superDatePickerShowDatesButton');
const endBtn = getTestSubjLocator('superDatePickerendDatePopoverButton');

if (
!((await showBtn.isVisible({ timeout: 2000 })) || (await endBtn.isVisible({ timeout: 2000 })))
) {
// Reload loop only if initial fails
await expect
.poll(
async () => {
await this.page.reload();
await getTestSubjLocator('superDatePickerToggleQuickMenuButton').waitFor();
return (await showBtn.isVisible()) || (await endBtn.isVisible());
},
{
timeout: 20000,
intervals: [500], // Retry every 0.5s
}
)
.toBe(true);
}

if (await showBtn.isVisible()) {
if (await showBtn.isVisible({ timeout: 2000 })) {
// Click to show start/end time pickers
await showBtn.click();
await this.page.testSubj.locator('superDatePickerAbsoluteTab').waitFor();
Expand All @@ -82,7 +88,16 @@ export class DatePicker {
}
}

async typeAbsoluteRange({
private async openAbsoluteTab() {
// Usually 2 matching elements exist: one visible in the popover and one hidden in the DOM.
const absoluteTab = this.page.testSubj
.locator('superDatePickerAbsoluteTab')
.filter({ visible: true });
await expect(absoluteTab).toHaveCount(1);
await absoluteTab.click();
}

private async typeAbsoluteRangeLegacy({
from,
to,
validateDates = false,
Expand All @@ -94,9 +109,7 @@ export class DatePicker {
containerLocator?: Locator;
}) {
const getTestSubjLocator = (selector: string) =>
containerLocator
? containerLocator.getByTestId(selector)
: this.page.testSubj.locator(selector);
this.getTestSubjLocator(selector, containerLocator);

// we start with end date
await getTestSubjLocator('superDatePickerendDatePopoverButton').click();
Expand All @@ -107,7 +120,7 @@ export class DatePicker {
await this.page.testSubj.locator('parseAbsoluteDateFormat').click();
await this.page.keyboard.press('Escape');
// and later change start date
await this.page.testSubj.locator('superDatePickerstartDatePopoverButton').click();
await getTestSubjLocator('superDatePickerstartDatePopoverButton').click();
await this.openAbsoluteTab();
const inputTo = this.page.testSubj.locator('superDatePickerAbsoluteDateInput');
await inputTo.clear();
Expand All @@ -129,16 +142,104 @@ export class DatePicker {
await getTestSubjLocator('querySubmitButton').click();
}

// ---------------------------------------------------------------------------
// New DateRangePicker helpers
// ---------------------------------------------------------------------------

private async ensurePickerVisible(containerLocator?: Locator) {
const controlButton = this.getTestSubjLocator('dateRangePickerControlButton', containerLocator);
await controlButton.waitFor();

// Close any open suggestion lists that might block the date picker button
const getLocator = (selector: string) =>
containerLocator ? containerLocator.locator(selector) : this.page.locator(selector);
const isSuggestionListVisible = await getLocator('div.kbnTypeahead').isVisible();
if (isSuggestionListVisible) {
await this.getTestSubjLocator('unifiedTabs_tabsBar', containerLocator).click();
await getLocator('div.kbnTypeahead').waitFor({ state: 'hidden' });
}
}
Comment thread
macroscopeapp[bot] marked this conversation as resolved.

private async openCustomRangePanel(containerLocator?: Locator) {
await this.ensurePickerVisible(containerLocator);
// Click the control button scoped to the container
await this.getTestSubjLocator('dateRangePickerControlButton', containerLocator).click();
// The dialog/popover renders as a portal at the page root, not inside the container,
// so dialog elements must be found at the page level.
await this.page.testSubj.locator('dateRangePickerCustomRangeNavItem').click();
await this.page.testSubj.locator('dateRangePickerCustomRangePanel').waitFor();
}

private async setDatePart(side: 'Start' | 'End', value: string) {
// Dialog elements render as a portal at the page root
await this.page.testSubj.locator(`dateRangePicker${side}AbsoluteTab`).click();
const input = this.page.testSubj.locator(`dateRangePicker${side}AbsoluteInput`);
await input.clear();
await input.fill(value);
}

private async typeAbsoluteRangeNewPicker({
from,
to,
validateDates = false,
containerLocator,
}: {
from: string;
to: string;
validateDates?: boolean;
containerLocator?: Locator;
}) {
// Dialog elements render as a portal at the page root
await this.setDatePart('Start', from);
await this.setDatePart('End', to);
await this.page.testSubj.locator('dateRangePickerCustomRangeApplyButton').click();

if (validateDates) {
const controlButton = this.getTestSubjLocator(
'dateRangePickerControlButton',
containerLocator
);
// Note: data-date-range stores ISO 8601 strings (e.g. "2025-01-01T00:00:00.000Z"),
// not the human-readable format passed as `from`/`to`. We assert visibility only
// to confirm the picker updated without risking a format-mismatch failure.
await expect(
controlButton,
`Date picker should reflect the updated time range`
).toBeVisible();
}

await this.getTestSubjLocator('querySubmitButton', containerLocator).click();
}
Comment on lines +197 to +212
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium page_objects/date_picker.ts:231

When validateDates is true, typeAbsoluteRangeNewPicker only asserts that controlButton is visible — it never checks that the actual date values were applied. Callers like setAbsoluteRange expect the dates to be validated, but the test silently passes even if the dates are wrong or empty. Consider asserting the control button's data-date-range attribute contains the expected from and to values, matching the behavior of typeAbsoluteRangeLegacy.

     if (validateDates) {
       const controlButton = this.getTestSubjLocator(
         'dateRangePickerControlButton',
         containerLocator
       );
       await expect(
         controlButton,
         `Date picker should reflect the updated time range`
-      ).toBeVisible();
+      ).toHaveAttribute('data-date-range', expect.stringContaining(from));
+      await expect(controlButton).toHaveAttribute(
+        'data-date-range',
+        expect.stringContaining(to)
+      );
     }
 
     await this.getTestSubjLocator('querySubmitButton', containerLocator).click();
🤖 Copy this AI Prompt to have your agent fix this:
In file src/platform/packages/shared/kbn-scout/src/playwright/page_objects/date_picker.ts around lines 231-243:

When `validateDates` is `true`, `typeAbsoluteRangeNewPicker` only asserts that `controlButton` is visible — it never checks that the actual date values were applied. Callers like `setAbsoluteRange` expect the dates to be validated, but the test silently passes even if the dates are wrong or empty. Consider asserting the control button's `data-date-range` attribute contains the expected `from` and `to` values, matching the behavior of `typeAbsoluteRangeLegacy`.

Evidence trail:
- src/platform/packages/shared/kbn-scout/src/playwright/page_objects/date_picker.ts lines 229-241 (`typeAbsoluteRangeNewPicker` validateDates block only calls `toBeVisible()`)
- src/platform/packages/shared/kbn-scout/src/playwright/page_objects/date_picker.ts lines 149-160 (`typeAbsoluteRangeLegacy` validateDates block uses `toHaveText(from)` and `toHaveText(to)` to validate actual values)
- src/platform/packages/shared/kbn-scout/src/playwright/page_objects/date_picker.ts lines 326-331 (shows `data-date-range` attribute exists and is used in `getTimeConfig()`)
- src/platform/packages/shared/kbn-scout/src/playwright/page_objects/date_picker.ts lines 266-273 (`setAbsoluteRange` calls with `validateDates: true`)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in c126c21, we're only adding a comment and not changing the logic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation about the ISO 8601 vs. human-readable format mismatch. The comment clarifies why direct comparison won't work.

However, the concern remains that validateDates: true doesn't actually validate the dates were applied—it only confirms the control button is visible. Callers like setAbsoluteRange (line 273) pass validateDates: true expecting validation, but if the date inputs fail silently or apply wrong values, the test would still pass.

If format conversion is too complex for this helper, consider at least checking that data-date-range is non-empty or matches a date pattern, or document that validateDates only validates picker visibility, not correctness.


// ---------------------------------------------------------------------------
// Public API (dual-path)
// ---------------------------------------------------------------------------

async setCommonlyUsedTime(option: string) {
await this.quickMenuButton.click();
const commonlyUsedOption = this.page.testSubj.locator(`superDatePickerCommonlyUsed_${option}`);
await expect(commonlyUsedOption).toBeVisible();
await commonlyUsedOption.click();
if (await this.isNewDateRangePicker()) {
await this.page.testSubj.locator('dateRangePickerControlButton').click();
await this.page.testSubj.locator('dateRangePickerMainPanel').waitFor();
const presetItem = this.page.testSubj.locator(`dateRangePickerPresetItem-${option}`);
await expect(presetItem).toBeVisible();
await presetItem.click();
} else {
await this.quickMenuButton.click();
const commonlyUsedOption = this.page.testSubj.locator(
`superDatePickerCommonlyUsed_${option}`
);
await expect(commonlyUsedOption).toBeVisible();
await commonlyUsedOption.click();
}
}

async setAbsoluteRange({ from, to }: { from: string; to: string }) {
await this.showStartEndTimes();
await this.typeAbsoluteRange({ from, to, validateDates: true });
if (await this.isNewDateRangePicker()) {
await this.openCustomRangePanel();
await this.typeAbsoluteRangeNewPicker({ from, to, validateDates: true });
} else {
await this.showStartEndTimes();
await this.typeAbsoluteRangeLegacy({ from, to, validateDates: true });
}
}

async setAbsoluteRangeInRootContainer({
Expand All @@ -150,43 +251,102 @@ export class DatePicker {
to: string;
containerLocator: Locator;
}) {
await this.showStartEndTimes(containerLocator);
await this.typeAbsoluteRange({ from, to, validateDates: true, containerLocator });
if (await this.isNewDateRangePicker(containerLocator)) {
await this.openCustomRangePanel(containerLocator);
await this.typeAbsoluteRangeNewPicker({
from,
to,
validateDates: true,
containerLocator,
});
} else {
await this.showStartEndTimes(containerLocator);
await this.typeAbsoluteRangeLegacy({
from,
to,
validateDates: true,
containerLocator,
});
}
}

async openAbsoluteTab() {
// usually 2 matching elements exist, one in the popover and one hidden in the DOM
const absoluteTab = this.page.testSubj
.locator('superDatePickerAbsoluteTab')
.filter({ visible: true });
await expect(absoluteTab).toHaveCount(1);
await absoluteTab.click();
/** @deprecated Use {@link setAbsoluteRangeInRootContainer} instead. */
async typeAbsoluteRange({
from,
to,
validateDates = false,
containerLocator,
}: {
from: string;
to: string;
validateDates?: boolean;
containerLocator?: Locator;
}) {
if (await this.isNewDateRangePicker(containerLocator)) {
await this.openCustomRangePanel(containerLocator);
await this.typeAbsoluteRangeNewPicker({ from, to, validateDates, containerLocator });
} else {
await this.showStartEndTimes(containerLocator);
await this.typeAbsoluteRangeLegacy({ from, to, validateDates, containerLocator });
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
}
}

async getTimeConfig(): Promise<{ start: string; end: string }> {
if (await this.isNewDateRangePicker()) {
const dateRange =
(await this.page.testSubj
.locator('dateRangePickerControlButton')
.getAttribute('data-date-range')) ?? '';
const [start, end] = dateRange.split(' to ');
return { start: start?.trim() ?? '', end: end?.trim() ?? '' };
}
await this.showStartEndTimes();
const start = await this.page.testSubj.innerText('superDatePickerstartDatePopoverButton');
const end = await this.page.testSubj.innerText('superDatePickerendDatePopoverButton');
return { start, end };
}

async startAutoRefresh(interval: number, dateUnit: DateUnitSelector = DateUnitSelector.Seconds) {
await this.quickMenuButton.click();
// Check if refresh is already running
const isPaused = (await this.toggleRefreshButton.getAttribute('aria-checked')) === 'false';
if (isPaused) {
await this.toggleRefreshButton.click();
}
// Set interval
await this.refreshIntervalInput.clear();
await this.refreshIntervalInput.fill(interval.toString());
await this.refreshIntervalUnitSelect.selectOption({ value: dateUnit });
await this.refreshIntervalInput.press('Enter');
if (await this.isNewDateRangePicker()) {
await this.page.testSubj.locator('dateRangePickerControlButton').click();
await this.page.testSubj.locator('dateRangePickerSettingsButton').click();
await this.page.testSubj.locator('dateRangePickerSettingsPanel').waitFor();

const toggle = this.page.testSubj.locator('dateRangePickerAutoRefreshToggle');
const isPaused = (await toggle.getAttribute('aria-checked')) !== 'true';
if (isPaused) {
await toggle.click();
}

await this.quickMenuButton.click();
const countInput = this.page.testSubj.locator('dateRangePickerAutoRefreshIntervalCount');
await countInput.clear();
await countInput.fill(interval.toString());
await this.page.testSubj
.locator('dateRangePickerAutoRefreshIntervalUnit')
.selectOption({ value: dateUnit });

await this.page.keyboard.press('Escape');
} else {
await this.quickMenuButton.click();
const isPaused = (await this.toggleRefreshButton.getAttribute('aria-checked')) === 'false';
if (isPaused) {
await this.toggleRefreshButton.click();
}
await this.refreshIntervalInput.clear();
await this.refreshIntervalInput.fill(interval.toString());
await this.refreshIntervalUnitSelect.selectOption({ value: dateUnit });
await this.refreshIntervalInput.press('Enter');
await this.quickMenuButton.click();
}
}

async waitToBeHidden() {
await this.page.testSubj.locator('superDatePickerAbsoluteTab').waitFor({ state: 'hidden' });
if (await this.isNewDateRangePicker()) {
await this.page.testSubj
.locator('dateRangePickerCustomRangePanel')
.waitFor({ state: 'hidden' });
} else {
await this.page.testSubj.locator('superDatePickerAbsoluteTab').waitFor({ state: 'hidden' });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ export interface DateRangePickerProps {
timeZone?: string;
/** Fires at the end of each auto-refresh interval while `settings.autoRefresh` exists, is enabled and timer is unpaused. */
onRefresh?: () => void;
/**
* Increment this value whenever an external timer (e.g. the Kibana timefilter) triggers a
* refresh, so the visual countdown resets to stay in sync with actual query cadence.
* `undefined` on first render is ignored.
*/
refreshEpoch?: number;
/**
* Prepends the Kibana server `basePath` to an internal URL path.
* Typically provided as `core.http.basePath.prepend`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export function DateRangePickerProvider({
onSettingsChange,
timeZone,
onRefresh,
refreshEpoch,
prependBasePath: prependBasePathProp,
canAccessAdvancedSettings = false,
}: PropsWithChildren<DateRangePickerProps>) {
Expand Down Expand Up @@ -260,6 +261,7 @@ export function DateRangePickerProvider({
isPaused: refreshTimerPaused,
intervalMs: settings.autoRefresh?.isEnabled ? settings.autoRefresh.intervalMs : 0,
onRefresh,
refreshEpoch,
});

const toggleAutoRefresh = useCallback(() => {
Expand Down
Loading
Loading