Skip to content

fix : naming convention session / main erasing with long test.title/tags #4992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
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
14 changes: 8 additions & 6 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -2377,15 +2377,16 @@ class Playwright extends Helper {
if (this.options.recordVideo && this.page && this.page.video()) {
test.artifacts.video = saveVideoForPage(this.page, `${test.title}.failed`)
for (const sessionName in this.sessionPages) {
test.artifacts[`video_${sessionName}`] = saveVideoForPage(this.sessionPages[sessionName], `${test.title}_${sessionName}.failed`)
if (sessionName === '') continue
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider defining a constant (e.g. MAIN_SESSION) for the main session check instead of using an empty string literal, to enhance code clarity and maintainability.

Suggested change
if (sessionName === '') continue
if (sessionName === MAIN_SESSION) continue

Copilot uses AI. Check for mistakes.

test.artifacts[`video_${sessionName}`] = saveVideoForPage(this.sessionPages[sessionName], `${sessionName}_${test.title}.failed`)
}
}

if (this.options.trace) {
test.artifacts.trace = await saveTraceForContext(this.browserContext, `${test.title}.failed`)
for (const sessionName in this.sessionPages) {
if (!this.sessionPages[sessionName].context) continue
test.artifacts[`trace_${sessionName}`] = await saveTraceForContext(this.sessionPages[sessionName].context, `${test.title}_${sessionName}.failed`)
if (!this.sessionPages[sessionName].context || sessionName === '') continue
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Similarly, use a named constant for the main session check in the trace saving logic to improve clarity and avoid hard-coding empty string comparisons.

Suggested change
if (!this.sessionPages[sessionName].context || sessionName === '') continue
if (!this.sessionPages[sessionName].context || sessionName === MAIN_SESSION_NAME) continue

Copilot uses AI. Check for mistakes.

test.artifacts[`trace_${sessionName}`] = await saveTraceForContext(this.sessionPages[sessionName].context(), `${sessionName}_${test.title}.failed`)
}
}

Expand All @@ -2399,7 +2400,8 @@ class Playwright extends Helper {
if (this.options.keepVideoForPassedTests) {
test.artifacts.video = saveVideoForPage(this.page, `${test.title}.passed`)
for (const sessionName of Object.keys(this.sessionPages)) {
test.artifacts[`video_${sessionName}`] = saveVideoForPage(this.sessionPages[sessionName], `${test.title}_${sessionName}.passed`)
if (sessionName === '') continue
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a consistent iteration approach (for example, either for...in or Object.keys) across the different loops for handling sessions to improve readability.

Copilot uses AI. Check for mistakes.

test.artifacts[`video_${sessionName}`] = saveVideoForPage(this.sessionPages[sessionName], `${sessionName}_${test.title}.passed`)
}
} else {
this.page
Expand All @@ -2414,8 +2416,8 @@ class Playwright extends Helper {
if (this.options.trace) {
test.artifacts.trace = await saveTraceForContext(this.browserContext, `${test.title}.passed`)
for (const sessionName in this.sessionPages) {
if (!this.sessionPages[sessionName].context) continue
test.artifacts[`trace_${sessionName}`] = await saveTraceForContext(this.sessionPages[sessionName].context, `${test.title}_${sessionName}.passed`)
if (!this.sessionPages[sessionName].context || sessionName === '') continue
test.artifacts[`trace_${sessionName}`] = await saveTraceForContext(this.sessionPages[sessionName].context(), `${sessionName}_${test.title}.passed`)
}
}
} else {
Expand Down
Loading