Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Search sessions] Don't show incomplete warning if search requests aren't in session #112364

Merged
merged 6 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,12 @@ describe('SearchInterceptor', () => {
opts: {
isRestore?: boolean;
isStored?: boolean;
sessionId: string;
sessionId?: string;
} | null
) => {
const sessionServiceMock = sessionService as jest.Mocked<ISessionService>;
sessionServiceMock.getSearchOptions.mockImplementation(() =>
opts
opts && opts.sessionId
? {
sessionId: opts.sessionId,
isRestore: opts.isRestore ?? false,
Expand All @@ -515,6 +515,7 @@ describe('SearchInterceptor', () => {
: null
);
sessionServiceMock.isRestore.mockReturnValue(!!opts?.isRestore);
sessionServiceMock.getSessionId.mockImplementation(() => opts?.sessionId);
fetchMock.mockResolvedValue({ result: 200 });
};

Expand Down Expand Up @@ -606,6 +607,41 @@ describe('SearchInterceptor', () => {
expect(SearchSessionIncompleteWarning).toBeCalledTimes(0);
});

test('should not show warning if a search outside of session is running', async () => {
setup({
isRestore: false,
isStored: false,
});

const responses = [
{
time: 10,
value: {
isPartial: false,
isRunning: false,
isRestored: false,
id: 1,
rawResponse: {
took: 1,
},
},
},
];
mockFetchImplementation(responses);

const response = searchInterceptor.search(
{},
{
sessionId: undefined,
}
);
response.subscribe({ next, error, complete });

await timeTravel(10);

expect(SearchSessionIncompleteWarning).toBeCalledTimes(0);
});

test('should show warning once if a search is not available during restore', async () => {
setup({
isRestore: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,14 @@ export class SearchInterceptor {
);
}),
tap((response) => {
if (this.deps.session.isRestore() && response.isRestored === false) {
this.showRestoreWarning(this.deps.session.getSessionId());
const isSearchInScopeOfSession =
sessionId && sessionId === this.deps.session.getSessionId();
if (
isSearchInScopeOfSession &&
this.deps.session.isRestore() &&
response.isRestored === false
) {
this.showRestoreWarning(sessionId);
}
}),
finalize(() => {
Expand Down