-
-
Notifications
You must be signed in to change notification settings - Fork 6
Fix streak tests ci #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a9290d4
test: skip first day activity tests in CI environment
masonfox 9e9181c
ci: add comprehensive test suite workflow for PRs
masonfox 0bdcde1
fix: resolve TypeScript type errors in test files
masonfox dc2d5f4
fix: restore original test for latest progress with totalReads
masonfox 967dbbb
ci: make type check non-blocking due to pre-existing errors
masonfox d34d837
ci: update test workflow
masonfox 0e8be30
ci: rename workflow to clarify purpose as PR Checks
masonfox bc99691
ci: ensure jobs only run for non-draft pull requests
masonfox 92d6bf8
ci: ensure jobs do not run for draft pull requests
masonfox 4cca499
test: standardize streak test lifecycle and revert CI/local DB diverg…
masonfox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: PR Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test & Build App | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Bun | ||
| uses: oven-sh/setup-bun@v2 | ||
| with: | ||
| bun-version: "1.3.0" | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: bun test | ||
|
|
||
| - name: Build application | ||
| run: bun run build | ||
|
|
||
| docker-build: | ||
| name: Validate Docker Build (PRs only) | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
| if: github.event_name == 'pull_request' | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build Docker image (no push) | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: false | ||
| tags: test-image:pr-${{ github.event.pull_request.number }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| platforms: linux/amd64 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,7 +119,7 @@ describe("Auth API Routes Logic", () => { | |
| delete process.env.AUTH_PASSWORD; | ||
|
|
||
| // Simulate middleware logic | ||
| const password = process.env.AUTH_PASSWORD || ""; | ||
| const password = (process.env.AUTH_PASSWORD || "") as string; | ||
|
masonfox marked this conversation as resolved.
|
||
| const AUTH_ENABLED = !!password && password.trim() !== ""; | ||
| const pathname = "/login"; | ||
|
|
||
|
|
@@ -141,7 +141,7 @@ describe("Auth API Routes Logic", () => { | |
|
|
||
| // Test with auth disabled | ||
| delete process.env.AUTH_PASSWORD; | ||
| password = process.env.AUTH_PASSWORD || ""; | ||
| password = (process.env.AUTH_PASSWORD || "") as string; | ||
|
masonfox marked this conversation as resolved.
|
||
| AUTH_ENABLED = !!password && password.trim() !== ""; | ||
| pathname = "/api/stats/overview"; | ||
|
|
||
|
|
@@ -152,7 +152,40 @@ describe("Auth API Routes Logic", () => { | |
| test("should allow regular routes when auth is disabled", () => { | ||
| delete process.env.AUTH_PASSWORD; | ||
|
|
||
| const password = process.env.AUTH_PASSWORD || ""; | ||
| const password = (process.env.AUTH_PASSWORD || "") as string; | ||
|
masonfox marked this conversation as resolved.
|
||
| const AUTH_ENABLED = !!password && password.trim() !== ""; | ||
| const pathname = "/login"; | ||
|
|
||
| // When auth is disabled, /login should redirect to home | ||
| const shouldRedirectToHome = !AUTH_ENABLED && pathname === "/login"; | ||
| expect(shouldRedirectToHome).toBe(true); | ||
| }); | ||
|
masonfox marked this conversation as resolved.
|
||
|
|
||
| test("should allow all API routes regardless of auth status", () => { | ||
| // Test with auth enabled | ||
| process.env.AUTH_PASSWORD = "testpass123"; | ||
| let password = process.env.AUTH_PASSWORD || ""; | ||
| let AUTH_ENABLED = !!password && password.trim() !== ""; | ||
| let pathname: string = "/api/books"; | ||
|
|
||
| // API routes should always be allowed | ||
| let shouldAllow = pathname.startsWith("/api/") || (!AUTH_ENABLED && pathname === "/login"); | ||
| expect(shouldAllow).toBe(true); | ||
|
|
||
| // Test with auth disabled | ||
| delete process.env.AUTH_PASSWORD; | ||
| password = (process.env.AUTH_PASSWORD || "") as string; | ||
|
masonfox marked this conversation as resolved.
|
||
| AUTH_ENABLED = !!password && password.trim() !== ""; | ||
| pathname = "/api/stats/overview"; | ||
|
|
||
| shouldAllow = pathname.startsWith("/api/") || (!AUTH_ENABLED && pathname === "/login"); | ||
| expect(shouldAllow).toBe(true); | ||
| }); | ||
|
|
||
|
masonfox marked this conversation as resolved.
|
||
| test("should allow regular routes when auth is disabled", () => { | ||
| delete process.env.AUTH_PASSWORD; | ||
|
|
||
| const password = (process.env.AUTH_PASSWORD || "") as string; | ||
|
||
| const AUTH_ENABLED = !!password && password.trim() !== ""; | ||
| const pathname: string = "/library"; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.