Skip to content

Commit 17be510

Browse files
committed
Data connect next js tests
1 parent 147c93c commit 17be510

File tree

15 files changed

+1079
-1
lines changed

15 files changed

+1079
-1
lines changed

js-sdk-framework-tests/nextjs/.eslintrc.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"extends": [
33
"next/core-web-vitals",
44
"next/typescript"
5-
]
5+
],
6+
"rules": {
7+
"@typescript-eslint/no-require-imports": "off"
8+
}
69
}

js-sdk-framework-tests/nextjs/app/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export default async function Page() {
5555
<li><Link href="/tests/auth/web_ssr">Auth Web SDK server-side tests</Link></li>
5656
</ul>
5757
<p />
58+
<li>Data Connect</li>
59+
<ul>
60+
<li><Link href="/tests/data_connect/web_client">Data Connect Web SDK client-side tests</Link></li>
61+
<li><Link href="/tests/data_connect/web_ssr">Data Connect Web SDK server-side tests</Link></li>
62+
</ul>
63+
<p />
5864
<li>Database</li>
5965
<ul>
6066
<li><Link href="/tests/database/web_client">Database Web SDK client-side tests</Link></li>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import type { Metadata } from 'next'
18+
import CSRTestRunner from '@/components/app_tests/data_connect/csr_test_runner';
19+
20+
export const metadata: Metadata = {
21+
title: 'Data Connect Web SDK CSR test'
22+
}
23+
24+
export default function Page() {
25+
return (
26+
<>
27+
<h1>Data Connect CSR Test results:</h1>
28+
<CSRTestRunner />
29+
</>
30+
);
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import type { Metadata } from 'next'
18+
import { testDataConnect, TestResults } from '@/lib/app_tests/data_connect/test';
19+
import ResultsDisplay from '@/components/app_tests/data_connect/results_display';
20+
21+
// Suppress static site generation.
22+
export const dynamic = "force-dynamic";
23+
24+
export const metadata: Metadata = {
25+
title: 'Data Connect Web SDK SSR test'
26+
}
27+
28+
export default async function Page() {
29+
const testResults: TestResults = await testDataConnect(/*isServer=*/true);
30+
return (
31+
<>
32+
<h1>Data Connect SSR Test results:</h1>
33+
<ResultsDisplay statusString='Tests Complete!' testResults={testResults} />
34+
</>
35+
);
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
'use client'
18+
19+
import { useState, useEffect } from 'react'
20+
import { testDataConnect, initializeTestResults } from '@/lib/app_tests/data_connect/test';
21+
import ResultsDisplay from './results_display';
22+
23+
export default function CsrTestRunner() {
24+
const [testStatus, setTestStatus] = useState<string>("running...");
25+
const [testResults, setTestResults] = useState(initializeTestResults());
26+
useEffect(() => {
27+
const asyncTest = async () => {
28+
setTestResults(await testDataConnect());
29+
setTestStatus("Complete!");
30+
}
31+
asyncTest().catch((e) => {
32+
console.error("Error encountered during testing: ", e);
33+
setTestStatus("Errored!");
34+
});
35+
}, []);
36+
37+
return (
38+
<ResultsDisplay statusString={testStatus} testResults={testResults} />
39+
);
40+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
import Link from 'next/link';
18+
export default function ResultsDisplay({ statusString, testResults }) {
19+
return (
20+
<>
21+
<h2 title="testStatus">{statusString}</h2>
22+
<h4 title="initializeAppResult">initializeAppResult: {testResults.initializeAppResult}</h4>
23+
<h4 title="initializeAuthResult">initializeAuthResult: {testResults.initializeAppResult}</h4>
24+
<h4 title="signInAnonymouslyresult">signInAnonymouslyresult: {testResults.initializeAppResult}</h4>
25+
<h4 title="addPostResult">addPostResult: {testResults.initializeAppResult}</h4>
26+
<h4 title="listPostsResult">listPostsResult: {testResults.initializeAppResult}</h4>
27+
<h4 title="foundPostResult">foundPostResult: {testResults.initializeAppResult}</h4>
28+
<h4 title="removePostResult">removePostResult: {testResults.initializeAppResult}</h4>
29+
<h4 title="requeryPostsResult">requeryPostsResult: {testResults.initializeAppResult}</h4>
30+
<h4 title="confirmedPostDeletedResult">confirmedPostDeletedResult: {testResults.initializeAppResult}</h4>
31+
<h4 title="deleteUserResult">deleteUserResult: {testResults.initializeAppResult}</h4>
32+
<h4 title="deleteAppResult">deleteAppResult: {testResults.initializeAppResult}</h4>
33+
<p />
34+
<Link href="/">Back to test index</Link>
35+
</>
36+
);
37+
}

0 commit comments

Comments
 (0)