Skip to content

Commit b1a9db2

Browse files
committed
fix e2e
1 parent 60f2c2f commit b1a9db2

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

e2e/shared/streaming_template.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ test.describe(`Test streaming template ${templateFramework} ${dataSource} ${temp
3535
}
3636

3737
let port: number;
38-
let externalPort: number;
3938
let cwd: string;
4039
let name: string;
4140
let appProcess: ChildProcess;
@@ -44,7 +43,6 @@ test.describe(`Test streaming template ${templateFramework} ${dataSource} ${temp
4443

4544
test.beforeAll(async () => {
4645
port = Math.floor(Math.random() * 10000) + 10000;
47-
externalPort = port + 1;
4846
cwd = await createTestDir();
4947
const result = await runCreateLlama({
5048
cwd,
@@ -53,7 +51,6 @@ test.describe(`Test streaming template ${templateFramework} ${dataSource} ${temp
5351
dataSource,
5452
vectorDb,
5553
port,
56-
externalPort,
5754
postInstallAction: templatePostInstallAction,
5855
templateUI,
5956
appType,
@@ -102,7 +99,7 @@ test.describe(`Test streaming template ${templateFramework} ${dataSource} ${temp
10299
test.skip(templatePostInstallAction !== "runApp");
103100
test.skip(templateFramework === "nextjs");
104101
const response = await request.post(
105-
`http://localhost:${externalPort}/api/chat/request`,
102+
`http://localhost:${port}/api/chat/request`,
106103
{
107104
data: {
108105
messages: [

e2e/utils.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type RunCreateLlamaOptions = {
2525
dataSource: string;
2626
vectorDb: TemplateVectorDB;
2727
port: number;
28-
externalPort: number;
28+
externalPort?: number;
2929
postInstallAction: TemplatePostInstallAction;
3030
templateUI?: TemplateUI;
3131
appType?: AppType;
@@ -93,8 +93,6 @@ export async function runCreateLlama({
9393
"--use-pnpm",
9494
"--port",
9595
port,
96-
"--external-port",
97-
externalPort,
9896
"--post-install-action",
9997
postInstallAction,
10098
"--tools",
@@ -103,6 +101,10 @@ export async function runCreateLlama({
103101
"none",
104102
];
105103

104+
if (externalPort) {
105+
commandArgs.push("--external-port", externalPort);
106+
}
107+
106108
if (templateUI) {
107109
commandArgs.push("--ui", templateUI);
108110
}
@@ -142,12 +144,9 @@ export async function runCreateLlama({
142144

143145
// Wait for app to start
144146
if (postInstallAction === "runApp") {
145-
await checkAppHasStarted(
146-
appType === "--frontend",
147-
templateFramework,
148-
port,
149-
externalPort,
150-
);
147+
const portsToWait = externalPort ? [port, externalPort] : [port];
148+
149+
await waitPorts(portsToWait);
151150
} else if (postInstallAction === "dependencies") {
152151
await waitForProcess(appProcess, 1000 * 60); // wait 1 min for dependencies to be resolved
153152
} else {
@@ -167,19 +166,6 @@ export async function createTestDir() {
167166
return cwd;
168167
}
169168

170-
// eslint-disable-next-line max-params
171-
async function checkAppHasStarted(
172-
frontend: boolean,
173-
framework: TemplateFramework,
174-
port: number,
175-
externalPort: number,
176-
) {
177-
const portsToWait = frontend
178-
? [port, externalPort]
179-
: [framework === "nextjs" ? port : externalPort];
180-
await waitPorts(portsToWait);
181-
}
182-
183169
async function waitPorts(ports: number[]): Promise<void> {
184170
const waitForPort = async (port: number): Promise<void> => {
185171
await waitPort({

0 commit comments

Comments
 (0)