@johnnyboy11234/esg-idea-contest 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/api/openapi.yaml +70 -0
- package/backend/cmd/server/main.go +10 -2
- package/backend/internal/account/logging_integration_test.go +70 -0
- package/backend/internal/api/api.gen.go +125 -0
- package/backend/internal/auth/internal/store/session.go +63 -5
- package/backend/internal/auth/logging_integration_test.go +88 -0
- package/backend/internal/auth/login.go +252 -0
- package/backend/internal/auth/login_integration_test.go +421 -0
- package/backend/internal/auth/login_test.go +68 -0
- package/backend/internal/auth/logout.go +68 -0
- package/backend/internal/auth/logout_integration_test.go +124 -0
- package/backend/internal/auth/me.go +40 -0
- package/backend/internal/auth/me_integration_test.go +70 -0
- package/backend/internal/auth/session.go +20 -1
- package/backend/internal/server/api.go +14 -0
- package/backend/internal/server/public.go +3 -1
- package/backend/internal/shared/web/problem.go +9 -0
- package/backend/internal/shared/web/retryafter_test.go +31 -0
- package/frontend/src/app/index.css +102 -102
- package/frontend/src/app/layouts.tsx +75 -18
- package/frontend/src/app/pages/auth.tsx +52 -78
- package/frontend/src/app/pages/login.test.tsx +218 -0
- package/frontend/src/app/pages/register.test.tsx +231 -0
- package/frontend/src/app/router.tsx +83 -34
- package/frontend/src/app/session.ts +53 -22
- package/frontend/src/features/auth/LoginForm.tsx +145 -0
- package/frontend/src/features/auth/RegisterForm.tsx +211 -0
- package/frontend/src/features/auth/login.ts +23 -0
- package/frontend/src/features/auth/register.ts +105 -0
- package/frontend/src/shared/i18n/locales/en.ts +15 -2
- package/frontend/src/shared/i18n/locales/zh-TW.ts +15 -2
- package/frontend/src/shared/text/index.ts +20 -0
- package/frontend/src/shared/text/text.test.ts +28 -1
- package/frontend/vite.config.ts +5 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import cleanup from 'testdata/text-cleanup.json';
|
|
2
|
-
import { checkName, checkSummary, countCodePoints, trimWhitespace } from './index';
|
|
2
|
+
import { checkEmail, checkName, checkSummary, countCodePoints, trimWhitespace } from './index';
|
|
3
3
|
|
|
4
4
|
describe('shared/text contract (testdata/text-cleanup.json)', () => {
|
|
5
5
|
it('has cases', () => {
|
|
@@ -20,3 +20,30 @@ describe('trimWhitespace', () => {
|
|
|
20
20
|
expect(trimWhitespace('a')).toBe('a');
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
describe('checkEmail (PRD §6.3)', () => {
|
|
25
|
+
it.each([
|
|
26
|
+
['a@x.com', 'a@x.com', ''],
|
|
27
|
+
[' A@X.Com ', 'a@x.com', ''],
|
|
28
|
+
[' a@x ', 'a@x', ''],
|
|
29
|
+
['a@localhost', 'a@localhost', ''],
|
|
30
|
+
['', '', 'REQUIRED'],
|
|
31
|
+
[' ', '', 'REQUIRED'],
|
|
32
|
+
['a b@x.com', 'a b@x.com', 'INVALID_FORMAT'],
|
|
33
|
+
['a@x .com', 'a@x .com', 'INVALID_FORMAT'],
|
|
34
|
+
['é@x.com', 'é@x.com', 'INVALID_FORMAT'],
|
|
35
|
+
['ax.com', 'ax.com', 'INVALID_FORMAT'],
|
|
36
|
+
['@x.com', '@x.com', 'INVALID_FORMAT'],
|
|
37
|
+
['a@', 'a@', 'INVALID_FORMAT'],
|
|
38
|
+
['a@@x.com', 'a@@x.com', 'INVALID_FORMAT'],
|
|
39
|
+
['a@b@x.com', 'a@b@x.com', 'INVALID_FORMAT'],
|
|
40
|
+
])('%j', (input, cleaned, problem) => {
|
|
41
|
+
expect(checkEmail(input)).toEqual({ cleaned, problem });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('allows 254 characters and rejects 255', () => {
|
|
45
|
+
const at = (n: number) => `${'a'.repeat(n - 2)}@x`;
|
|
46
|
+
expect(checkEmail(at(254)).problem).toBe('');
|
|
47
|
+
expect(checkEmail(at(255)).problem).toBe('OUT_OF_RANGE');
|
|
48
|
+
});
|
|
49
|
+
});
|
package/frontend/vite.config.ts
CHANGED
|
@@ -9,7 +9,11 @@ const testdata = fileURLToPath(new URL('../testdata', import.meta.url));
|
|
|
9
9
|
export default defineConfig({
|
|
10
10
|
plugins: [react(), tailwindcss()],
|
|
11
11
|
resolve: { alias: { '@': src, testdata } },
|
|
12
|
-
server: {
|
|
12
|
+
server: {
|
|
13
|
+
fs: { allow: ['..'] },
|
|
14
|
+
// The app calls same-origin /api/v1; in dev the Go backend (ESG_PUBLIC_ADDR, default :8080) answers it.
|
|
15
|
+
proxy: { '/api': process.env.ESG_API_TARGET ?? 'http://localhost:8080' },
|
|
16
|
+
},
|
|
13
17
|
test: {
|
|
14
18
|
environment: 'jsdom',
|
|
15
19
|
globals: true,
|
package/package.json
CHANGED