Fix save session UI appears in report (#115746)

This commit is contained in:
Anton Dosov 2021-10-20 17:03:44 +02:00 committed by GitHub
parent c6fcde9a8b
commit a7a1e5436b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 1 deletions

View file

@ -8,7 +8,15 @@
"githubTeam": "kibana-app-services"
},
"configPath": ["xpack", "data_enhanced"],
"requiredPlugins": ["bfetch", "data", "features", "management", "share", "taskManager"],
"requiredPlugins": [
"bfetch",
"data",
"features",
"management",
"share",
"taskManager",
"screenshotMode"
],
"optionalPlugins": ["kibanaUtils", "usageCollection", "security"],
"server": true,
"ui": true,

View file

@ -22,6 +22,7 @@ import { toMountPoint } from '../../../../src/plugins/kibana_react/public';
import { createConnectedSearchSessionIndicator } from './search';
import { ConfigSchema } from '../config';
import { Storage } from '../../../../src/plugins/kibana_utils/public';
import { ScreenshotModePluginStart } from '../../../../src/plugins/screenshot_mode/public';
export interface DataEnhancedSetupDependencies {
bfetch: BfetchPublicSetup;
@ -31,6 +32,7 @@ export interface DataEnhancedSetupDependencies {
export interface DataEnhancedStartDependencies {
data: DataPublicPluginStart;
share: SharePluginStart;
screenshotMode: ScreenshotModePluginStart;
}
export type DataEnhancedSetup = ReturnType<DataEnhancedPlugin['setup']>;
@ -77,6 +79,7 @@ export class DataEnhancedPlugin
.duration(this.config.search.sessions.notTouchedTimeout)
.asMilliseconds(),
usageCollector: this.usageCollector,
tourDisabled: plugins.screenshotMode.isScreenshotMode(),
})
)
),

View file

@ -39,6 +39,7 @@ timeFilter.getRefreshIntervalUpdate$.mockImplementation(() => refreshInterval$);
timeFilter.getRefreshInterval.mockImplementation(() => refreshInterval$.getValue());
const disableSaveAfterSessionCompletesTimeout = 5 * 60 * 1000;
const tourDisabled = false;
function Container({ children }: { children?: ReactNode }) {
return <IntlProvider locale="en">{children}</IntlProvider>;
@ -64,6 +65,7 @@ test("shouldn't show indicator in case no active search session", async () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const { getByTestId, container } = render(
<Container>
@ -92,6 +94,7 @@ test("shouldn't show indicator in case app hasn't opt-in", async () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const { getByTestId, container } = render(
<Container>
@ -122,6 +125,7 @@ test('should show indicator in case there is an active search session', async ()
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const { getByTestId } = render(
<Container>
@ -147,6 +151,7 @@ test('should be disabled in case uiConfig says so ', async () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
render(
@ -170,6 +175,7 @@ test('should be disabled in case not enough permissions', async () => {
storage,
disableSaveAfterSessionCompletesTimeout,
basePath,
tourDisabled,
});
render(
@ -203,6 +209,7 @@ describe('Completed inactivity', () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
render(
@ -264,6 +271,7 @@ describe('tour steps', () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const rendered = render(
<Container>
@ -305,6 +313,7 @@ describe('tour steps', () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const rendered = render(
<Container>
@ -329,6 +338,51 @@ describe('tour steps', () => {
expect(usageCollector.trackSessionIndicatorTourLoading).toHaveBeenCalledTimes(0);
expect(usageCollector.trackSessionIndicatorTourRestored).toHaveBeenCalledTimes(0);
});
test("doesn't show tour step on slow loading when tour is disabled", async () => {
const state$ = new BehaviorSubject(SearchSessionState.Loading);
const SearchSessionIndicator = createConnectedSearchSessionIndicator({
sessionService: { ...sessionService, state$ },
application,
storage,
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled: true,
});
const rendered = render(
<Container>
<SearchSessionIndicator />
</Container>
);
await waitFor(() => rendered.getByTestId('searchSessionIndicator'));
expect(() => screen.getByTestId('searchSessionIndicatorPopoverContainer')).toThrow();
act(() => {
jest.advanceTimersByTime(10001);
});
expect(
screen.queryByTestId('searchSessionIndicatorPopoverContainer')
).not.toBeInTheDocument();
act(() => {
jest.advanceTimersByTime(5000);
state$.next(SearchSessionState.Completed);
});
expect(
screen.queryByTestId('searchSessionIndicatorPopoverContainer')
).not.toBeInTheDocument();
expect(storage.get(TOUR_RESTORE_STEP_KEY)).toBeFalsy();
expect(storage.get(TOUR_TAKING_TOO_LONG_STEP_KEY)).toBeFalsy();
expect(usageCollector.trackSessionIndicatorTourLoading).toHaveBeenCalledTimes(0);
expect(usageCollector.trackSessionIndicatorTourRestored).toHaveBeenCalledTimes(0);
});
});
test('shows tour step for restored', async () => {
@ -340,6 +394,7 @@ describe('tour steps', () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const rendered = render(
<Container>
@ -367,6 +422,7 @@ describe('tour steps', () => {
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
});
const rendered = render(
<Container>

View file

@ -31,6 +31,7 @@ export interface SearchSessionIndicatorDeps {
* after the last search in the session has completed
*/
disableSaveAfterSessionCompletesTimeout: number;
tourDisabled: boolean;
usageCollector?: SearchUsageCollector;
}
@ -41,6 +42,7 @@ export const createConnectedSearchSessionIndicator = ({
disableSaveAfterSessionCompletesTimeout,
usageCollector,
basePath,
tourDisabled,
}: SearchSessionIndicatorDeps): React.FC => {
const searchSessionsManagementUrl = basePath.prepend('/app/management/kibana/search_sessions');
@ -113,6 +115,7 @@ export const createConnectedSearchSessionIndicator = ({
searchSessionIndicator,
state,
saveDisabled,
tourDisabled,
usageCollector
);

View file

@ -23,6 +23,7 @@ export function useSearchSessionTour(
searchSessionIndicatorRef: SearchSessionIndicatorRef | null,
state: SearchSessionState,
searchSessionsDisabled: boolean,
disableSearchSessionsTour: boolean,
usageCollector?: SearchUsageCollector
) {
const markOpenedDone = useCallback(() => {
@ -55,6 +56,7 @@ export function useSearchSessionTour(
useEffect(() => {
if (searchSessionsDisabled) return;
if (disableSearchSessionsTour) return;
if (!searchSessionIndicatorRef) return;
let timeoutHandle: number;
@ -82,6 +84,7 @@ export function useSearchSessionTour(
searchSessionIndicatorRef,
state,
searchSessionsDisabled,
disableSearchSessionsTour,
markOpenedDone,
markRestoredDone,
usageCollector,

View file

@ -22,6 +22,7 @@
{ "path": "../../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../../../src/plugins/management/tsconfig.json" },
{ "path": "../../../src/plugins/screenshot_mode/tsconfig.json"},
{ "path": "../security/tsconfig.json" },
{ "path": "../task_manager/tsconfig.json" },