Skip to content

Commit 215f3dc

Browse files
authored
(feat) add Firestore SSR features to nightly tests (#24)
**General Updates:** Updates the CI to test against Firebase Next and not Firebase Canary. The Canary target installs the Canary of the previously released version, where as Next installs the upcoming version (which we should test against). Unfreezes the yarn lock file so that CI installs the latest Next version as it becomes available. **Additions to the test framework:** Expands upon Firestore tests to ensure that. `toJson` and `fromJson` works for: * `Bytes` * `DocumentSnapshot` * `GeoPoint` * `QuerySnapshot` * `Timestamp` * `VectorValue` Additionally tests that these object type can be serialized server-side then deserialized client-side and their values matched the originals. Finally, also tests that QuerySnapshot and DocumentSnapshot can be stood up as listeners form their serialized forms.
1 parent 5b7571c commit 215f3dc

File tree

8 files changed

+970
-544
lines changed

8 files changed

+970
-544
lines changed

app/tests/firestore/web_client/page.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@
1616
*/
1717
import type { Metadata } from 'next'
1818
import CSRTestRunner from '@/components/app_tests/firestore/csr_test_runner';
19+
import {
20+
buildSerializedFirestoreData,
21+
SerializedFirestoreData
22+
} from '@/lib/app_tests/firestore/test';
1923

2024
export const metadata: Metadata = {
2125
title: 'Firestore Web SDK CSR test'
2226
}
2327

24-
export default function Page() {
28+
export default async function Page() {
29+
const serializedFirestoreData : SerializedFirestoreData = await buildSerializedFirestoreData();
2530
return (
2631
<>
2732
<h1>Firestore CSR Test results:</h1>
28-
<CSRTestRunner />
33+
<CSRTestRunner serializedFirestoreData={serializedFirestoreData} />
2934
</>
3035
);
3136
}

app/tests/firestore/web_ssr/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const metadata: Metadata = {
2626
}
2727

2828
export default async function Page() {
29-
const testResults: TestResults = await testFirestore();
29+
const testResults: TestResults = await testFirestore(/* isServer= */ true);
3030
return (
3131
<>
3232
<h1>Firestore SSR Test results:</h1>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "playwright test"
1313
},
1414
"dependencies": {
15-
"firebase": "canary",
15+
"firebase": "next",
1616
"next": "latest",
1717
"react": "latest",
1818
"react-dom": "latest"

src/components/app_tests/firestore/csr_test_runner.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,27 @@
1717
'use client'
1818

1919
import { useState, useEffect } from 'react'
20-
import { testFirestore, initializeTestResults } from '@/lib/app_tests/firestore/test';
20+
import {
21+
initializeTestResults,
22+
testSerializedFirestoreData,
23+
testFirestore } from '@/lib/app_tests/firestore/test';
2124
import ResultsDisplay from './results_display';
2225

23-
export default function CsrTestRunner() {
26+
export default function CsrTestRunner(props) {
2427
const [testStatus, setTestStatus] = useState<string>("running...");
2528
const [testResults, setTestResults] = useState(initializeTestResults());
2629
useEffect(() => {
2730
const asyncTest = async () => {
28-
setTestResults(await testFirestore());
31+
let testResults = await testFirestore(/* isServer= */ false);
32+
testResults = await testSerializedFirestoreData(testResults, props.serializedFirestoreData);
33+
setTestResults(testResults);
2934
setTestStatus("Complete!");
3035
}
3136
asyncTest().catch((e) => {
3237
console.error("Error encountered during testing: ", e);
3338
setTestStatus("Errored!");
3439
});
35-
}, []);
40+
}, [props.serializedFirestoreData]);
3641

3742
return (
3843
<ResultsDisplay statusString={testStatus} testResults={testResults} />

src/components/app_tests/firestore/results_display.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,28 @@ export default function ResultsDisplay({ statusString, testResults }) {
2727
<h4 title="updateDocResult">updateDocResult: {testResults.updateDocResult}</h4>
2828
<h4 title="onSnapshotUpdateDR">onSnapshotUpdateDocResult: {testResults.onSnapshotUpdateDocResult}</h4>
2929
<h4 title="getDocResult">getDocResult: {testResults.getDocResult}</h4>
30+
<h4 title="querySnapshotGetDocsResult">querySnapshotGetDocsResult: {testResults.querySnapshotGetDocsResult}</h4>
31+
<h4 title="documentSnapshotBundleResult">documentSnapshotBundleResult: {testResults.documentSnapshotBundleResult}</h4>
32+
<h4 title="reconstitutedDocDataResult">reconstitutedDocDataResult: {testResults.reconstitutedDocDataResult}</h4>
33+
<h4 title="documentSnapshotOnSnapshotResumeResult">documentSnapshotOnSnapshotResumeResult: {testResults.documentSnapshotOnSnapshotResumeResult}</h4>
34+
<h4 title="querySnapshotOnSnapshotResumeResult">querySnapshotOnSnapshotResumeResult: {testResults.querySnapshotOnSnapshotResumeResult}</h4>
35+
<h4 title="querySnapshotBundleResult">querySnapshotBundleResult: {testResults.querySnapshotBundleResult}</h4>
36+
<h4 title="reconstitutedQueryDataResult">reconstitutedQueryDataResult: {testResults.reconstitutedQueryDataResult}</h4>
3037
<h4 title="deleteDocResult">deleteDocResult: {testResults.deleteDocResult}</h4>
3138
<h4 title="onSnapshotDeleteDR">onSnapshotDeleteDocResult: {testResults.onSnapshotDeleteDocResult}</h4>
3239
<h4 title="getDeletedDocResult">getDeletedDocResult: {testResults.getDeletedDocResult}</h4>
3340
<h4 title="deleteAppResult">deleteAppResult: {testResults.deleteAppResult}</h4>
41+
42+
<h3> CSR-side deserialization tests </h3>
43+
<h4 title="csrDocumentSnapshotResult">csrDocumentSnapshotResult: {testResults.csrDocumentSnapshotResult}</h4>
44+
<h4 title="csrDocumentSnapshotOnResumeResult">csrDocumentSnapshotOnResumeResult: {testResults.csrDocumentSnapshotOnResumeResult}</h4>
45+
<h4 title="csrQuerySnapshotResult">csrQuerySnapshotResult: {testResults.csrQuerySnapshotResult}</h4>
46+
<h4 title="csrQuerySnapshotOnResumeResult">csrQuerySnapshotOnResumeResult: {testResults.csrQuerySnapshotOnResumeResult}</h4>
47+
<h4 title="csrDeserializedBytesResult">csrDeserializedBytesResult: {testResults.csrDeserializedBytesResult}</h4>
48+
<h4 title="csrDeserializedGeoPointResult">csrDeserializedGeoPointResult: {testResults.csrDeserializedGeoPointResult}</h4>
49+
<h4 title="csrDeserializedTimestampResult">csrDeserializedTimestampResult: {testResults.csrDeserializedTimestampResult}</h4>
50+
<h4 title="csrDeserializedVectorValueResult">csrDeserializedVectorValueResult: {testResults.csrDeserializedVectorValueResult}</h4>
51+
3452
<p />
3553
<Link href="/">Back to test index</Link>
3654
</>

0 commit comments

Comments
 (0)