From cb6d5d667529798dbebd2ed2d7d4361be2439a67 Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Fri, 12 Jul 2024 10:11:44 +0300 Subject: [PATCH] fixup! feat: highlight the currently hovered file in yazi (opt-in) --- .../hover-highlights.cy.ts | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts b/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts index 6ccae388..a73c45be 100644 --- a/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts +++ b/integration-tests/cypress/e2e/using-ya-to-read-events/hover-highlights.cy.ts @@ -16,6 +16,18 @@ describe("highlighting the buffer with 'hover' events", () => { // there are multiple colors. Work around this by matching a substring of the // text instead of the whole text. + /** HACK in CI, there can be timing issues where the first hover event is + * lost. Right now we work around this by selecting another file first, then + * hovering the desired file. + */ + function hoverAnotherFileToEnsureHoverEventIsReceivedInCI(file: string) { + // select another file (hacky) + cy.typeIntoTerminal("gg") + + // select the desired file so that a new hover event is sent + cy.typeIntoTerminal(`/${file}{enter}`) + } + it("can highlight the buffer when hovered", () => { startNeovimWithYa().then((dir) => { // wait until text on the start screen is visible @@ -26,6 +38,10 @@ describe("highlighting the buffer with 'hover' events", () => { // start yazi cy.typeIntoTerminal("{upArrow}") + hoverAnotherFileToEnsureHoverEventIsReceivedInCI( + dir.contents["initial-file.txt"].name, + ) + // yazi is shown and adjacent files should be visible now // // the current file (initial-file.txt) is highlighted by default when @@ -63,6 +79,10 @@ describe("highlighting the buffer with 'hover' events", () => { // yazi is shown and adjacent files should be visible now cy.contains(dir.contents["test.lua"].name) + hoverAnotherFileToEnsureHoverEventIsReceivedInCI( + dir.contents["initial-file.txt"].name, + ) + // the current file (initial-file.txt) is highlighted by default when // opening yazi. This should have sent the 'hover' event and caused the // Neovim window to be shown with a different background color @@ -90,15 +110,17 @@ describe("highlighting the buffer with 'hover' events", () => { .children() .should("have.css", "background-color", backgroundColors.normal) + const testFile = dir.contents["test.lua"].name // open an adjacent file and wait for it to be displayed - cy.typeIntoTerminal( - `:vsplit ${dir.rootPath}/${dir.contents["test.lua"].name}{enter}`, - { delay: 1 }, - ) + cy.typeIntoTerminal(`:vsplit ${dir.rootPath}/${testFile}{enter}`, { + delay: 1, + }) cy.contains("how to initialize the test environment") // start yazi - the initial file should be highlighted cy.typeIntoTerminal("{upArrow}") + + hoverAnotherFileToEnsureHoverEventIsReceivedInCI(testFile) cy.contains("how to initialize the test environment").should( "have.css", "background-color",