@@ -3521,15 +3521,14 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
35213521// }
35223522
35233523 func testDocumentId( ) async throws {
3524- try XCTSkipIf ( true , " Skip this test since backend has not yet supported. " )
35253524 let collRef = collectionRef ( withDocuments: bookDocs)
35263525 let db = collRef. firestore
35273526
35283527 let pipeline = db. pipeline ( )
35293528 . collection ( collRef. path)
35303529 . sort ( [ Field ( " rating " ) . descending ( ) ] )
35313530 . limit ( 1 )
3532- . select ( [ Field ( " __path__ " ) . documentId ( ) . as ( " docId " ) ] )
3531+ . select ( [ Field ( FieldPath . documentID ( ) ) . documentId ( ) . as ( " docId " ) ] )
35333532 let snapshot = try await pipeline. execute ( )
35343533 TestHelper . compare (
35353534 snapshot: snapshot,
@@ -3844,4 +3843,52 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
38443843 enforceOrder: true
38453844 )
38463845 }
3846+
3847+ func testSplitWorks( ) async throws {
3848+ let collRef = collectionRef ( withDocuments: [
3849+ " doc1 " : [ " text " : " a-b-c " ] ,
3850+ " doc2 " : [ " text " : " x,y,z " , " delimiter " : " , " ] ,
3851+ " doc3 " : [ " text " : Data ( [ 0x61 , 0x00 , 0x62 , 0x00 , 0x63 ] ) , " delimiter " : Data ( [ 0x00 ] ) ] ,
3852+ ] )
3853+ let db = collRef. firestore
3854+
3855+ // Test with string literal delimiter
3856+ var pipeline = db. pipeline ( )
3857+ . documents ( [ collRef. document ( " doc1 " ) . path] )
3858+ . select ( [
3859+ Field ( " text " ) . split ( delimiter: " - " ) . as ( " split_text " ) ,
3860+ ] )
3861+ var snapshot = try await pipeline. execute ( )
3862+
3863+ var expectedResults : [ [ String : Sendable ] ] = [
3864+ [ " split_text " : [ " a " , " b " , " c " ] ] ,
3865+ ]
3866+ TestHelper . compare ( snapshot: snapshot, expected: expectedResults, enforceOrder: false )
3867+
3868+ // Test with expression delimiter (string)
3869+ pipeline = db. pipeline ( )
3870+ . documents ( [ collRef. document ( " doc2 " ) . path] )
3871+ . select ( [
3872+ Field ( " text " ) . split ( delimiter: Field ( " delimiter " ) ) . as ( " split_text " ) ,
3873+ ] )
3874+ snapshot = try await pipeline. execute ( )
3875+
3876+ expectedResults = [
3877+ [ " split_text " : [ " x " , " y " , " z " ] ] ,
3878+ ]
3879+ TestHelper . compare ( snapshot: snapshot, expected: expectedResults, enforceOrder: false )
3880+
3881+ // Test with expression delimiter (bytes)
3882+ pipeline = db. pipeline ( )
3883+ . documents ( [ collRef. document ( " doc3 " ) . path] )
3884+ . select ( [
3885+ Field ( " text " ) . split ( delimiter: Field ( " delimiter " ) ) . as ( " split_text " ) ,
3886+ ] )
3887+ snapshot = try await pipeline. execute ( )
3888+
3889+ let expectedByteResults : [ [ String : Sendable ] ] = [
3890+ [ " split_text " : [ Data ( [ 0x61 ] ) , Data ( [ 0x62 ] ) , Data ( [ 0x63 ] ) ] ] ,
3891+ ]
3892+ TestHelper . compare ( snapshot: snapshot, expected: expectedByteResults, enforceOrder: false )
3893+ }
38473894}
0 commit comments