From b8ceaafe7197351915bdc3975c4093a8100e5336 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 14 Sep 2023 12:40:37 +0200 Subject: [PATCH 1/6] chore: print page content on failed promise --- site/e2e/tests/webTerminal.spec.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/site/e2e/tests/webTerminal.spec.ts b/site/e2e/tests/webTerminal.spec.ts index 01d40c03d8a96..412e2be4ecdfc 100644 --- a/site/e2e/tests/webTerminal.spec.ts +++ b/site/e2e/tests/webTerminal.spec.ts @@ -50,9 +50,17 @@ test("web terminal", async ({ context, page }) => { await terminal.keyboard.press("Enter"); // Check if "echo" command was executed - await xtermRows.waitForSelector('div:text-matches("hello")', { - state: "visible", - }); + // try-catch is used temporarily to find the root cause: https://github.com/coder/coder/actions/runs/6176958762/job/16767089943 + try { + await xtermRows.waitForSelector('div:text-matches("hello")', { + state: "visible", + }); + } catch (error) { + const pageContent = await terminal.content(); + // eslint-disable-next-line no-console -- Let's see what is inside of xterm-rows + console.log("Unable to find echoed text:", pageContent); + throw error; + } await stopAgent(agent); }); From 8d4e64c35a84d9e0ba2358bc462fbb2bf3c245a1 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 14 Sep 2023 12:50:04 +0200 Subject: [PATCH 2/6] WIP --- site/e2e/tests/webTerminal.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/site/e2e/tests/webTerminal.spec.ts b/site/e2e/tests/webTerminal.spec.ts index 412e2be4ecdfc..c1587d2331005 100644 --- a/site/e2e/tests/webTerminal.spec.ts +++ b/site/e2e/tests/webTerminal.spec.ts @@ -54,6 +54,7 @@ test("web terminal", async ({ context, page }) => { try { await xtermRows.waitForSelector('div:text-matches("hello")', { state: "visible", + timeout: 30 * 1000, }); } catch (error) { const pageContent = await terminal.content(); From 3ce891d9fbd1797234a135e211dc91d9757156d2 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 14 Sep 2023 12:52:00 +0200 Subject: [PATCH 3/6] Short timeout --- site/e2e/tests/webTerminal.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/e2e/tests/webTerminal.spec.ts b/site/e2e/tests/webTerminal.spec.ts index c1587d2331005..ed0a27032f7be 100644 --- a/site/e2e/tests/webTerminal.spec.ts +++ b/site/e2e/tests/webTerminal.spec.ts @@ -54,7 +54,7 @@ test("web terminal", async ({ context, page }) => { try { await xtermRows.waitForSelector('div:text-matches("hello")', { state: "visible", - timeout: 30 * 1000, + timeout: 5 * 1000, }); } catch (error) { const pageContent = await terminal.content(); From 0de62491d297ed6aba6e013d0a4fdefa96ad83c9 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 14 Sep 2023 13:05:40 +0200 Subject: [PATCH 4/6] use terminal --- site/e2e/tests/webTerminal.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/e2e/tests/webTerminal.spec.ts b/site/e2e/tests/webTerminal.spec.ts index ed0a27032f7be..48e446f7a79b7 100644 --- a/site/e2e/tests/webTerminal.spec.ts +++ b/site/e2e/tests/webTerminal.spec.ts @@ -41,7 +41,7 @@ test("web terminal", async ({ context, page }) => { const terminal = await pagePromise; await terminal.waitForLoadState("domcontentloaded"); - const xtermRows = await terminal.waitForSelector("div.xterm-rows", { + await terminal.waitForSelector("div.xterm-rows", { state: "visible", }); @@ -52,9 +52,9 @@ test("web terminal", async ({ context, page }) => { // Check if "echo" command was executed // try-catch is used temporarily to find the root cause: https://github.com/coder/coder/actions/runs/6176958762/job/16767089943 try { - await xtermRows.waitForSelector('div:text-matches("hello")', { + await terminal.waitForSelector('div.xterm-rows div:text-matches("hello")', { state: "visible", - timeout: 5 * 1000, + timeout: 10 * 1000, }); } catch (error) { const pageContent = await terminal.content(); From 7ff41d41b11364a2bc7aa9157d052a1080df5cd2 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 14 Sep 2023 13:18:52 +0200 Subject: [PATCH 5/6] use less generic phrase --- site/e2e/tests/webTerminal.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/e2e/tests/webTerminal.spec.ts b/site/e2e/tests/webTerminal.spec.ts index 48e446f7a79b7..78bddd4cd0d98 100644 --- a/site/e2e/tests/webTerminal.spec.ts +++ b/site/e2e/tests/webTerminal.spec.ts @@ -46,13 +46,13 @@ test("web terminal", async ({ context, page }) => { }); // Ensure that we can type in it - await terminal.keyboard.type("echo he${justabreak}llo"); + await terminal.keyboard.type("echo he${justabreak}llo123456"); await terminal.keyboard.press("Enter"); // Check if "echo" command was executed // try-catch is used temporarily to find the root cause: https://github.com/coder/coder/actions/runs/6176958762/job/16767089943 try { - await terminal.waitForSelector('div.xterm-rows div:text-matches("hello")', { + await terminal.waitForSelector('div.xterm-rows div:text-matches("hello123456")', { state: "visible", timeout: 10 * 1000, }); From 413de1e878d3b1815c7d938d311f34968d4d0658 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 14 Sep 2023 13:22:36 +0200 Subject: [PATCH 6/6] fmt --- site/e2e/tests/webTerminal.spec.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/site/e2e/tests/webTerminal.spec.ts b/site/e2e/tests/webTerminal.spec.ts index 78bddd4cd0d98..3ce23700f5d0c 100644 --- a/site/e2e/tests/webTerminal.spec.ts +++ b/site/e2e/tests/webTerminal.spec.ts @@ -52,10 +52,13 @@ test("web terminal", async ({ context, page }) => { // Check if "echo" command was executed // try-catch is used temporarily to find the root cause: https://github.com/coder/coder/actions/runs/6176958762/job/16767089943 try { - await terminal.waitForSelector('div.xterm-rows div:text-matches("hello123456")', { - state: "visible", - timeout: 10 * 1000, - }); + await terminal.waitForSelector( + 'div.xterm-rows div:text-matches("hello123456")', + { + state: "visible", + timeout: 10 * 1000, + }, + ); } catch (error) { const pageContent = await terminal.content(); // eslint-disable-next-line no-console -- Let's see what is inside of xterm-rows