Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3e11a6ad1 | ||
|
|
6313817cd4 | ||
|
|
f9fba50093 | ||
|
|
c50b53cea0 | ||
|
|
7ee6b4969e | ||
|
|
1ef65523d3 | ||
|
|
738b727242 | ||
|
|
068ac93e40 | ||
|
|
53d642bbb7 | ||
|
|
f0ecd16cb0 | ||
|
|
2a4dd82643 | ||
|
|
d33cfd6ccc |
@@ -0,0 +1,14 @@
|
||||
# TODO: delete this file if unused
|
||||
# This is on the only .env file commited to git.
|
||||
# It's purpose is to provide an environment from which it can operate the app and do full development.
|
||||
|
||||
DATABASE_URL=postgres://app_client:app_password@localhost:5432/inventory_2?sslmode=disable
|
||||
TEST_DATABASE_URL=postgres://app_client:app_password@localhost:5432/inventory_2_test?sslmode=disable
|
||||
|
||||
# AUTH0_DOMAIN / AUTH0_CLIENT_ID / AUTH0_CLIENT_SECRET / AUTH0_CALLBACK_URL
|
||||
# are intentionally omitted: with DEV_AUTH_ENABLED=true below, real Auth0
|
||||
# login never runs, so config.Load() doesn't require them.
|
||||
|
||||
DEV_AUTH_ENABLED=true
|
||||
|
||||
PORT=8090
|
||||
@@ -22,6 +22,18 @@ jobs:
|
||||
pull-requests: write
|
||||
issues: write
|
||||
# Note: Gitea Actions may not require id-token: write for basic functionality
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -37,6 +49,35 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
- name: Setup node environment
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
# Version Spec of the version to use in SemVer notation.
|
||||
# It also admits such aliases as lts/*, latest, nightly and canary builds
|
||||
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
||||
node-version: 24
|
||||
|
||||
# Set this option if you want the action to check for the latest available version
|
||||
# that satisfies the version spec.
|
||||
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
|
||||
# Default: false
|
||||
#check-latest: false
|
||||
|
||||
package-manager-cache: false # Maybe add caching later
|
||||
|
||||
# Used to pull node distributions from https://github.com/actions/node-versions.
|
||||
# Since there's a default, this is typically not supplied by the user.
|
||||
# When running this action on github.com, the default value is sufficient.
|
||||
# When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
|
||||
#
|
||||
# We recommend using a service account with the least permissions necessary. Also
|
||||
# when generating a new PAT, select the least scopes necessary.
|
||||
#
|
||||
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
|
||||
#
|
||||
# Default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
- name: Run Claude Assistant
|
||||
uses: markwylde/claude-code-gitea-action@gitea
|
||||
with:
|
||||
@@ -49,6 +90,12 @@ jobs:
|
||||
penpot_self_hosted__high_level_overview
|
||||
penpot_self_hosted__penpot_api_info
|
||||
penpot_self_hosted__export_shape
|
||||
Bash(go:*)
|
||||
Bash(gofmt:*)
|
||||
Bash(./tailwind.sh)
|
||||
Bash(node -v)
|
||||
Bash(npm install)
|
||||
Bash(psql:*)
|
||||
gitea_api_url: "https://gitea.inventory-plus-plus.com/api/v1"
|
||||
gitea_token: ${{ secrets.GITEA_TOKEN }} # Use standard workflow token
|
||||
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
@@ -67,3 +114,8 @@ jobs:
|
||||
- Use standard git operations when possible
|
||||
env:
|
||||
GITEA_SERVER_URL: "https://gitea.inventory-plus-plus.com"
|
||||
NODE_VERSION: 24.x
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: 5432
|
||||
DATABASE_URL: postgres://app_client:app_password@localhost:5432/inventory_2?sslmode=disable
|
||||
TEST_DATABASE_URL: postgres://app_client:app_password@localhost:5432/inventory_2_test?sslmode=disable
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@ node_modules
|
||||
|
||||
.env
|
||||
.env.*
|
||||
.env.example
|
||||
!.env.gitea-claude-bot-dev
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
package ui_test
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"ruben/inventory2/domains/accounts"
|
||||
"ruben/inventory2/domains/authentication"
|
||||
etsy_platform "ruben/inventory2/domains/platforms/etsy"
|
||||
"ruben/inventory2/domains/raw_events"
|
||||
"ruben/inventory2/domains/reports"
|
||||
"ruben/inventory2/internal/testdb"
|
||||
"ruben/inventory2/server/auth"
|
||||
"ruben/inventory2/server/response"
|
||||
"ruben/inventory2/server/ui"
|
||||
)
|
||||
|
||||
// update regenerates the golden files under testdata/golden from the
|
||||
// current rendered output, instead of comparing against them. Review the
|
||||
// diff like any other golden file before committing it, e.g.:
|
||||
//
|
||||
// TEST_DATABASE_URL=... go test ./server/ui/... -run TestServeTemplate_Golden -update
|
||||
var update = flag.Bool("update", false, "update golden files in testdata/golden instead of comparing against them")
|
||||
|
||||
// TestServeTemplate_Golden is a raw-HTML snapshot/regression test: it
|
||||
// exercises server/ui's real routing + templating path end-to-end (real
|
||||
// templates, real Store types backed by a real Postgres connection, the
|
||||
// same response.HandleResponses/HandleErrors middleware production uses -
|
||||
// nothing about the render path is mocked) and diffs the rendered HTML
|
||||
// against a committed golden file, so an unintentional template/markup
|
||||
// change shows up as a reviewable diff instead of shipping silently.
|
||||
//
|
||||
// This is the "raw HTML snapshot" layer described in issue #33's UI-testing
|
||||
// proposal. A browser-screenshot layer (e.g. chromedp, for catching CSS/
|
||||
// layout regressions raw HTML can't) and Penpot-design-fidelity comparisons
|
||||
// are separate, not-yet-implemented layers of that same proposal.
|
||||
//
|
||||
// Only covers logged-out pages for now (no seeded oauth session/cookie);
|
||||
// extend the tests table below using testdb.SeedOAuthSession plus an
|
||||
// "access_token" cookie on the request to cover authenticated pages.
|
||||
//
|
||||
// Like other integration tests in this repo, it's skipped (not failed) if
|
||||
// TEST_DATABASE_URL is unset. If a golden file hasn't been generated yet,
|
||||
// the individual case is also skipped (not failed) rather than breaking
|
||||
// the suite - run with -update once, review the generated file, and commit
|
||||
// it to turn that case into a real regression check.
|
||||
func TestServeTemplate_Golden(t *testing.T) {
|
||||
pool := testdb.Pool(t)
|
||||
logger := testdb.Logger()
|
||||
|
||||
accts := accounts.NewStore(logger, pool)
|
||||
rawEvents := raw_events.NewStore(logger, pool)
|
||||
reps := reports.NewStore(logger, pool, accts)
|
||||
etsy := etsy_platform.NewPlatform(
|
||||
logger,
|
||||
func(acctID int64) string { return "" },
|
||||
"", "",
|
||||
pool,
|
||||
)
|
||||
|
||||
authr := authentication.NewDev(pool, logger)
|
||||
authM := auth.NewService(logger, authr, accts)
|
||||
|
||||
gin.SetMode(gin.TestMode)
|
||||
router := gin.New()
|
||||
router.Use(
|
||||
authM.Identify,
|
||||
response.HandleResponses,
|
||||
response.HandleErrors,
|
||||
)
|
||||
|
||||
ui.Routes(
|
||||
logger,
|
||||
router.Group("/ui"),
|
||||
"/ui",
|
||||
rawEvents,
|
||||
accts,
|
||||
reps,
|
||||
etsy,
|
||||
authM.Authenticate(),
|
||||
true,
|
||||
)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
path string
|
||||
wantStatus int
|
||||
}{
|
||||
{name: "home-logged-out", path: "/ui", wantStatus: http.StatusOK},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, tt.path, nil)
|
||||
rec := httptest.NewRecorder()
|
||||
router.ServeHTTP(rec, req)
|
||||
|
||||
require.Equal(t, tt.wantStatus, rec.Code, "unexpected status for %s", tt.path)
|
||||
|
||||
got := rec.Body.Bytes()
|
||||
golden := filepath.Join("testdata", "golden", tt.name+".html")
|
||||
|
||||
if *update {
|
||||
require.NoError(t, os.MkdirAll(filepath.Dir(golden), 0o755))
|
||||
require.NoError(t, os.WriteFile(golden, got, 0o644))
|
||||
return
|
||||
}
|
||||
|
||||
want, err := os.ReadFile(golden)
|
||||
if os.IsNotExist(err) {
|
||||
t.Skipf(
|
||||
"golden file %s does not exist yet; generate it once via `go test ./server/ui/... -run TestServeTemplate_Golden -update` (requires TEST_DATABASE_URL), then review and commit it",
|
||||
golden,
|
||||
)
|
||||
}
|
||||
require.NoError(t, err, "reading golden file %s", golden)
|
||||
|
||||
require.Equal(t, string(want), string(got), "rendered output for %s no longer matches %s; if this change is intentional, regenerate with -update", tt.path, golden)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user