From ceb5cb8f1d110761d58d56c29673b6d1e9bd8006 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Fri, 24 Jan 2025 05:59:56 -0600 Subject: [PATCH 1/5] log after each test --- test/e2e/pages/console.ts | 5 ++--- test/e2e/pages/terminal.ts | 19 +++++++++++++++++++ test/e2e/tests/_test.setup.ts | 5 ++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/test/e2e/pages/console.ts b/test/e2e/pages/console.ts index c8f71bb125b..2ae1234f9c6 100644 --- a/test/e2e/pages/console.ts +++ b/test/e2e/pages/console.ts @@ -107,11 +107,10 @@ export class Console { } async logConsoleContents() { - this.code.logger.log('------------------'); - this.code.logger.log('Console contents:'); - this.code.logger.log('------------------'); + this.code.logger.log('---- START: Console Contents ----'); const contents = await this.code.driver.page.locator(CONSOLE_LINES).allTextContents(); contents.forEach(line => this.code.logger.log(line)); + this.code.logger.log('---- END: Console Contents ----'); } async typeToConsole(text: string, delay = 30, pressEnter = false) { diff --git a/test/e2e/pages/terminal.ts b/test/e2e/pages/terminal.ts index 586c3517520..5a1327eb082 100644 --- a/test/e2e/pages/terminal.ts +++ b/test/e2e/pages/terminal.ts @@ -70,4 +70,23 @@ export class Terminal { } }, text); } + + async logTerminalContents() { + const plainText = await this.code.driver.page.evaluate(() => { + const rows = document.querySelectorAll('.xterm-rows > div'); + return Array.from(rows) + .map((row) => { + const spans = row.querySelectorAll('span'); + return Array.from(spans) + .map((span) => span.textContent?.trim() || '') + .join(' '); // Join spans within a row with a space + }) + .filter((line) => line && line.length > 0) // Remove empty lines + .join('\n'); // Join rows with newlines + }); + + this.code.logger.log('---- START: Terminal Contents ----'); + this.code.logger.log(plainText); + this.code.logger.log('---- END: Terminal Contents ----'); + } } diff --git a/test/e2e/tests/_test.setup.ts b/test/e2e/tests/_test.setup.ts index 5c6580ebffe..8082fc18b42 100644 --- a/test/e2e/tests/_test.setup.ts +++ b/test/e2e/tests/_test.setup.ts @@ -293,7 +293,7 @@ export const test = base.extend({ await use(app.code.driver.page); }, - autoTestFixture: [async ({ logger, suiteId }, use, testInfo) => { + autoTestFixture: [async ({ logger, suiteId, app }, use, testInfo) => { if (!suiteId) { throw new Error('suiteId is required'); } logger.log(''); @@ -306,6 +306,9 @@ export const test = base.extend({ const testTitle = testInfo.title; const endLog = failed ? `>>> !!! FAILURE !!! Test end: '${testTitle}' !!! FAILURE !!! <<<` : `>>> Test end: '${testTitle}' <<<`; + await app.workbench.console.logConsoleContents(); + await app.workbench.terminal.logTerminalContents(); + logger.log(''); logger.log(endLog); logger.log(''); From 59634536317b949518339c9712c68ecb7bfca5cb Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Fri, 24 Jan 2025 06:27:33 -0600 Subject: [PATCH 2/5] use locator --- test/e2e/pages/terminal.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/e2e/pages/terminal.ts b/test/e2e/pages/terminal.ts index 5a1327eb082..1b1aae5fb72 100644 --- a/test/e2e/pages/terminal.ts +++ b/test/e2e/pages/terminal.ts @@ -72,18 +72,16 @@ export class Terminal { } async logTerminalContents() { - const plainText = await this.code.driver.page.evaluate(() => { - const rows = document.querySelectorAll('.xterm-rows > div'); - return Array.from(rows) - .map((row) => { - const spans = row.querySelectorAll('span'); - return Array.from(spans) - .map((span) => span.textContent?.trim() || '') - .join(' '); // Join spans within a row with a space - }) - .filter((line) => line && line.length > 0) // Remove empty lines - .join('\n'); // Join rows with newlines - }); + const locator = this.code.driver.page.locator('.xterm-rows > div'); + const plainText = (await locator.evaluateAll((rows) => + rows.map((row) => { + const spans = row.querySelectorAll('span'); + return Array.from(spans) + .map((span) => span.textContent?.trim() || '') + .join(' '); // Join spans within a row with a space + }) + )).filter((line) => line && line.length > 0) // Remove empty lines + .join('\n'); // Join rows with newlines this.code.logger.log('---- START: Terminal Contents ----'); this.code.logger.log(plainText); From 8e7ea98e47bd0f15f7d365031919e717d598f0b3 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Fri, 24 Jan 2025 06:29:19 -0600 Subject: [PATCH 3/5] nit --- test/e2e/tests/_test.setup.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/tests/_test.setup.ts b/test/e2e/tests/_test.setup.ts index 8082fc18b42..d75b59b2b5c 100644 --- a/test/e2e/tests/_test.setup.ts +++ b/test/e2e/tests/_test.setup.ts @@ -302,13 +302,13 @@ export const test = base.extend({ await use(); + await app.workbench.console.logConsoleContents(); + await app.workbench.terminal.logTerminalContents(); + const failed = testInfo.status !== testInfo.expectedStatus; const testTitle = testInfo.title; const endLog = failed ? `>>> !!! FAILURE !!! Test end: '${testTitle}' !!! FAILURE !!! <<<` : `>>> Test end: '${testTitle}' <<<`; - await app.workbench.console.logConsoleContents(); - await app.workbench.terminal.logTerminalContents(); - logger.log(''); logger.log(endLog); logger.log(''); From 64c9f8c4fa706f2995e924664d9135c93c41e7f7 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Fri, 24 Jan 2025 06:30:17 -0600 Subject: [PATCH 4/5] cleanup --- test/e2e/pages/terminal.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/pages/terminal.ts b/test/e2e/pages/terminal.ts index 1b1aae5fb72..b292924c153 100644 --- a/test/e2e/pages/terminal.ts +++ b/test/e2e/pages/terminal.ts @@ -78,10 +78,10 @@ export class Terminal { const spans = row.querySelectorAll('span'); return Array.from(spans) .map((span) => span.textContent?.trim() || '') - .join(' '); // Join spans within a row with a space + .join(' '); }) - )).filter((line) => line && line.length > 0) // Remove empty lines - .join('\n'); // Join rows with newlines + )).filter((line) => line && line.length > 0) + .join('\n'); this.code.logger.log('---- START: Terminal Contents ----'); this.code.logger.log(plainText); From cd0b22a2dff2ad8ba76cedccc07b46be70374ee6 Mon Sep 17 00:00:00 2001 From: Marie Idleman Date: Fri, 24 Jan 2025 06:50:09 -0600 Subject: [PATCH 5/5] rename vars --- test/e2e/pages/terminal.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/pages/terminal.ts b/test/e2e/pages/terminal.ts index b292924c153..6ff84564ae6 100644 --- a/test/e2e/pages/terminal.ts +++ b/test/e2e/pages/terminal.ts @@ -72,8 +72,8 @@ export class Terminal { } async logTerminalContents() { - const locator = this.code.driver.page.locator('.xterm-rows > div'); - const plainText = (await locator.evaluateAll((rows) => + const terminalRows = this.code.driver.page.locator('.xterm-rows > div'); + const terminalContents = (await terminalRows.evaluateAll((rows) => rows.map((row) => { const spans = row.querySelectorAll('span'); return Array.from(spans) @@ -84,7 +84,7 @@ export class Terminal { .join('\n'); this.code.logger.log('---- START: Terminal Contents ----'); - this.code.logger.log(plainText); + this.code.logger.log(terminalContents); this.code.logger.log('---- END: Terminal Contents ----'); } }