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
2 changes: 1 addition & 1 deletion .github/workflows/blog-auditor.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/cloclo.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/daily-multi-device-docs-tester.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/workflows/unbloat-docs.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/workflow/custom_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ func TestCustomEngineRenderPlaywrightMCPConfigWithDomainConfiguration(t *testing
t.Errorf("Expected Playwright configuration in output")
}

// Check that it contains Playwright MCP npx configuration
if !strings.Contains(output, "@playwright/mcp@latest") {
t.Errorf("Expected Playwright MCP npx package in output")
// Check that it contains Playwright MCP npx configuration with the specified version
if !strings.Contains(output, "@playwright/mcp@v1.40.0") {
t.Errorf("Expected Playwright MCP npx package with v1.40.0 in output")
}

// Check that it contains --allowed-origins flag when domains are configured
Expand Down Expand Up @@ -351,9 +351,9 @@ func TestCustomEngineRenderPlaywrightMCPConfigDefaultDomains(t *testing.T) {
t.Errorf("Expected Playwright configuration in output")
}

// Check that it contains Playwright MCP npx configuration
if !strings.Contains(output, "@playwright/mcp@latest") {
t.Errorf("Expected Playwright MCP npx package in output")
// Check that it contains Playwright MCP npx configuration with the specified version
if !strings.Contains(output, "@playwright/mcp@v1.40.0") {
t.Errorf("Expected Playwright MCP npx package with v1.40.0 in output")
}

// Check that it contains --allowed-origins flag for default domains
Expand Down
13 changes: 10 additions & 3 deletions pkg/workflow/mcp-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func renderPlaywrightMCPConfigWithOptions(yaml *strings.Builder, playwrightTool
}

// Determine version to use - respect version configuration if provided
// Default to the pinned version from constants
// Default to the pinned version from constants when no version is specified
playwrightPackage := "@playwright/mcp@" + constants.DefaultPlaywrightVersion
if includeCopilotFields && args.ImageVersion != "" && args.ImageVersion != "latest" {
if args.ImageVersion != "" {
playwrightPackage = "@playwright/mcp@" + args.ImageVersion
}

Expand Down Expand Up @@ -200,11 +200,18 @@ func renderPlaywrightMCPConfigTOML(yaml *strings.Builder, playwrightTool any) {
args := generatePlaywrightDockerArgs(playwrightTool)
customArgs := getPlaywrightCustomArgs(playwrightTool)

// Determine version to use - respect version configuration if provided
// Default to the pinned version from constants when no version is specified
version := constants.DefaultPlaywrightVersion
if args.ImageVersion != "" {
version = args.ImageVersion
}

yaml.WriteString(" \n")
yaml.WriteString(" [mcp_servers.playwright]\n")
yaml.WriteString(" command = \"npx\"\n")
yaml.WriteString(" args = [\n")
yaml.WriteString(fmt.Sprintf(" \"@playwright/mcp@%s\",\n", constants.DefaultPlaywrightVersion))
yaml.WriteString(fmt.Sprintf(" \"@playwright/mcp@%s\",\n", version))
yaml.WriteString(" \"--output-dir\",\n")
yaml.WriteString(" \"/tmp/gh-aw/mcp-logs/playwright\"")
if len(args.AllowedDomains) > 0 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/workflow/mcp_config_refactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package workflow
import (
"strings"
"testing"

"github.com/githubnext/gh-aw/pkg/constants"
)

// TestRenderPlaywrightMCPConfigWithOptions verifies the shared Playwright config helper
Expand Down Expand Up @@ -48,7 +50,7 @@ func TestRenderPlaywrightMCPConfigWithOptions(t *testing.T) {
`"playwright": {`,
`"command": "npx"`,
`"args": [`,
`"@playwright/mcp@latest"`,
`"@playwright/mcp@` + constants.DefaultPlaywrightVersion + `"`,
`"--output-dir"`,
`"/tmp/gh-aw/mcp-logs/playwright"`,
` },`,
Expand Down Expand Up @@ -269,7 +271,7 @@ func TestRenderPlaywrightMCPConfigTOML(t *testing.T) {
`[mcp_servers.playwright]`,
`command = "npx"`,
`args = [`,
`"@playwright/mcp@latest"`,
`"@playwright/mcp@` + constants.DefaultPlaywrightVersion + `"`,
`"--output-dir"`,
`"/tmp/gh-aw/mcp-logs/playwright"`,
},
Expand Down
6 changes: 4 additions & 2 deletions pkg/workflow/mcp_config_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package workflow
import (
"strings"
"testing"

"github.com/githubnext/gh-aw/pkg/constants"
)

// TestRenderPlaywrightMCPConfigShared tests the shared renderPlaywrightMCPConfig function
Expand All @@ -23,7 +25,7 @@ func TestRenderPlaywrightMCPConfigShared(t *testing.T) {
wantContains: []string{
`"playwright": {`,
`"command": "npx"`,
`"@playwright/mcp@latest"`,
`"@playwright/mcp@` + constants.DefaultPlaywrightVersion + `"`,
`"--output-dir"`,
`"/tmp/gh-aw/mcp-logs/playwright"`,
`"--allowed-origins"`,
Expand All @@ -50,7 +52,7 @@ func TestRenderPlaywrightMCPConfigShared(t *testing.T) {
wantContains: []string{
`"playwright": {`,
`"command": "npx"`,
`"@playwright/mcp@latest"`,
`"@playwright/mcp@` + constants.DefaultPlaywrightVersion + `"`,
},
wantEnding: "},\n",
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/workflow/mcp_servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ func getGitHubAllowedTools(githubTool any) []string {
}

func getPlaywrightDockerImageVersion(playwrightTool any) string {
playwrightDockerImageVersion := "latest" // Default Playwright Docker image version
// Default to empty string - caller will use pinned version when empty
playwrightDockerImageVersion := ""
// Extract version setting from tool properties
if toolConfig, ok := playwrightTool.(map[string]any); ok {
if versionSetting, exists := toolConfig["version"]; exists {
Expand Down
55 changes: 55 additions & 0 deletions pkg/workflow/playwright_version_latest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package workflow

import (
"strings"

Check failure on line 4 in pkg/workflow/playwright_version_latest_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofmt)
"testing"
)

// TestPlaywrightExplicitLatestVersion verifies that when user explicitly sets version: "latest"
// it is respected and used in the rendered output
func TestPlaywrightExplicitLatestVersion(t *testing.T) {
t.Run("Explicit latest version for Copilot engine", func(t *testing.T) {
var yaml strings.Builder
playwrightTool := map[string]any{
"version": "latest",
"allowed_domains": []string{"example.com"},
}

renderPlaywrightMCPConfigWithOptions(&yaml, playwrightTool, false, true, true)
output := yaml.String()

if !strings.Contains(output, "@playwright/mcp@latest") {
t.Errorf("Expected @playwright/mcp@latest when user explicitly sets version: latest, got: %s", output)
}
})

t.Run("Explicit latest version for Claude engine", func(t *testing.T) {
var yaml strings.Builder
playwrightTool := map[string]any{
"version": "latest",
"allowed_domains": []string{"example.com"},
}

renderPlaywrightMCPConfigWithOptions(&yaml, playwrightTool, false, false, false)
output := yaml.String()

if !strings.Contains(output, "@playwright/mcp@latest") {
t.Errorf("Expected @playwright/mcp@latest when user explicitly sets version: latest, got: %s", output)
}
})

t.Run("Explicit latest version for Codex engine (TOML)", func(t *testing.T) {
var yaml strings.Builder
playwrightTool := map[string]any{
"version": "latest",
"allowed_domains": []string{"example.com"},
}

renderPlaywrightMCPConfigTOML(&yaml, playwrightTool)
output := yaml.String()

if !strings.Contains(output, "@playwright/mcp@latest") {
t.Errorf("Expected @playwright/mcp@latest when user explicitly sets version: latest, got: %s", output)
}
})
}
18 changes: 14 additions & 4 deletions pkg/workflow/version_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestVersionField(t *testing.T) {

// Test Playwright tool version extraction
t.Run("Playwright version field extraction", func(t *testing.T) {
// Test "version" field
// Test "version" field with specific version
playwrightTool := map[string]any{
"allowed_domains": []any{"example.com"},
"version": "v1.41.0",
Expand All @@ -43,13 +43,23 @@ func TestVersionField(t *testing.T) {
t.Errorf("Expected v1.41.0, got %s", result)
}

// Test default value when version field is not present
// Test explicit "latest" version is respected
playwrightToolLatest := map[string]any{
"allowed_domains": []any{"example.com"},
"version": "latest",
}
result = getPlaywrightDockerImageVersion(playwrightToolLatest)
if result != "latest" {
t.Errorf("Expected latest (user explicitly set it), got %s", result)
}

// Test default value when version field is not present (empty string, caller uses pinned version)
playwrightToolDefault := map[string]any{
"allowed_domains": []any{"example.com"},
}
result = getPlaywrightDockerImageVersion(playwrightToolDefault)
if result != "latest" {
t.Errorf("Expected default latest, got %s", result)
if result != "" {
t.Errorf("Expected default empty string, got %s", result)
}
})

Expand Down
Loading