Testing testing#523
Open
cubap wants to merge 5 commits into
Open
Conversation
Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/TPEN-services/sessions/7492f37f-92a2-4dfe-8273-a5988b4741fc Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/TPEN-services/sessions/7492f37f-92a2-4dfe-8273-a5988b4741fc Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Agent-Logs-Url: https://github.com/CenterForDigitalHumanities/TPEN-services/sessions/ca5b71a2-fa7f-471c-aeef-887c2885556b Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Replace the legacy Jest-based test setup and dotenv loader with Node's built-in test runner and native env-file flags. GitHub Actions workflows were reworked: job 'test' renamed to 'local_seams', new 'integration_seams' (creates .env from secrets, sets up Node 24, caches npm, runs npm run test:integration) and coordinated bump_version job added; CD jobs now run npm run test:integration for smoke checks. Documentation and guides (.github/copilot-instructions.md, CONFIG.md, CONTRIBUTING.md, README.md) updated to reflect Node native env-file usage, updated test script names (test:local, test:integration, test:coverage) and testing guidance. Removed import of env-loader from bin/tpen3_services.js. Large set of legacy Jest tests under __tests__ and various class test folders were removed and replaced by new test suites under test/local and test/integration; package.json/package-lock were updated accordingly.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes environment loading and test execution by moving from Jest/dotenv-based tooling to Node native env-file flags and node:test, while restructuring CI/CD and adding an OpenAPI artifact sync workflow.
Changes:
- Replaces Jest scripts/configuration and many legacy
__tests__suites with smallertest/localandtest/integrationnode:test suites. - Updates documentation and npm scripts for Node native env-file loading and c8 coverage.
- Adjusts CI/CD workflows and adds automation to sync a shared OpenAPI component artifact.
Reviewed changes
Copilot reviewed 46 out of 49 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
.github/copilot-instructions.md |
Updates repo guidance for env-file flags and new test commands. |
.github/workflows/cd_dev.yaml |
Replaces deployed dev smoke script with integration test command. |
.github/workflows/cd_prod.yaml |
Replaces deployed prod smoke script with integration test command. |
.github/workflows/ci_dev.yaml |
Splits PR validation into local and integration seam jobs. |
.github/workflows/ci_prod.yaml |
Splits PR validation into local and integration seam jobs. |
.github/workflows/sync_tpen_shared_openapi.yaml |
Adds workflow to sync shared OpenAPI artifact to another repo. |
CONFIG.md |
Documents new env-file loading approach. |
CONTRIBUTING.md |
Documents node:test/c8 workflow and test directory layout. |
README.md |
Updates setup/testing documentation. |
__tests__/full_end_to_end.test.js |
Removes legacy Jest end-to-end tests. |
__tests__/mount.test.js |
Removes legacy route/static-file existence suite. |
__tests__/smoke.test.js |
Removes deployed-service smoke test script. |
auth/__tests__/auth_unit_test.js |
Removes legacy auth middleware tests. |
bin/tpen3_services.js |
Removes direct env-loader import from server entrypoint. |
classes/Group/__tests__/Group.test.js |
Removes legacy Group class tests. |
classes/Layer/__tests__/exists.test.js |
Removes legacy Layer class existence tests. |
classes/Line/__tests__/Line.test.js |
Removes legacy Line class tests. |
classes/Page/__tests__/exists.test.js |
Removes legacy Page class existence tests. |
classes/Project/__tests__/Project.test.js |
Removes legacy Project class tests. |
classes/Project/__tests__/exists_unit.test.js |
Removes Project/ProjectFactory existence tests. |
classes/User/__tests__/exists.test.js |
Removes User class existence tests. |
classes/User/__tests__/unit.test.js |
Removes legacy private profile/User tests. |
config.env |
Updates comments for env-file loading order. |
database/__tests__/unit.test.js |
Removes legacy database driver tests. |
database/maria/__tests__/unit.test.js |
Removes MariaDB stub test. |
database/mongo/__tests__/unit.test.js |
Removes MongoDB controller tests. |
database/tiny/__tests__/unit.test.js |
Removes TinyPEN controller tests. |
env-loader.js |
Removes custom dotenv loader. |
jest.config.js |
Removes Jest configuration. |
layer/__tests__/layer_routes.test.js |
Removes legacy layer route tests. |
line/__tests__/lineRouter.test.js |
Removes legacy line router tests. |
openapi/components/tpen-services-shared-components.openapi.yaml |
Adds shared OpenAPI components artifact. |
package.json |
Replaces Jest/dotenv scripts and dependencies with node:test/c8 scripts. |
page/__tests__/end_to_end_unit.test.js |
Removes legacy page route tests. |
project/__tests__/customMetadataRouter.test.js |
Removes custom metadata router tests. |
project/__tests__/end_to_end_unit.test.js |
Removes legacy project route tests. |
project/__tests__/exists_unit.test.js |
Removes project route existence stub. |
test/integration/api.seams.integration.test.js |
Adds source/static-file integration seam checks. |
test/local/api.seams.static.test.js |
Adds static route/middleware seam checks. |
test/local/openapi.artifacts.test.js |
Adds OpenAPI artifact and sync workflow checks. |
test/local/utility.validation.test.js |
Adds minimal validation utility tests. |
userProfile/__tests__/end_to_end_unit.test.js |
Removes legacy user profile route tests. |
userProfile/__tests__/exists_unit.test.js |
Removes user profile route existence tests. |
userProfile/__tests__/functionality_unit.test.js |
Removes validateID helper tests. |
utilities/__tests__/isDefaultRole.test.js |
Removes legacy default-role tests. |
utilities/__tests__/isSuspicious.test.js |
Removes suspicious input detection tests. |
utilities/__tests__/shared.test.js |
Removes shared utility tests. |
utilities/__tests__/validatePayload.test.js |
Removes comprehensive project payload validation tests. |
Comments suppressed due to low confidence (7)
utilities/tests/isSuspicious.test.js:1
- Removing this test file without a node:test replacement drops all automated coverage for the suspicious-input detector, including script/command patterns and safe JSON regressions. That utility protects request bodies on write routes, so the new test suite should preserve these security checks rather than only static route seams.
utilities/tests/shared.test.js:1 - Removing this test file without a node:test replacement drops coverage for
hasAnnotationChanges, including the property-order and RERUM-metadata cases that prevent false positives/negatives when deciding whether annotation content changed.
userProfile/tests/functionality_unit.test.js:1 - The replacement test suite no longer checks
validateID, so invalid/valid user ID handling for/user/:idlost its only direct regression coverage. Please port these assertions to the new node:test structure instead of deleting them outright.
auth/tests/auth_unit_test.js:1 - Removing these active auth middleware tests leaves the new suite with only static checks that
auth0Middleware()appears in route source. It no longer verifies the runtime 401 behavior for missing or invalid bearer tokens, which is a security-sensitive contract and should be ported to node:test/supertest.
utilities/tests/validatePayload.test.js:1 - Removing this comprehensive validation suite leaves the new replacement with only three project-payload assertions and one role-scrubbing assertion. Edge cases previously covered here—invalid metadata shapes, malformed layers/pages, manifest URI validation, creator/group validation, and tool URL/custom validation—should be ported so regressions in project creation validation are still caught.
classes/User/tests/unit.test.js:1 - Removing this test file drops the active unauthenticated/invalid-token coverage for
/my/profileand/my/projects. The new static seam tests only assert middleware wiring, so they would not catch a regression that accidentally allows unauthenticated profile access.
tests/mount.test.js:1 - Deleting this route-mount suite removes coverage for most registered API routes (user, project management, custom roles/metadata, tools, copy, layer/page/line, proxy, feedback, and required static files). The replacement static seam test only checks a handful of app/page/line patterns, so many accidental route removals would no longer be caught by CI.
| run: | | ||
| cd /srv/node/tpen-services/ | ||
| SMOKE_TEST_URL=https://api.t-pen.org node __tests__/smoke.test.js | ||
| npm run test:integration |
| run: | | ||
| cd /srv/node/tpen-services/ | ||
| SMOKE_TEST_URL=https://dev.api.t-pen.org node __tests__/smoke.test.js | ||
| npm run test:integration |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request modernizes and clarifies the project's configuration and testing approach, updates documentation, improves CI/CD workflows, and removes legacy test files. The changes focus on adopting Node.js native features for environment management and testing, restructuring test directories, and enhancing automation for development and deployment.
Configuration and Documentation Updates:
dotenvand custom loaders to Node.js native env-file flags for environment configuration, updating all related documentation (README.md,CONFIG.md,.github/copilot-instructions.md) to reflect the new approach. [1] [2] [3] [4] [5] [6]node:testwithc8for coverage), removed references to Jest, and clarified testing commands and directory structure inCONTRIBUTING.mdandREADME.md. [1] [2] [3] [4] [5] [6]Testing and Directory Structure:
__tests__/full_end_to_end.test.jsfile and restructured test directories to usetest/localandtest/integration, aligning with the new testing strategy. [1] [2] [3]CI/CD Workflow Improvements:
local_seamsandintegration_seamsjobs for both development and production (ci_dev.yaml,ci_prod.yaml), and updated test commands to use the new scripts. [1] [2] [3] [4]npm run test:integrationinstead of direct script calls. [1] [2]Automation and Artifact Sync:
.github/workflows/sync_tpen_shared_openapi.yamlto automatically sync the shared OpenAPI artifact with an external repository, streamlining API documentation updates.Test Script and Category Updates:
These changes collectively modernize the development workflow, improve maintainability, and ensure consistency across documentation, testing, and deployment processes.