Skip to content
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
38 changes: 16 additions & 22 deletions src/features/QuickViewManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ define(function (require, exports, module) {
const CMD_ENABLE_QUICK_VIEW = "view.enableQuickView",
QUICK_VIEW_EDITOR_MARKER = 'quickViewMark',
// Time (ms) mouse must remain over a provider's matched text before popover appears
HOVER_DELAY = 500,
HOVER_DELAY = 350,
// Pointer height, used to shift popover above pointer (plus a little bit of space)
POINTER_HEIGHT = 10,
POPOVER_HORZ_MARGIN = 5; // Horizontal margin
Expand Down Expand Up @@ -300,7 +300,6 @@ define(function (require, exports, module) {
EditorManager.getActiveEditor().focus();
}
}
showPreviewQueued = false;
mouseInPreviewContainer = false;
unlockQuickView();
window.clearTimeout(popoverState.hoverTimer);
Expand Down Expand Up @@ -546,8 +545,6 @@ define(function (require, exports, module) {
return false;
}

let showPreviewQueued = false;

function processMouseMove() {
animationRequest = null;

Expand Down Expand Up @@ -579,24 +576,21 @@ define(function (require, exports, module) {
}
}

if(!showPreviewQueued){
// Initialize popoverState
showPreviewQueued = true;
popoverState = popoverState || {};

// Set timer to scan and show. This will get cancelled (in hidePreview())
// if mouse movement rendered this popover inapplicable before timer fires.
// When showing "immediately", still use setTimeout() to make this async
// so we return from this mousemove event handler ASAP.
popoverState.hoverTimer = window.setTimeout(function () {
showPreviewQueued = false;
if(!mouseInPreviewContainer && !quickViewLocked){
hidePreview();
popoverState = {};
showPreview(editor);
}
}, HOVER_DELAY);
}
popoverState = popoverState || {};

// Set timer to scan and show. This will get cancelled (in hidePreview())
// if mouse movement rendered this popover inapplicable before timer fires.
// When showing "immediately", still use setTimeout() to make this async
// so we return from this mousemove event handler ASAP.
clearTimeout(popoverState.hoverTimer);
popoverState.hoverTimer = window.setTimeout(function () {
if(!mouseInPreviewContainer && !quickViewLocked){
console.error("showing");
hidePreview();
popoverState = {};
showPreview(editor);
}
}, HOVER_DELAY);
}

function handleMouseMove(event) {
Expand Down
4 changes: 3 additions & 1 deletion test/spec/QuickViewManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ define(function (require, exports, module) {
}
expect(rangeMarker).toBeDefined();
let range = rangeMarker.find();
expect(range.from.ch).toBe(4);
// there are two quick views, if the test started before css lint, then we will only have color preview
// at ch:11, else the css lint error preview starts at 4
expect([4, 11].includes(range.from.ch)).toBeTrue();
expect(range.to.ch).toBe(18);
});

Expand Down
60 changes: 15 additions & 45 deletions test/spec/login-desktop-integ-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ define(function (require, exports, module) {
await awaitsFor(
function () {
return testWindow._test_login_service_exports &&
testWindow._test_login_desktop_exports;
testWindow._test_login_desktop_exports;
},
"Test exports to be available",
5000
Expand Down Expand Up @@ -244,10 +244,14 @@ define(function (require, exports, module) {

async function performFullLoginFlow() {
// Mock desktop app functions for login flow
let capturedBrowserURL = null;
testWindow.Phoenix.app.openURLInDefaultBrowser = function(url) {
capturedBrowserURL = url;
return true;
};
let capturedClipboardText = null;
testWindow.Phoenix.app.copyToClipboard = function(text) {
capturedClipboardText = text;
return true;
};

Expand All @@ -263,6 +267,16 @@ define(function (require, exports, module) {

// Wait for desktop login dialog
await testWindow.__PR.waitForModalDialog(".modal");
const copyButton = testWindow.$('.modal').find('[data-button-id="copy"]');
copyButton.trigger('click');
expect(capturedClipboardText).toBe("123456");

// Test open browser functionality
const openBrowserButton = testWindow.$('.modal').find('[data-button-id="open"]');
openBrowserButton.trigger('click');
expect(capturedBrowserURL).toBeDefined();
expect(capturedBrowserURL).toContain('authorizeApp');
expect(capturedBrowserURL).toContain('test-session-123');

// Click refresh button to verify login
const refreshButton = testWindow.$('.modal').find('[data-button-id="refresh"]');
Expand Down Expand Up @@ -306,50 +320,6 @@ define(function (require, exports, module) {
await cleanupTrialState();
});

it("should open browser and copy validation code", async function () {
// Setup basic user mock
setupProUserMock(false);

// Mock desktop app functions
let capturedBrowserURL = null;
let capturedClipboardText = null;

if (testWindow.Phoenix && testWindow.Phoenix.app) {
testWindow.Phoenix.app.openURLInDefaultBrowser = function(url) {
capturedBrowserURL = url;
return true;
};
testWindow.Phoenix.app.copyToClipboard = function(text) {
capturedClipboardText = text;
return true;
};
}

// Click profile button and sign in
const $profileButton = testWindow.$("#user-profile-button");
$profileButton.trigger('click');
await popupToAppear(SIGNIN_POPUP);

const popupContent = testWindow.$('.profile-popup');
const signInButton = popupContent.find('#phoenix-signin-btn');
signInButton.trigger('click');

// Wait for desktop login dialog
await testWindow.__PR.waitForModalDialog(".modal");

// Test copy functionality
const copyButton = testWindow.$('.modal').find('[data-button-id="copy"]');
copyButton.trigger('click');
expect(capturedClipboardText).toBe("123456");

// Test open browser functionality
const openBrowserButton = testWindow.$('.modal').find('[data-button-id="open"]');
openBrowserButton.trigger('click');
expect(capturedBrowserURL).toBeDefined();
expect(capturedBrowserURL).toContain('authorizeApp');
expect(capturedBrowserURL).toContain('test-session-123');
});

LoginShared.setupSharedTests();
});
});
Expand Down
Loading