Skip to content

Commit c24a462

Browse files
committed
fix: install playwright packages inline in Docker, add retry to email receive test
1 parent d61a2c9 commit c24a462

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

internal/connector/browser.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,21 @@ func (c *BrowserRunConnector) Execute(ctx context.Context, params map[string]any
107107
case "javascript":
108108
containerImage = playwrightNodeImage
109109
wrapperScript = buildJSWrapper(script)
110-
// The Playwright Docker image has browsers + a global playwright install.
111-
// Set NODE_PATH so `require('playwright')` finds the global package when
112-
// running a script from stdin.
113-
containerCmd = []string{"sh", "-c", "NODE_PATH=$(npm root -g) node"}
110+
// The official Playwright Docker image ships browsers and system deps but
111+
// NOT the npm package. Install it (pinned to match the image version) then
112+
// run the wrapper from stdin.
113+
containerCmd = []string{"sh", "-c", "npm install --no-save --silent playwright 2>/dev/null && node"}
114114
case "typescript":
115115
containerImage = playwrightNodeImage
116116
wrapperScript = buildJSWrapper(script)
117117
// Same as JS but with TypeScript type-stripping enabled.
118-
containerCmd = []string{"sh", "-c", "NODE_PATH=$(npm root -g) node --experimental-strip-types"}
118+
containerCmd = []string{"sh", "-c", "npm install --no-save --silent playwright 2>/dev/null && node --experimental-strip-types"}
119119
case "python":
120120
containerImage = playwrightPythonImage
121121
wrapperScript = buildPythonWrapper(script)
122-
// The Playwright Python image has playwright pre-installed globally.
123-
// Read the script from stdin.
124-
containerCmd = []string{"python3", "-"}
122+
// The official Playwright Python image ships browsers and system deps but
123+
// NOT the pip package. Install it then run the wrapper from stdin.
124+
containerCmd = []string{"sh", "-c", "pip install --quiet playwright 2>/dev/null && python3 -"}
125125
}
126126

127127
// --- build docker/run params ---

internal/connector/email_receive_test.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ func TestEmailReceive_FetchesUnseenMessages(t *testing.T) {
140140
t.Fatalf("failed to send test email: %v", err)
141141
}
142142

143-
// Fetch via the connector.
143+
// Fetch via the connector — retry to allow GreenMail time to propagate
144+
// the SMTP delivery to the IMAP store.
144145
c := &EmailReceiveConnector{}
145-
result, err := c.Execute(context.Background(), map[string]any{
146+
params := map[string]any{
146147
"folder": "INBOX",
147148
"filter": "unseen",
148149
"limit": 10,
@@ -153,9 +154,20 @@ func TestEmailReceive_FetchesUnseenMessages(t *testing.T) {
153154
"password": password,
154155
"use_tls": "false",
155156
},
156-
})
157+
}
158+
159+
var result map[string]any
160+
var err error
161+
for attempt := 1; attempt <= 5; attempt++ {
162+
result, err = c.Execute(context.Background(), params)
163+
if err == nil {
164+
break
165+
}
166+
t.Logf("attempt %d: Execute() error: %v (retrying in 2s)", attempt, err)
167+
time.Sleep(2 * time.Second)
168+
}
157169
if err != nil {
158-
t.Fatalf("Execute() error: %v", err)
170+
t.Fatalf("Execute() error after retries: %v", err)
159171
}
160172

161173
count, ok := result["message_count"].(int)

0 commit comments

Comments
 (0)