Skip to content

Commit

Permalink
Merge branch 'master' into uptime_ui-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine committed Oct 9, 2019
2 parents 093d68d + 08de89b commit 4dbdc52
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/

export function SharePageProvider({ getService, getPageObjects }) {
import { FtrProviderContext } from '../ftr_provider_context';

export function SharePageProvider({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const find = getService('find');
const PageObjects = getPageObjects(['visualize', 'common']);
Expand All @@ -32,7 +34,7 @@ export function SharePageProvider({ getService, getPageObjects }) {
return testSubjects.click('shareTopNavButton');
}

async openShareMenuItem(itemTitle) {
async openShareMenuItem(itemTitle: string) {
log.debug(`openShareMenuItem title:${itemTitle}`);
const isShareMenuOpen = await this.isShareMenuOpen();
if (!isShareMenuOpen) {
Expand All @@ -45,11 +47,24 @@ export function SharePageProvider({ getService, getPageObjects }) {
await this.clickShareTopNavButton();
}
const menuPanel = await find.byCssSelector('div.euiContextMenuPanel');
testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
await testSubjects.click(`sharePanel-${itemTitle.replace(' ', '')}`);
await testSubjects.waitForDeleted(menuPanel);
}

/**
* if there are more entries in the share menu, the permalinks entry has to be clicked first
* else the selection isn't displayed. this happens if you're testing against an instance
* with xpack features enabled, where there's also a csv sharing option
* in a pure OSS environment, the permalinks sharing panel is displayed initially
*/
async openPermaLinks() {
if (await testSubjects.exists('sharePanel-Permalinks')) {
await testSubjects.click(`sharePanel-Permalinks`);
}
}

async getSharedUrl() {
await this.openPermaLinks();
return await testSubjects.getAttribute('copyShareUrlButton', 'data-share-url');
}

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

async exportAsSavedObject() {
await this.openPermaLinks();
return await testSubjects.click('exportAsSavedObject');
}

}

return new SharePage();
Expand Down
4 changes: 4 additions & 0 deletions x-pack/legacy/plugins/code/server/lsp/abstract_launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export abstract class AbstractLauncher implements ILanguageServerLauncher {
log.debug('Detach mode, expected language server launch externally');
proxy.onConnected(() => {
this.running = true;
// reset spawn times
this.spawnTimes = 0;
});
proxy.onDisconnected(() => {
this.running = false;
Expand Down Expand Up @@ -81,6 +83,8 @@ export abstract class AbstractLauncher implements ILanguageServerLauncher {
await new Promise((resolve, reject) => {
proxy.onConnected(() => {
this.proxyConnected = true;
// reset spawn times
this.spawnTimes = 0;
resolve();
});
this.launchReject = err => {
Expand Down
9 changes: 6 additions & 3 deletions x-pack/legacy/plugins/code/server/lsp/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ export class LanguageServerProxy implements ILanguageServerHandler {
this.eventEmitter.on('err', error =>
reject(new ResponseError(InternalError, 'Server error', error))
);
this.eventEmitter.on('exit', () =>
reject(new ResponseError(RequestCancelled, 'Server closed'))
);
this.eventEmitter.on('exit', () => {
reject(new ResponseError(RequestCancelled, 'Server closed'));
this.initialized = false;
});
this.eventEmitter.on('connect', () => resolve(this.clientConnection!));
});
}
Expand Down Expand Up @@ -164,6 +165,7 @@ export class LanguageServerProxy implements ILanguageServerHandler {
clientConn.sendNotification(ExitNotification.type);
}
this.eventEmitter.emit('exit');
this.initialized = false;
}

public startServerConnection() {
Expand Down Expand Up @@ -246,6 +248,7 @@ export class LanguageServerProxy implements ILanguageServerHandler {

private onSocketClosed() {
this.clientConnection = null;
this.initialized = false;
this.eventEmitter.emit('close');
}

Expand Down
14 changes: 9 additions & 5 deletions x-pack/legacy/plugins/code/server/lsp/request_expander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ export class RequestExpander implements ILanguageServerHandler {
readonly log: Logger
) {
this.proxy = proxy;
proxy.onDisconnected(() => {
const clearListener = () => {
this.log.debug('proxy disconnected, clearing workspace status');
this.workspaces.clear();
});
};
proxy.onDisconnected(clearListener);
proxy.onExit(clearListener);
this.workspaceRoot = fs.realpathSync(this.serverOptions.workspacePath);
}

Expand Down Expand Up @@ -260,9 +263,10 @@ export class RequestExpander implements ILanguageServerHandler {
}

initializeState(workspaceDir: string): WorkspaceStatus {
if (this.hasWorkspacePath(workspaceDir)) {
return this.getWorkspace(workspaceDir).status;
const ws = this.getWorkspace(workspaceDir);
if (ws.status === WorkspaceStatus.Uninitialized) {
ws.initPromise = Cancelable.fromPromise(this.initialize(workspaceDir));
}
return WorkspaceStatus.Uninitialized;
return ws.status;
}
}
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/code/server/lsp/workspace_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ export class WorkspaceHandler {
}

public handleResponse(request: LspRequest, response: ResponseMessage): ResponseMessage {
if (!response.result) {
return response;
}
const { method } = request;
switch (method) {
case 'textDocument/hover': {
Expand Down

0 comments on commit 4dbdc52

Please sign in to comment.