Skip to content

Commit ee58929

Browse files
committed
refactor to remove exposing proxy server url
1 parent 7ad4de4 commit ee58929

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/testing/containers/n8n-test-container-creation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export interface N8NStack {
8686
baseUrl: string;
8787
stop: () => Promise<void>;
8888
containers: StartedTestContainer[];
89-
proxyServerUrl?: string;
9089
}
9190

9291
/**
@@ -274,7 +273,6 @@ export async function createN8NStack(config: N8NConfig = {}): Promise<N8NStack>
274273

275274
return {
276275
baseUrl,
277-
proxyServerUrl,
278276
stop: async () => {
279277
await stopN8NStack(containers, network, uniqueProjectName);
280278
},

packages/testing/playwright/fixtures/base.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,24 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
164164

165165
proxyServer: async ({ n8nContainer }, use) => {
166166
// n8nContainer is "null" if running tests in "local" mode
167-
// proxy server is also not initialized in local mode (only in container modes can it be supported)
168-
// tests that require proxy server should have "@capability:proxy" so that they are skipped in local mode
169-
if (!n8nContainer?.proxyServerUrl) {
167+
if (!n8nContainer) {
170168
throw new TestError(
171169
'Testing with Proxy server is not supported when using N8N_BASE_URL environment variable. Remove N8N_BASE_URL to use containerized testing.',
172170
);
173171
}
174172

175-
const proxyServer = new ProxyServer(n8nContainer.proxyServerUrl);
173+
const proxyServerContainer = n8nContainer.containers.find((container) =>
174+
container.getName().endsWith('proxyserver'),
175+
);
176+
177+
// proxy server is not initialized in local mode (it be only supported in container modes)
178+
// tests that require proxy server should have "@capability:proxy" so that they are skipped in local mode
179+
if (!proxyServerContainer) {
180+
throw new TestError('Proxy server container not initialized. Cannot initialize client.');
181+
}
182+
183+
const serverUrl = `http://${proxyServerContainer?.getHost()}:${proxyServerContainer?.getFirstMappedPort()}`;
184+
const proxyServer = new ProxyServer(serverUrl);
176185
await proxyServer.loadExpectations();
177186

178187
await use(proxyServer);

0 commit comments

Comments
 (0)