Skip to content

Commit

Permalink
End-to-end test for "bulk_create_foreign_key" annotation property (#2561
Browse files Browse the repository at this point in the history
)

* tests cases for bulk_create_foreign_key annotation property
  • Loading branch information
jrchudy authored Oct 28, 2024
1 parent e96d611 commit 75c0827
Show file tree
Hide file tree
Showing 5 changed files with 277 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"main_fk_col": 2004, "leaf_fk_col": 2, "third_fk_col": 2, "static_col1": 2}]
10 changes: 10 additions & 0 deletions test/e2e/data_setup/data/product/leaf_table_for_three_fks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[{"id": "1", "details": "Leaf 1"},
{"id": "2", "details": "Leaf 2"},
{"id": "3", "details": "Leaf 3"},
{"id": "4", "details": "Leaf 4"},
{"id": "5", "details": "Leaf 5"},
{"id": "6", "details": "Leaf 6"},
{"id": "7", "details": "Leaf 7"},
{"id": "8", "details": "Leaf 8"},
{"id": "9", "details": "Leaf 9"},
{"id": "10", "details": "Leaf 10"}]
10 changes: 10 additions & 0 deletions test/e2e/data_setup/data/product/third_table_for_three_fks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[{"id": "1", "details": "Other Leaf 1"},
{"id": "2", "details": "Other Leaf 2"},
{"id": "3", "details": "Other Leaf 3"},
{"id": "4", "details": "Other Leaf 4"},
{"id": "5", "details": "Other Leaf 5"},
{"id": "6", "details": "Other Leaf 6"},
{"id": "7", "details": "Other Leaf 7"},
{"id": "8", "details": "Other Leaf 8"},
{"id": "9", "details": "Other Leaf 9"},
{"id": "10", "details": "Other Leaf 10"}]
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@
[
"product-unordered-related-tables-links",
"static_to_accommodation_w_dropdown_fkey"
],
[
"product-unordered-related-tables-links",
"three_fks_to_accommodation_fkey"
]
]
},
Expand Down Expand Up @@ -3234,6 +3238,237 @@
]
}
}
},
"association_table_w_three_fks": {
"comment": "For testing 'add records' prefill and using bulk create foreign key features with an annnotation defined since there are 3 foreign key relationships",
"kind": "table",
"schema_name": "product-unordered-related-tables-links",
"table_name": "association_table_w_three_fks",
"column_definitions": [
{
"name": "static_col1",
"type": {
"typename": "int4"
}
},
{
"name": "main_fk_col",
"nullok": false,
"type": {
"typename": "int4"
}
},
{
"name": "leaf_fk_col",
"nullok": false,
"type": {
"typename": "text"
}
},
{
"name": "third_fk_col",
"type": {
"typename": "text"
}
}
],
"keys": [
{
"unique_columns": [
"RID"
]
},
{
"unique_columns": [
"main_fk_col",
"leaf_fk_col"
]
}
],
"foreign_keys": [
{
"foreign_key_columns": [
{
"schema_name": "product-unordered-related-tables-links",
"table_name": "association_table_w_three_fks",
"column_name": "leaf_fk_col"
}
],
"referenced_columns": [
{
"schema_name": "product-unordered-related-tables-links",
"table_name": "leaf_table_for_three_fks",
"column_name": "id"
}
],
"names": [
[
"product-unordered-related-tables-links",
"three_fks_to_leaf_fkey"
]
]
},
{
"foreign_key_columns": [
{
"schema_name": "product-unordered-related-tables-links",
"table_name": "association_table_w_three_fks",
"column_name": "main_fk_col"
}
],
"referenced_columns": [
{
"schema_name": "product-unordered-related-tables-links",
"table_name": "accommodation",
"column_name": "id"
}
],
"names": [
[
"product-unordered-related-tables-links",
"three_fks_to_accommodation_fkey"
]
]
},
{
"foreign_key_columns": [
{
"schema_name": "product-unordered-related-tables-links",
"table_name": "association_table_w_three_fks",
"column_name": "third_fk_col"
}
],
"referenced_columns": [
{
"schema_name": "product-unordered-related-tables-links",
"table_name": "third_table_for_three_fks",
"column_name": "id"
}
],
"names": [
[
"product-unordered-related-tables-links",
"three_fks_to_third_fkey"
]
]
}
],
"annotations": {
"tag:isrd.isi.edu,2016:visible-columns": {
"entry": [
"static_col1",
{
"source": [
{
"outbound": [
"product-unordered-related-tables-links",
"three_fks_to_accommodation_fkey"
]
},
"RID"
],
"display": {
"bulk_create_foreign_key": [
"product-unordered-related-tables-links",
"three_fks_to_leaf_fkey"
]
}
},
[
"product-unordered-related-tables-links",
"three_fks_to_leaf_fkey"
],
[
"product-unordered-related-tables-links",
"three_fks_to_third_fkey"
]
],
"compact": "entry",
"detailed": "entry"
}
}
},
"leaf_table_for_three_fks": {
"comment": "leaf table for testing an association with 3 foreign keys and a bulk_create_foreign_key property in visible columns annotation",
"kind": "table",
"table_name": "leaf_table_for_three_fks",
"schema_name": "product-unordered-related-tables-links",
"keys": [
{
"unique_columns": [
"id"
]
}
],
"foreign_keys": [],
"column_definitions": [
{
"name": "id",
"type": {
"typename": "text"
}
},
{
"name": "details",
"type": {
"typename": "text"
}
}
],
"annotations": {
"tag:isrd.isi.edu,2016:table-display": {
"row_name": {
"row_markdown_pattern": "{{{details}}}"
}
},
"tag:isrd.isi.edu,2016:visible-columns": {
"compact": [
"id",
"details"
]
}
}
},
"third_table_for_three_fks": {
"comment": "third table for testing an association with 3 foreign keys and a bulk_create_foreign_key property in visible columns annotation",
"kind": "table",
"table_name": "third_table_for_three_fks",
"schema_name": "product-unordered-related-tables-links",
"keys": [
{
"unique_columns": [
"id"
]
}
],
"foreign_keys": [],
"column_definitions": [
{
"name": "id",
"type": {
"typename": "text"
}
},
{
"name": "details",
"type": {
"typename": "text"
}
}
],
"annotations": {
"tag:isrd.isi.edu,2016:table-display": {
"row_name": {
"row_markdown_pattern": "{{{details}}}"
}
},
"tag:isrd.isi.edu,2016:visible-columns": {
"compact": [
"id",
"details"
]
}
}
}
},
"comment": null,
Expand Down
26 changes: 21 additions & 5 deletions test/e2e/specs/all-features/record/related-table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ const testParams = {
'association with filter on main table',
'association with filter on related table', // association with filter on related table
'path of length 3 with filters', // path of length 3 with filters
'association_table_w_static_column', // "almost" pure and binary multi create foreig key with fk input modals
'association_table_w_static_column_dropdown' // "almost" pure and binary multi create foreig key with fk input dropdowns
'association_table_w_static_column', // "almost" pure and binary multi create foreign key with fk input modals
'association_table_w_static_column_dropdown', // "almost" pure and binary multi create foreign key with fk input dropdowns
'association_table_w_three_fks' // association table with 3 foreign keys and multi create foreign key with annotation
],
tocHeaders: [
'Summary', 'booking (6)', 'schedule (2)', 'media (1)', 'association_table (1)',
Expand All @@ -59,7 +60,8 @@ const testParams = {
'association with filter on related table (1)',
'path of length 3 with filters (1)',
'association_table_w_static_column (1)',
'association_table_w_static_column_dropdown (1)'
'association_table_w_static_column_dropdown (1)',
'association_table_w_three_fks (1)'
],
scrollToDisplayname: 'table_w_aggregates'
};
Expand Down Expand Up @@ -837,9 +839,12 @@ test.describe('Related tables', () => {
});

/**
* The following 2 tests are for testing the prefill functionality when the inbound foreign key is part of a table that is "almost" pure and binary
* The following tests are for testing the prefill functionality when the inbound foreign key is part of a table that is "almost" pure and binary
*
* This means there are 2 foreign keys that are part of the same key (making the pair unique) and there are other columns that are not foreign keys
* For the first 3 tests, this means there are 2 foreign keys that are part of the same key (making the pair unique) and there are other columns that are not foreign keys
*
* For the 4th test, there are still 2 foreign keys that are part of the same key but there is another foreign key on this table. This means the heuristics won't trigger
* for the bulk create foreign key functionality requiring an annotation to be defined instead.
*/
test.describe('for a table that is almost pure and binary and the foreign keys are a unique key', async () => {
const params = {
Expand Down Expand Up @@ -960,6 +965,17 @@ test.describe('Related tables', () => {

await testAddRelatedWithForeignKeyMultiPicker(page, params, RecordeditInputType.FK_DROPDOWN);
});

test('with a third foreign key and an annotation on main_fk_col', async ({ page }) => {
params.table_name = 'association_table_w_three_fks';
params.leaf_fk_name = 'leaf_fk_col';
params.bulk_modal_title = 'Select a set of leaf_fk_col for association_table_w_three_fks'

params.column_names = ['static1', 'main_fk_col', 'leaf_fk_col', 'third_fk_col'];
params.resultset_values = [['', '2004', '10', ''], ['', '2004', '7', '']];
params.related_table_values = [['2', 'Leaf 2', 'Other Leaf 2'], ['', 'Leaf 10', ''], ['', 'Leaf 7', '']];
await testAddRelatedWithForeignKeyMultiPicker(page, params, RecordeditInputType.FK_POPUP);
});
});
});

Expand Down

0 comments on commit 75c0827

Please sign in to comment.