Skip to content

Commit f202a86

Browse files
authored
Merge pull request #345 from shapehq/develop
Deploy to production
2 parents 27ef780 + c488c73 commit f202a86

File tree

70 files changed

+3355
-2357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3355
-2357
lines changed

.github/dependabot.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ updates:
1414
mui:
1515
patterns:
1616
- "@mui/*"
17+
typescript-eslint:
18+
patterns:
19+
- "@typescript-eslint/*"

.github/workflows/test-sql-queries.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Test SQL Queries
22
on:
33
workflow_dispatch:
44
pull_request:
5+
env:
6+
PGPASSWORD: postgres
7+
DATABASE_NAME: testdb
58
jobs:
69
test:
710
name: Test SQL Queries
@@ -18,8 +21,8 @@ jobs:
1821
--health-retries=5
1922
env:
2023
POSTGRES_USER: postgres
21-
POSTGRES_PASSWORD: postgres
22-
POSTGRES_DB: testdb
24+
POSTGRES_PASSWORD: ${{ env.PGPASSWORD }}
25+
POSTGRES_DB: ${{ env.DATABASE_NAME }}
2326
steps:
2427
- name: Checkout repository
2528
uses: actions/checkout@v4
@@ -29,10 +32,20 @@ jobs:
2932
sleep 1
3033
done
3134
- name: Run create-tables.sql
32-
env:
33-
PGPASSWORD: postgres
34-
run: psql -h localhost -U postgres -d testdb -f create-tables.sql
35+
run: psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -f create-tables.sql
36+
- name: Ensure tables were created
37+
run: |
38+
COUNT=$(psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -t -A -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';")
39+
if [ "$COUNT" -eq 0 ]; then
40+
echo "No tables found. Exiting with error."
41+
exit 1
42+
fi
3543
- name: Run drop-tables.sql
36-
env:
37-
PGPASSWORD: postgres
38-
run: psql -h localhost -U postgres -d testdb -f drop-tables.sql
44+
run: psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -f drop-tables.sql
45+
- name: Ensure all tables were dropped
46+
run: |
47+
COUNT=$(psql -v ON_ERROR_STOP=1 -h localhost -U postgres -d ${{ env.DATABASE_NAME }} -t -A -c "SELECT count(*) FROM information_schema.tables WHERE table_schema = 'public';")
48+
if [ "$COUNT" -gt 0 ]; then
49+
echo "Tables found: $count. Exiting with error."
50+
exit 1
51+
fi

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.13.1
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { makeFullRepositoryName } from "@/common/utils/makeFullRepositoryName";
2+
3+
test("It returns a sanitized repository name with a suffix", async () => {
4+
const result = makeFullRepositoryName({ name: "My Project", suffix: "-repo" });
5+
expect(result).toEqual("myproject-repo");
6+
});
7+
8+
test("It returns a lowercase repository name", async () => {
9+
const result = makeFullRepositoryName({ name: "MyProject", suffix: "-repo" });
10+
expect(result).toEqual("myproject-repo");
11+
});
12+
13+
test("It trims spaces from the name", async () => {
14+
const result = makeFullRepositoryName({ name: " My Project ", suffix: "-repo" });
15+
expect(result).toEqual("myproject-repo");
16+
});
17+
18+
test("It removes non-alphanumeric characters except dashes", async () => {
19+
const result = makeFullRepositoryName({ name: "My!@#Pro$%^ject", suffix: "-repo" });
20+
expect(result).toEqual("myproject-repo");
21+
});
22+
23+
test("It replaces spaces with dashes", async () => {
24+
const result = makeFullRepositoryName({ name: "My Project", suffix: "-repo" });
25+
expect(result).toEqual("myproject-repo");
26+
});
27+
28+
test("It handles names with multiple spaces correctly", async () => {
29+
const result = makeFullRepositoryName({ name: "My Project", suffix: "-repo" });
30+
expect(result).toEqual("myproject-repo");
31+
});
32+
33+
test("It handles names with no characters left after sanitization", async () => {
34+
const result = makeFullRepositoryName({ name: "!@#$%^", suffix: "-repo" });
35+
expect(result).toEqual("-repo");
36+
});
37+
38+
test("It handles names that are already safe", async () => {
39+
const result = makeFullRepositoryName({ name: "safe-project-name", suffix: "-repo" });
40+
expect(result).toEqual("safe-project-name-repo");
41+
});
42+
43+
test("It returns just the suffix if the name is an empty string", async () => {
44+
const result = makeFullRepositoryName({ name: "", suffix: "-repo" });
45+
expect(result).toEqual("-repo");
46+
});
47+
48+
test("It handles a suffix with special characters correctly", async () => {
49+
const result = makeFullRepositoryName({ name: "My Project", suffix: "!-repo" });
50+
expect(result).toEqual("myproject!-repo");
51+
});
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { makeNewGitHubRepositoryLink } from "@/common/utils/makeNewGitHubRepositoryLink";
2+
3+
test("It generates a URL with repository name and description", async () => {
4+
const result = makeNewGitHubRepositoryLink({
5+
repositoryName: "test-repo",
6+
description: "A test repository"
7+
});
8+
expect(result).toEqual(
9+
"https://github.com/new?name=test-repo&description=A%20test%20repository&visibility=private"
10+
);
11+
});
12+
13+
test("It encodes special characters in the repository name and description", async () => {
14+
const result = makeNewGitHubRepositoryLink({
15+
repositoryName: "test repo",
16+
description: "A test & description"
17+
});
18+
expect(result).toEqual(
19+
"https://github.com/new?name=test%20repo&description=A%20test%20%26%20description&visibility=private"
20+
);
21+
});
22+
23+
test("It generates a URL with a template repository", async () => {
24+
const result = makeNewGitHubRepositoryLink({
25+
templateName: "owner/template-repo",
26+
repositoryName: "test-repo",
27+
description: "A test repository"
28+
});
29+
expect(result).toEqual(
30+
"https://github.com/new?name=test-repo&description=A%20test%20repository&visibility=private&template_owner=owner&template_name=template-repo"
31+
);
32+
});
33+
34+
test("It handles template names with special characters", async () => {
35+
const result = makeNewGitHubRepositoryLink({
36+
templateName: "owner/template repo",
37+
repositoryName: "test-repo",
38+
description: "A test repository"
39+
});
40+
expect(result).toEqual(
41+
"https://github.com/new?name=test-repo&description=A%20test%20repository&visibility=private&template_owner=owner&template_name=template%20repo"
42+
);
43+
});
44+
45+
test("It returns the URL without template parameters if templateName is not provided", async () => {
46+
const result = makeNewGitHubRepositoryLink({
47+
repositoryName: "test-repo",
48+
description: "A test repository"
49+
});
50+
expect(result).toEqual(
51+
"https://github.com/new?name=test-repo&description=A%20test%20repository&visibility=private"
52+
);
53+
});
54+
55+
test("It returns a URL even if the template name cannot be split into owner and repository", async () => {
56+
const result = makeNewGitHubRepositoryLink({
57+
templateName: "invalidTemplateName",
58+
repositoryName: "test-repo",
59+
description: "A test repository"
60+
});
61+
expect(result).toEqual(
62+
"https://github.com/new?name=test-repo&description=A%20test%20repository&visibility=private"
63+
);
64+
});

drop-tables.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
DROP TABLE oauth_tokens;
2-
DROP TABLE verification_token;
32
DROP TABLE accounts;
43
DROP TABLE sessions;
54
DROP TABLE users;

0 commit comments

Comments
 (0)