@@ -2672,6 +2672,74 @@ public function createRelationColumnToView(string $title, string $tableName, str
26722672 $ this ->collectionManager ->register ($ newColumn , 'column ' , $ newColumn ['id ' ], $ title );
26732673 }
26742674
2675+ /**
2676+ * @Then relation lookup column :title exists on table :tableName for relation column :relationColumnName using target column :targetColumnName
2677+ */
2678+ public function createRelationLookupColumn (string $ title , string $ tableName , string $ relationColumnName , string $ targetColumnName ): void {
2679+ $ relationColumnId = (int )$ this ->collectionManager ->getByAlias ('column ' , $ relationColumnName )['id ' ];
2680+ $ targetColumnId = (int )$ this ->collectionManager ->getByAlias ('column ' , $ targetColumnName )['id ' ];
2681+
2682+ $ props = [
2683+ 'title ' => $ title ,
2684+ 'type ' => 'relation_lookup ' ,
2685+ 'mandatory ' => 0 ,
2686+ 'customSettings ' => [
2687+ 'relationColumnId ' => $ relationColumnId ,
2688+ 'targetColumnId ' => $ targetColumnId ,
2689+ ],
2690+ ];
2691+
2692+ $ this ->sendRequest (
2693+ 'POST ' ,
2694+ '/apps/tables/api/1/tables/ ' . $ this ->tableIds [$ tableName ] . '/columns ' ,
2695+ $ props
2696+ );
2697+
2698+ $ newColumn = $ this ->getDataFromResponse ($ this ->response );
2699+ $ this ->columnId = $ newColumn ['id ' ];
2700+
2701+ Assert::assertEquals (200 , $ this ->response ->getStatusCode ());
2702+ Assert::assertEquals ($ title , $ newColumn ['title ' ]);
2703+ Assert::assertEquals ('relation_lookup ' , $ newColumn ['type ' ]);
2704+
2705+ $ this ->collectionManager ->register ($ newColumn , 'column ' , $ newColumn ['id ' ], $ title );
2706+ }
2707+
2708+ /**
2709+ * @Then relation lookup column :title exists on table :tableName for relation column :relationColumnName using target column :targetColumnName added to view :viewName
2710+ */
2711+ public function createRelationLookupColumnAddedToView (string $ title , string $ tableName , string $ relationColumnName , string $ targetColumnName , string $ viewName ): void {
2712+ $ relationColumnId = (int )$ this ->collectionManager ->getByAlias ('column ' , $ relationColumnName )['id ' ];
2713+ $ targetColumnId = (int )$ this ->collectionManager ->getByAlias ('column ' , $ targetColumnName )['id ' ];
2714+ $ viewId = $ this ->viewIds [$ viewName ];
2715+
2716+ $ props = [
2717+ 'title ' => $ title ,
2718+ 'type ' => 'relation_lookup ' ,
2719+ 'mandatory ' => 0 ,
2720+ 'selectedViewIds ' => [$ viewId ],
2721+ 'customSettings ' => [
2722+ 'relationColumnId ' => $ relationColumnId ,
2723+ 'targetColumnId ' => $ targetColumnId ,
2724+ ],
2725+ ];
2726+
2727+ $ this ->sendRequest (
2728+ 'POST ' ,
2729+ '/apps/tables/api/1/tables/ ' . $ this ->tableIds [$ tableName ] . '/columns ' ,
2730+ $ props
2731+ );
2732+
2733+ $ newColumn = $ this ->getDataFromResponse ($ this ->response );
2734+ $ this ->columnId = $ newColumn ['id ' ];
2735+
2736+ Assert::assertEquals (200 , $ this ->response ->getStatusCode ());
2737+ Assert::assertEquals ($ title , $ newColumn ['title ' ]);
2738+ Assert::assertEquals ('relation_lookup ' , $ newColumn ['type ' ]);
2739+
2740+ $ this ->collectionManager ->register ($ newColumn , 'column ' , $ newColumn ['id ' ], $ title );
2741+ }
2742+
26752743 /**
26762744 * @When user :user fetches relations for table :tableName
26772745 */
@@ -2721,6 +2789,17 @@ public function theRelationsResponseForColumnHasEntryWithLabel(string $columnNam
27212789 Assert::assertContains ($ label , $ labels , 'Label " ' . $ label . '" not found in relations for column " ' . $ columnName . '" ' );
27222790 }
27232791
2792+ /**
2793+ * @Then the relations response for column :columnName has an entry with value :value
2794+ */
2795+ public function theRelationsResponseForColumnHasEntryWithValue (string $ columnName , string $ value ): void {
2796+ Assert::assertNotNull ($ this ->relationsData , 'Relations response was not fetched or returned non-200 ' );
2797+ $ columnId = (int )$ this ->collectionManager ->getByAlias ('column ' , $ columnName )['id ' ];
2798+ Assert::assertArrayHasKey ($ columnId , $ this ->relationsData , 'Column " ' . $ columnName . '" not found in relations response ' );
2799+ $ values = array_column ($ this ->relationsData [$ columnId ]['values ' ], 'value ' );
2800+ Assert::assertContains ($ value , $ values , 'Value " ' . $ value . '" not found in relations for column " ' . $ columnName . '" ' );
2801+ }
2802+
27242803 /**
27252804 * @Then the relations response is empty
27262805 */
0 commit comments