Skip to content

Commit e1c3fa3

Browse files
committed
test: Harden REST helpers per CodeRabbit review
Use a dedicated maintenance-key value in buildHeaders, assert the Parse-error shape in expectParseError, drop the redundant local reconfigureServer decl (it lives in globals.d.ts), and fix the REST-client description in the plan.
1 parent e59ed18 commit e1c3fa3

5 files changed

Lines changed: 8 additions & 4 deletions

File tree

spec/helpers/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const TestConfig = {
55
serverURL: 'http://localhost:8378/1',
66
appId: 'test',
77
masterKey: 'test',
8+
maintenanceKey: 'testing',
89
restAPIKey: 'rest',
910
clientKey: 'client',
1011
javascriptKey: 'test',

spec/helpers/headers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function buildHeaders(auth: AuthOptions = {}): ParseHeaders {
2121
const headers: ParseHeaders = { 'X-Parse-Application-Id': TestConfig.appId };
2222
if (auth.json !== false) headers['Content-Type'] = 'application/json';
2323
if (auth.masterKey) headers['X-Parse-Master-Key'] = TestConfig.masterKey;
24-
if (auth.maintenanceKey) headers['X-Parse-Maintenance-Key'] = TestConfig.masterKey;
24+
if (auth.maintenanceKey) headers['X-Parse-Maintenance-Key'] = TestConfig.maintenanceKey;
2525
if (auth.restAPIKey) headers['X-Parse-REST-API-Key'] = TestConfig.restAPIKey;
2626
if (auth.clientKey) headers['X-Parse-Client-Key'] = TestConfig.clientKey;
2727
if (auth.javascriptKey) headers['X-Parse-JavaScript-Key'] = TestConfig.javascriptKey;

spec/helpers/request.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ export async function expectParseError(
9595
await promise;
9696
} catch (e: any) {
9797
const body: ParseErrorBody = e && e.data ? e.data : e;
98+
if (typeof body?.code !== 'number' || typeof body?.error !== 'string') {
99+
throw new Error(
100+
`Expected a Parse error ({ code, error }), but got: ${JSON.stringify(body)}`
101+
);
102+
}
98103
if (code !== undefined) {
99104
expect(body.code).toBe(code);
100105
}

spec/server/analytics.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { track, appOpened } from '../helpers/analytics.ts';
22

3-
declare const reconfigureServer: (config?: Record<string, unknown>) => Promise<unknown>;
4-
53
describe('AnalyticsController', () => {
64
const analyticsAdapter = {
75
appOpened: function () {},

spec/spec_migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Measured at the time of writing — re-measure before starting to confirm.
6565
| Decision | Choice |
6666
|---|---|
6767
| Roll-out | **Incremental, in-place** — convert files where they live, reorganise directories as part of each migration. |
68-
| Server access | **New typed REST test client** wrapping `lib/request.js`. |
68+
| Server access | **New typed REST test client** — a small, typed layer over the native `fetch` API (Node 18+). |
6969
| SDK | **Eliminate the Parse JS SDK** from all HTTP-level tests. Retain only a thin WS client for LiveQuery (not the SDK's LiveQuery client). |
7070
| Quality | **Full cleanup bundled into each file's migration** — async/await, no `setTimeout` timing, cleanup hooks, monolith splitting, eslint tightening, `xit`/`fit` triage. |
7171
| Language | **TypeScript** for helpers/clients (and incrementally for specs). |

0 commit comments

Comments
 (0)