@johnnyboy11234/esg-idea-contest 0.2.2 → 0.2.3

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.
Files changed (35) hide show
  1. package/backend/api/openapi.yaml +70 -0
  2. package/backend/cmd/server/main.go +10 -2
  3. package/backend/internal/account/logging_integration_test.go +70 -0
  4. package/backend/internal/api/api.gen.go +125 -0
  5. package/backend/internal/auth/internal/store/session.go +63 -5
  6. package/backend/internal/auth/logging_integration_test.go +88 -0
  7. package/backend/internal/auth/login.go +252 -0
  8. package/backend/internal/auth/login_integration_test.go +421 -0
  9. package/backend/internal/auth/login_test.go +68 -0
  10. package/backend/internal/auth/logout.go +68 -0
  11. package/backend/internal/auth/logout_integration_test.go +124 -0
  12. package/backend/internal/auth/me.go +40 -0
  13. package/backend/internal/auth/me_integration_test.go +70 -0
  14. package/backend/internal/auth/session.go +20 -1
  15. package/backend/internal/server/api.go +14 -0
  16. package/backend/internal/server/public.go +3 -1
  17. package/backend/internal/shared/web/problem.go +9 -0
  18. package/backend/internal/shared/web/retryafter_test.go +31 -0
  19. package/frontend/src/app/index.css +102 -102
  20. package/frontend/src/app/layouts.tsx +75 -18
  21. package/frontend/src/app/pages/auth.tsx +52 -78
  22. package/frontend/src/app/pages/login.test.tsx +218 -0
  23. package/frontend/src/app/pages/register.test.tsx +231 -0
  24. package/frontend/src/app/router.tsx +83 -34
  25. package/frontend/src/app/session.ts +53 -22
  26. package/frontend/src/features/auth/LoginForm.tsx +145 -0
  27. package/frontend/src/features/auth/RegisterForm.tsx +211 -0
  28. package/frontend/src/features/auth/login.ts +23 -0
  29. package/frontend/src/features/auth/register.ts +105 -0
  30. package/frontend/src/shared/i18n/locales/en.ts +15 -2
  31. package/frontend/src/shared/i18n/locales/zh-TW.ts +15 -2
  32. package/frontend/src/shared/text/index.ts +20 -0
  33. package/frontend/src/shared/text/text.test.ts +28 -1
  34. package/frontend/vite.config.ts +5 -1
  35. 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
+ });
@@ -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: { fs: { allow: ['..'] } },
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnnyboy11234/esg-idea-contest",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "ESG Idea Contest registration system: Go backend, React frontend and design documents (source distribution).",
5
5
  "license": "MIT",
6
6
  "author": "Brian Huang",