Skip to content

Commit 4a13edd

Browse files
ci: apply automated fixes
1 parent b6e4e44 commit 4a13edd

File tree

3 files changed

+105
-85
lines changed

3 files changed

+105
-85
lines changed

packages/trailbase-db-collection/e2e/global-setup.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function isDockerAvailable(): boolean {
2020
try {
2121
execSync('docker --version', { stdio: 'pipe' })
2222
return true
23-
} catch { }
23+
} catch {}
2424

2525
return false
2626
}
@@ -29,7 +29,7 @@ async function isTrailBaseRunning(url: string): Promise<boolean> {
2929
try {
3030
const res = await fetch(`${url}/api/healthcheck`)
3131
return res.ok
32-
} catch { }
32+
} catch {}
3333

3434
return false
3535
}
@@ -107,7 +107,7 @@ async function waitForTrailBase(url: string): Promise<void> {
107107
clearTimeout(timeout)
108108
return resolve()
109109
}
110-
} catch { }
110+
} catch {}
111111

112112
setTimeout(() => void check(), 500)
113113
}
@@ -119,7 +119,7 @@ async function waitForTrailBase(url: string): Promise<void> {
119119
/**
120120
* Global setup for TrailBase e2e test suite
121121
*/
122-
export default async function({ provide }: TestProject) {
122+
export default async function ({ provide }: TestProject) {
123123
let serverProcess: ChildProcess | null = null
124124

125125
// Check if TrailBase is already running
@@ -129,9 +129,9 @@ export default async function({ provide }: TestProject) {
129129
if (!isDockerAvailable()) {
130130
throw new Error(
131131
`TrailBase is not running at ${TRAILBASE_URL} and no startup method is available.\n` +
132-
`Please either:\n` +
133-
` 1. Start TrailBase manually at ${TRAILBASE_URL}\n` +
134-
` 2. Install Docker and run the tests again\n`,
132+
`Please either:\n` +
133+
` 1. Start TrailBase manually at ${TRAILBASE_URL}\n` +
134+
` 2. Install Docker and run the tests again\n`,
135135
)
136136
}
137137

packages/trailbase-db-collection/e2e/trailbase.e2e.test.ts

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ import {
1919
createPaginationTestSuite,
2020
createPredicatesTestSuite,
2121
createProgressiveTestSuite,
22-
generateSeedData
23-
22+
generateSeedData,
2423
} from '../../db-collection-e2e/src/index'
25-
import type { Client } from 'trailbase';
26-
import type { SeedDataResult } from '../../db-collection-e2e/src/index';
24+
import type { Client } from 'trailbase'
25+
import type { SeedDataResult } from '../../db-collection-e2e/src/index'
2726
import type { TrailBaseSyncMode } from '../src/trailbase'
2827
import type {
2928
Comment,
@@ -41,16 +40,21 @@ declare module 'vitest' {
4140

4241
// / Decode a "url-safe" base64 string to bytes.
4342
function urlSafeBase64Decode(base64: string): Uint8Array {
44-
return Uint8Array.from(atob(base64.replace(/_/g, "/").replace(/-/g, "+")), (c) => c.charCodeAt(0));
43+
return Uint8Array.from(
44+
atob(base64.replace(/_/g, '/').replace(/-/g, '+')),
45+
(c) => c.charCodeAt(0),
46+
)
4547
}
4648

4749
// / Encode an arbitrary string input as a "url-safe" base64 string.
4850
function urlSafeBase64Encode(bytes: Uint8Array): string {
49-
return btoa(String.fromCharCode(...bytes)).replace(/\//g, "_").replace(/\+/g, "-");
51+
return btoa(String.fromCharCode(...bytes))
52+
.replace(/\//g, '_')
53+
.replace(/\+/g, '-')
5054
}
5155

5256
function parseTrailBaseId(id: string): string {
53-
return uuidStringify(urlSafeBase64Decode(id));
57+
return uuidStringify(urlSafeBase64Decode(id))
5458
}
5559

5660
function toTrailBaseId(id: string): string {
@@ -141,15 +145,15 @@ function createCollectionsForSyncMode(
141145
id: parseTrailBaseId,
142146
isActive: (isActive) => Boolean(isActive),
143147
createdAt: (createdAt) => new Date(createdAt),
144-
metadata: (m) => m ? JSON.parse(m) : null,
145-
deletedAt: (d) => d ? new Date(d) : null,
148+
metadata: (m) => (m ? JSON.parse(m) : null),
149+
deletedAt: (d) => (d ? new Date(d) : null),
146150
},
147151
serialize: {
148152
id: toTrailBaseId,
149-
isActive: (a) => a ? 1 : 0,
153+
isActive: (a) => (a ? 1 : 0),
150154
createdAt: (c) => c.toISOString(),
151-
metadata: (m) => m ? JSON.stringify(m) : null,
152-
deletedAt: (d) => d ? d.toISOString() : null,
155+
metadata: (m) => (m ? JSON.stringify(m) : null),
156+
deletedAt: (d) => (d ? d.toISOString() : null),
153157
},
154158
}),
155159
)
@@ -164,14 +168,14 @@ function createCollectionsForSyncMode(
164168
parse: {
165169
id: parseTrailBaseId,
166170
largeViewCount: (l) => BigInt(l),
167-
publishedAt: (v) => v ? new Date(v) : null,
168-
deletedAt: (d) => d ? new Date(d) : null,
171+
publishedAt: (v) => (v ? new Date(v) : null),
172+
deletedAt: (d) => (d ? new Date(d) : null),
169173
},
170174
serialize: {
171175
id: toTrailBaseId,
172176
largeViewCount: (v) => v.toString(),
173-
publishedAt: (v) => v ? v.toISOString() : null,
174-
deletedAt: (d) => d ? d.toISOString() : null,
177+
publishedAt: (v) => (v ? v.toISOString() : null),
178+
deletedAt: (d) => (d ? d.toISOString() : null),
175179
},
176180
}),
177181
)
@@ -186,12 +190,12 @@ function createCollectionsForSyncMode(
186190
parse: {
187191
id: parseTrailBaseId,
188192
createdAt: (v) => new Date(v),
189-
deletedAt: (d) => d ? new Date(d) : null,
193+
deletedAt: (d) => (d ? new Date(d) : null),
190194
},
191195
serialize: {
192196
id: toTrailBaseId,
193197
createdAt: (v) => v.toISOString(),
194-
deletedAt: (d) => d ? d.toISOString() : null,
198+
deletedAt: (d) => (d ? d.toISOString() : null),
195199
},
196200
}),
197201
)
@@ -239,10 +243,7 @@ async function initialCleanup(client: Client) {
239243
console.log(`Cleanup complete`)
240244
}
241245

242-
async function setupInitialData(
243-
client: Client,
244-
seedData: SeedDataResult,
245-
) {
246+
async function setupInitialData(client: Client, seedData: SeedDataResult) {
246247
const usersRecordApi = client.records<UserRecord>(`users_e2e`)
247248
const postsRecordApi = client.records<PostRecord>(`posts_e2e`)
248249
const commentsRecordApi = client.records<CommentRecord>(`comments_e2e`)
@@ -300,10 +301,10 @@ describe(`TrailBase Collection E2E Tests`, async () => {
300301
const client = initClient(baseUrl)
301302

302303
// Wipe all pre-existing data, e.g. when using a persistent TB instance.
303-
await initialCleanup(client);
304+
await initialCleanup(client)
304305

305306
const seedData = generateSeedData()
306-
await setupInitialData(client, seedData);
307+
await setupInitialData(client, seedData)
307308

308309
async function getConfig(): Promise<E2ETestConfig> {
309310
// Create collections with different sync modes
@@ -337,11 +338,13 @@ describe(`TrailBase Collection E2E Tests`, async () => {
337338
eagerCollections.posts.preload(),
338339
eagerCollections.comments.preload(),
339340
])
340-
expect(eagerCollections.posts.size).toEqual(seedData.posts.length);
341-
expect(eagerCollections.comments.size).toEqual(seedData.comments.length);
341+
expect(eagerCollections.posts.size).toEqual(seedData.posts.length)
342+
expect(eagerCollections.comments.size).toEqual(seedData.comments.length)
342343

343344
// NOTE: One of the tests deletes a user :/
344-
expect(eagerCollections.users.size).toBeGreaterThanOrEqual(seedData.users.length - 1);
345+
expect(eagerCollections.users.size).toBeGreaterThanOrEqual(
346+
seedData.users.length - 1,
347+
)
345348

346349
const usersRecordApi = client.records<UserRecord>(`users_e2e`)
347350
const postsRecordApi = client.records<PostRecord>(`posts_e2e`)
@@ -386,7 +389,7 @@ describe(`TrailBase Collection E2E Tests`, async () => {
386389
await postsRecordApi.create(serializePost(post))
387390
},
388391
},
389-
setup: async () => { },
392+
setup: async () => {},
390393
teardown: async () => {
391394
await Promise.all([
392395
eagerCollections.users.cleanup(),

0 commit comments

Comments
 (0)