Skip to content

chore: drop the server tests that only test the platform - #17037

Open
Nic-Polumeyv wants to merge 2 commits into
server-respond-testsfrom
csrf-dedup
Open

chore: drop the server tests that only test the platform#17037
Nic-Polumeyv wants to merge 2 commits into
server-respond-testsfrom
csrf-dedup

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Two kinds of test in the moved server suite exercise nothing in kit under a direct Server.respond call.

Six of the eight CSRF cases repeat csrf.spec.js one for one: same origin, non-allowed origins, GET, non-form content types, the method loop, missing origin. Only the 403 body text and the csrf.trustedOrigins wiring are checked nowhere else, so those two stay.

The slow-read test hands the endpoint an in-memory buffer, so nothing is read slowly and the digest round-trip only proves Request.body. The backpressure it used to reach over HTTP has its own cases in node/index.spec.js.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Sep 4, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 7fee9c8:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/7fee9c85ad3df9a9cc5de04db018930479c77845

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17037

@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7fee9c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CSRF test suite now contains one successful POST form request from https://trusted.example.com. Tests for other origins, methods, content types, and missing origins were removed. The slow request-body hashing test was also removed.

Merge Risk: 🔵 Low · up to 7fee9

This test-only change reduces CSRF coverage to a trusted-origin case, leaving configured trusted-origin propagation less protected against regression. The change is mergeable with owner awareness of this bounded coverage gap.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Backward Compatibility Impact Disclosure ✅ Passed The pull request changes only the private test-basics test application. It removes a test route and test cases; it does not change @sveltejs/kit exports, package metadata, runtime source, request/…
Title check ✅ Passed The title uses the required chore: prefix and accurately describes the removal of platform-only server tests.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
packages/kit/test/apps/basics/unit-test/server.spec.js-201-201 (1)

201-201: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Retain multi-entry csrf.trustedOrigins coverage.

This test validates only one trusted-origin entry. packages/kit/src/runtime/server/csrf.spec.js also tests only a singleton trusted_origins array. If server configuration drops entries after the first, all remaining tests pass. Keep the additional trusted-origin case here, or add a focused test that passes at least two configured origins.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: QUIET

Plan: Advanced

Run ID: 06cdfebf-a730-47cc-96bc-22cbf983b8c3

📥 Commits

Reviewing files that changed from the base of the PR and between 7b36829 and ff6cb45.

📒 Files selected for processing (1)
  • packages/kit/test/apps/basics/unit-test/server.spec.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • sveltejs/vite-plugin-svelte (manual)
  • vitejs/vite (manual)
  • sveltejs/svelte (manual)

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@Nic-Polumeyv Nic-Polumeyv changed the title chore: drop the CSRF server tests that csrf.spec.js already covers chore: drop the server tests that only test the platform Sep 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/kit/test/apps/basics/unit-test/server.spec.js (1)

176-190: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Align the retained CSRF test with the case it sends.

This test sends no Origin header, so it covers a missing origin, not an incorrect origin. Rename the test to reflect that case. The response text varies by method, not by content_type, so use one representative form content type per method.

Proposed narrowing
-	test('Blocks requests with incorrect origin', async () => {
-		const content_types = [
-			'application/x-www-form-urlencoded',
-			'multipart/form-data',
-			'text/plain',
-			'text/plaiN'
-		];
+	test('Reports forbidden response text for mutating form methods', async () => {
 		const methods = ['POST', 'PUT', 'PATCH', 'DELETE'];
 		for (const method of methods) {
-			for (const content_type of content_types) {
-				const res = await get('/csrf', { method, headers: { 'content-type': content_type } });
-				const message = `request method: ${method}, content-type: ${content_type}`;
+			const res = await get('/csrf', {
+				method,
+				headers: { 'content-type': 'application/x-www-form-urlencoded' }
+			});
+			const message = `request method: ${method}`;
 				expect(res.status, message).toBe(403);
 				expect(await res.text(), message).toBe(
 					`Cross-site ${method} form submissions are forbidden`
 				);
-			}
 		}
 	});

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: QUIET

Plan: Advanced

Run ID: 5f3b44b1-0548-4aa0-a4be-4ace4fa91141

📥 Commits

Reviewing files that changed from the base of the PR and between ff6cb45 and 75eb48d.

📒 Files selected for processing (2)
  • packages/kit/test/apps/basics/src/routes/endpoint-input/sha256/+server.js
  • packages/kit/test/apps/basics/unit-test/server.spec.js
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • sveltejs/vite-plugin-svelte (manual)
  • vitejs/vite (manual)
  • sveltejs/svelte (manual)
💤 Files with no reviewable changes (1)
  • packages/kit/test/apps/basics/src/routes/endpoint-input/sha256/+server.js

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant