Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions expo-example/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Couchbase Lite React Native - Test Environment Configuration
# Copy this file to .env.local and fill in your actual values
# Note: .env.local is git-ignored for security

# Sync Gateway Configuration
EXPO_PUBLIC_SYNC_GATEWAY_URL=wss://your-gateway-url:4984/your-endpoint
EXPO_PUBLIC_SYNC_USERNAME=your_username
EXPO_PUBLIC_SYNC_PASSWORD=your_password

# Note: These credentials are used for testing purposes only
# Never commit actual credentials to version control
2 changes: 1 addition & 1 deletion expo-example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.25'
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is using CBL 3.3, we were using kotlin 1.9.24


ndkVersion = "26.1.10909125"
}
Expand Down
4 changes: 2 additions & 2 deletions expo-example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile().toString())
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().toString())
}
plugins { id("com.facebook.react.settings") }

Expand Down Expand Up @@ -31,7 +31,7 @@ dependencyResolutionManagement {
}
}

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

include ':app'
Expand Down
26 changes: 16 additions & 10 deletions expo-example/app/tests/custom-bug-fix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import {
Collection,
MutableDocument,
Document,
ConcurrencyControl
} from 'cbl-reactnative';import getFileDefaultPath from '@/service/file/getFileDefaultPath';
ConcurrencyControl,
CollectionConfiguration
} from 'cbl-reactnative';
import getFileDefaultPath from '@/service/file/getFileDefaultPath';

export default function CustomBugFixScreen() {
function reset() {}
Expand Down Expand Up @@ -63,22 +65,26 @@ export default function CustomBugFixScreen() {

const connectToSyncGateway = async () => {
setListOfLogs(prev => [...prev, 'Connecting to Sync Gateway']); // ✅ Use prev
const defaultCollection = await database?.defaultCollection();
if(database === null || database === undefined) {

Choose a reason for hiding this comment

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

medium

This check for null or undefined can be simplified. Using !database is more concise and idiomatic in TypeScript for this purpose.

Suggested change
if(database === null || database === undefined) {
if(!database) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like a good suggestion

throw Error("Database is undefined")
}
const defaultCollection = await database.defaultCollection();

const syncGatewayUrl = "wss://nasm0fvdr-jnehnb.apps.cloud.couchbase.com:4984/testendpoint"
const syncGatewayUrl = process.env.EXPO_PUBLIC_SYNC_GATEWAY_URL || "wss://localhost:4984/testendpoint"
const endpoint = new URLEndpoint(syncGatewayUrl);
const username = "jayantdhingra"
const password = "f9yu5QT4B5jpZep@"
const username = process.env.EXPO_PUBLIC_SYNC_USERNAME || "test_user"
const password = process.env.EXPO_PUBLIC_SYNC_PASSWORD || "test_pass"

const replicatorConfig = new ReplicatorConfiguration(endpoint)

const collectionConfig = new CollectionConfiguration(defaultCollection)
const listOfCollectionConfig = [collectionConfig]

const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint)
replicatorConfig.setAuthenticator(new BasicAuthenticator(username, password))
// replicatorConfig.setContinuous(true)
replicatorConfig.setAcceptOnlySelfSignedCerts(false);


if (defaultCollection) {
replicatorConfig.addCollection(defaultCollection)
}

const replicator = await Replicator.create(replicatorConfig)

Expand Down
25 changes: 25 additions & 0 deletions expo-example/app/tests/replication-new.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import TestRunnerContainer from '@/components/TestRunnerContainer/TestRunnerContainer';

import { ReplicatorNewApiTests } from '../../cblite-js-tests/cblite-tests/e2e/replicator-new-api-test';

export default function TestsReplicatorScreen() {
function reset() {}

async function update(): Promise<string[]> {
try {
return [''];
} catch (e) {
const errorMessage = e instanceof Error ? e.message : String(e);
return [errorMessage];
}
}

return (
<TestRunnerContainer
navigationTitle="Replicator Tests"
subTitle="Run Sync Gate before tests - visit tests README.md"
testCases={[ReplicatorNewApiTests]}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
URLEndpoint,
BasicAuthenticator,
MutableDocument,
CollectionConfiguration,
ListenerToken
} from 'cbl-reactnative';
import getFileDefaultPath from '@/service/file/getFileDefaultPath';
Expand Down Expand Up @@ -62,12 +63,18 @@ export default function ReplicatorListenersScreen() {
}

const endpoint = new URLEndpoint(SYNC_GATEWAY_URL);
const replicatorConfig = new ReplicatorConfiguration(endpoint);

//Create CollectionConfiguration
const collectionConfig = new CollectionConfiguration(defaultCollection);

const listOfCollectionConfig = [collectionConfig]

// Pass array of configs and endpoint to constructor
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig , endpoint);
Comment on lines +67 to +73

Choose a reason for hiding this comment

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

medium

The comments explaining the API change can be removed as the code is now straightforward. Also, there are extra blank lines and an extra space in the constructor call that can be cleaned up for better readability.

Suggested change
//Create CollectionConfiguration
const collectionConfig = new CollectionConfiguration(defaultCollection);
const listOfCollectionConfig = [collectionConfig]
// Pass array of configs and endpoint to constructor
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig , endpoint);
const collectionConfig = new CollectionConfiguration(defaultCollection);
const listOfCollectionConfig = [collectionConfig];
const replicatorConfig = new ReplicatorConfiguration(listOfCollectionConfig, endpoint);


replicatorConfig.setAuthenticator(new BasicAuthenticator(USERNAME, PASSWORD));
replicatorConfig.setContinuous(true);
replicatorConfig.setAcceptOnlySelfSignedCerts(false);
replicatorConfig.addCollection(defaultCollection);

const replicator = await Replicator.create(replicatorConfig);
setReplicator(replicator);
Expand Down
Loading