Skip to content

Commit 4dbdc52

Browse files
Merge branch 'master' into uptime_ui-tests
2 parents 093d68d + 08de89b commit 4dbdc52

5 files changed

Lines changed: 41 additions & 12 deletions

File tree

test/functional/page_objects/share_page.js renamed to test/functional/page_objects/share_page.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
* under the License.
1818
*/
1919

20-
export function SharePageProvider({ getService, getPageObjects }) {
20+
import { FtrProviderContext } from '../ftr_provider_context';
21+
22+
export function SharePageProvider({ getService, getPageObjects }: FtrProviderContext) {
2123
const testSubjects = getService('testSubjects');
2224
const find = getService('find');
2325
const PageObjects = getPageObjects(['visualize', 'common']);
@@ -32,7 +34,7 @@ export function SharePageProvider({ getService, getPageObjects }) {
3234
return testSubjects.click('shareTopNavButton');
3335
}
3436

35-
async openShareMenuItem(itemTitle) {
37+
async openShareMenuItem(itemTitle: string) {
3638
log.debug(`openShareMenuItem title:${itemTitle}`);
3739
const isShareMenuOpen = await this.isShareMenuOpen();
3840
if (!isShareMenuOpen) {
@@ -45,11 +47,24 @@ export function SharePageProvider({ getService, getPageObjects }) {
4547
await this.clickShareTopNavButton();
4648
}
4749
const menuPanel = await find.byCssSelector('div.euiContextMenuPanel');
48-
testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
50+
await testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
4951
await testSubjects.waitForDeleted(menuPanel);
5052
}
5153

54+
/**
55+
* if there are more entries in the share menu, the permalinks entry has to be clicked first
56+
* else the selection isn't displayed. this happens if you're testing against an instance
57+
* with xpack features enabled, where there's also a csv sharing option
58+
* in a pure OSS environment, the permalinks sharing panel is displayed initially
59+
*/
60+
async openPermaLinks() {
61+
if (await testSubjects.exists('sharePanel-Permalinks')) {
62+
await testSubjects.click(`sharePanel-Permalinks`);
63+
}
64+
}
65+
5266
async getSharedUrl() {
67+
await this.openPermaLinks();
5368
return await testSubjects.getAttribute('copyShareUrlButton', 'data-share-url');
5469
}
5570

@@ -68,9 +83,9 @@ export function SharePageProvider({ getService, getPageObjects }) {
6883
}
6984

7085
async exportAsSavedObject() {
86+
await this.openPermaLinks();
7187
return await testSubjects.click('exportAsSavedObject');
7288
}
73-
7489
}
7590

7691
return new SharePage();

x-pack/legacy/plugins/code/server/lsp/abstract_launcher.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export abstract class AbstractLauncher implements ILanguageServerLauncher {
4343
log.debug('Detach mode, expected language server launch externally');
4444
proxy.onConnected(() => {
4545
this.running = true;
46+
// reset spawn times
47+
this.spawnTimes = 0;
4648
});
4749
proxy.onDisconnected(() => {
4850
this.running = false;
@@ -81,6 +83,8 @@ export abstract class AbstractLauncher implements ILanguageServerLauncher {
8183
await new Promise((resolve, reject) => {
8284
proxy.onConnected(() => {
8385
this.proxyConnected = true;
86+
// reset spawn times
87+
this.spawnTimes = 0;
8488
resolve();
8589
});
8690
this.launchReject = err => {

x-pack/legacy/plugins/code/server/lsp/proxy.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@ export class LanguageServerProxy implements ILanguageServerHandler {
9393
this.eventEmitter.on('err', error =>
9494
reject(new ResponseError(InternalError, 'Server error', error))
9595
);
96-
this.eventEmitter.on('exit', () =>
97-
reject(new ResponseError(RequestCancelled, 'Server closed'))
98-
);
96+
this.eventEmitter.on('exit', () => {
97+
reject(new ResponseError(RequestCancelled, 'Server closed'));
98+
this.initialized = false;
99+
});
99100
this.eventEmitter.on('connect', () => resolve(this.clientConnection!));
100101
});
101102
}
@@ -164,6 +165,7 @@ export class LanguageServerProxy implements ILanguageServerHandler {
164165
clientConn.sendNotification(ExitNotification.type);
165166
}
166167
this.eventEmitter.emit('exit');
168+
this.initialized = false;
167169
}
168170

169171
public startServerConnection() {
@@ -246,6 +248,7 @@ export class LanguageServerProxy implements ILanguageServerHandler {
246248

247249
private onSocketClosed() {
248250
this.clientConnection = null;
251+
this.initialized = false;
249252
this.eventEmitter.emit('close');
250253
}
251254

x-pack/legacy/plugins/code/server/lsp/request_expander.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ export class RequestExpander implements ILanguageServerHandler {
5656
readonly log: Logger
5757
) {
5858
this.proxy = proxy;
59-
proxy.onDisconnected(() => {
59+
const clearListener = () => {
60+
this.log.debug('proxy disconnected, clearing workspace status');
6061
this.workspaces.clear();
61-
});
62+
};
63+
proxy.onDisconnected(clearListener);
64+
proxy.onExit(clearListener);
6265
this.workspaceRoot = fs.realpathSync(this.serverOptions.workspacePath);
6366
}
6467

@@ -260,9 +263,10 @@ export class RequestExpander implements ILanguageServerHandler {
260263
}
261264

262265
initializeState(workspaceDir: string): WorkspaceStatus {
263-
if (this.hasWorkspacePath(workspaceDir)) {
264-
return this.getWorkspace(workspaceDir).status;
266+
const ws = this.getWorkspace(workspaceDir);
267+
if (ws.status === WorkspaceStatus.Uninitialized) {
268+
ws.initPromise = Cancelable.fromPromise(this.initialize(workspaceDir));
265269
}
266-
return WorkspaceStatus.Uninitialized;
270+
return ws.status;
267271
}
268272
}

x-pack/legacy/plugins/code/server/lsp/workspace_handler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ export class WorkspaceHandler {
158158
}
159159

160160
public handleResponse(request: LspRequest, response: ResponseMessage): ResponseMessage {
161+
if (!response.result) {
162+
return response;
163+
}
161164
const { method } = request;
162165
switch (method) {
163166
case 'textDocument/hover': {

0 commit comments

Comments
 (0)