Skip to content

Commit b36af0a

Browse files
authored
Merge branch 'staging' into CanvasAnalysisAndTests
2 parents 63df81d + ed2b374 commit b36af0a

File tree

11 files changed

+559
-98
lines changed

11 files changed

+559
-98
lines changed

app/api/chat/[graph]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { NextRequest, NextResponse } from "next/server"
22
import { getEnvVariables } from "../../utils"
33

44

5-
export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {
5+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
66

7-
const repo = params.graph
7+
const repo = (await params).graph
88
const msg = request.nextUrl.searchParams.get('msg')
99

1010
try {

app/api/repo/[graph]/[node]/route.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { getEnvVariables } from "@/app/api/utils";
22
import { NextRequest, NextResponse } from "next/server";
33

4-
export async function POST(request: NextRequest, { params }: { params: { graph: string, node: string } }) {
4+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string, node: string }> }) {
55

6-
const repo = params.graph;
7-
const src = Number(params.node);
6+
const p = await params;
7+
8+
const repo = p.graph;
9+
const src = Number(p.node);
810
const dest = Number(request.nextUrl.searchParams.get('targetId'))
911

1012
try {

app/api/repo/[graph]/commit/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { getEnvVariables } from "@/app/api/utils";
22
import { NextRequest, NextResponse } from "next/server";
33

4-
export async function GET(request: NextRequest, { params }: { params: { graph: string } }) {
4+
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
5+
6+
const repo = (await params).graph
57

6-
const repo = params.graph
7-
88
try {
99

1010
const { url, token } = getEnvVariables()
@@ -32,6 +32,6 @@ export async function GET(request: NextRequest, { params }: { params: { graph: s
3232
}
3333
}
3434

35-
export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {
35+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
3636

3737
}

app/api/repo/[graph]/info/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { NextRequest, NextResponse } from "next/server";
22
import { getEnvVariables } from "@/app/api/utils";
33

4-
export async function GET(request: NextRequest, { params }: { params: { graph: string } }) {
4+
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
55

6-
const repo = params.graph
6+
const repo = (await params).graph
77

88
try {
9-
9+
1010
const { url, token } = getEnvVariables();
1111

1212
const result = await fetch(`${url}/repo_info`, {

app/api/repo/[graph]/neighbors/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { NextRequest, NextResponse } from "next/server";
22
import { getEnvVariables } from "@/app/api/utils";
33

4-
export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {
4+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
55

6-
const repo = params.graph;
6+
const repo = (await params).graph;
77
const node_ids = (await request.json()).nodeIds.map((id: string) => Number(id));
88

99
try {
@@ -13,7 +13,7 @@ export async function POST(request: NextRequest, { params }: { params: { graph:
1313
if (node_ids.length === 0) {
1414
throw new Error("nodeIds is required");
1515
}
16-
16+
1717
const result = await fetch(`${url}/get_neighbors`, {
1818
method: 'POST',
1919
body: JSON.stringify({ node_ids, repo }),

app/api/repo/[graph]/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { NextRequest, NextResponse } from "next/server"
22
import { getEnvVariables } from "../../utils"
33

4-
export async function GET(request: NextRequest, { params }: { params: { graph: string } }) {
4+
export async function GET(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
55

6-
const graphName = params.graph
6+
const graphName = (await params).graph
77

88
try {
99

@@ -29,9 +29,9 @@ export async function GET(request: NextRequest, { params }: { params: { graph: s
2929
}
3030
}
3131

32-
export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {
32+
export async function POST(request: NextRequest, { params }: { params: Promise<{ graph: string }> }) {
3333

34-
const repo = params.graph
34+
const repo = (await params).graph
3535
const prefix = request.nextUrl.searchParams.get('prefix')
3636

3737
try {

app/components/Input.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ export default function Input({ value, onValueChange, handleSubmit, graph, icon,
145145
value={value || ""}
146146
onChange={(e) => {
147147
const newVal = e.target.value
148+
const invalidChars = /[%*()\-\[\]{};:"|~]/;
149+
150+
if (invalidChars.test(newVal)) {
151+
e.target.setCustomValidity(`The character "${newVal.match(invalidChars)?.[0]}" is not allowed in this field.`);
152+
e.target.reportValidity();
153+
return;
154+
}
155+
e.target.setCustomValidity('');
148156
onValueChange({ name: newVal })
149157
}}
150158
{...props}

e2e/config/testData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ const categorizeCharacters = (characters: string[], expectedRes: boolean): { cha
1010
};
1111

1212
export const specialCharacters: { character: string; expectedRes: boolean }[] = [
13-
...categorizeCharacters(['%', '*', '(', ')', '-', '[', ']', '{', '}', ';', ':', '"', '|', '~'], true),
14-
...categorizeCharacters(['!', '@', '$', '^', '_', '=', '+', "'", ',', '.', '<', '>', '/', '?', '\\', '`', '&', '#'], false)
13+
...categorizeCharacters(['%', '*', '(', ')', '-', '[', ']', '{', '}', ';', ':', '"', '|', '~'], false),
14+
...categorizeCharacters(['!', '@', '$', '^', '_', '=', '+', "'", ',', '.', '<', '>', '/', '?', '\\', '`', '&', '#'], true)
1515
];

e2e/tests/codeGraph.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test.describe("Code graph tests", () => {
6262
await codeGraph.selectGraph(GRAPH_ID);
6363
await codeGraph.fillSearchBar(character);
6464
await delay(1000);
65-
expect(await codeGraph.isNotificationError()).toBe(expectedRes);
65+
expect((await codeGraph.getSearchBarInputValue()).includes(character)).toBe(expectedRes);
6666
});
6767
});
6868

0 commit comments

Comments
 (0)