This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provisions to identify fields with multiple value (#5109)
provisions to identify fields with multiple value. Some fields can hold multiple values and single value based on a property called `allowMultipleValues`. For example, `Lookup` column: ``` "lookup": { "allowMultipleValues": true, "allowUnlimitedLength": false, "columnName": "Title", "listId": "21b45bf2-e495-4582-b114-839577ff8e4f" } ``` But `choice` columns, even though allows to set multiple choices/value, does not have that particular field `allowMultipleValues` to indicate. So in this PR we are trying determine the same by the stored values while restoring. **Original list with `choice` column in site**: ![Choice-List-Multi](https://github.com/alcionai/corso/assets/48874082/d4457b3c-0230-4a69-8467-f64b7d7d4f04) **Restored list with `choice` column in site** ![Restored-Choice-List-Multi](https://github.com/alcionai/corso/assets/48874082/78478055-0e84-43d0-ac83-262b564ce778) The color does not come through though #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) #5108 #### Test Plan <!-- How will this be tested prior to merging.--> - [x] 💪 Manual - [x] ⚡ Unit test - [x] 💚 E2E
- Loading branch information
1 parent
6ef2c2d
commit 8ac7e6c
Showing
3 changed files
with
149 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,12 +162,12 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_GetValidation() { | |
for _, test := range tests { | ||
suite.Run(test.name, func() { | ||
t := suite.T() | ||
colNames := map[string]*columnDetails{} | ||
|
||
orig := test.getOrig() | ||
newCd := cloneColumnDefinitionable(orig) | ||
newCd := cloneColumnDefinitionable(orig, colNames) | ||
|
||
require.NotEmpty(t, newCd) | ||
|
||
test.expect(t, newCd.GetValidation()) | ||
}) | ||
} | ||
|
@@ -219,9 +219,10 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_GetDefaultValue() { | |
for _, test := range tests { | ||
suite.Run(test.name, func() { | ||
t := suite.T() | ||
colNames := map[string]*columnDetails{} | ||
|
||
orig := test.getOrig() | ||
newCd := cloneColumnDefinitionable(orig) | ||
newCd := cloneColumnDefinitionable(orig, colNames) | ||
|
||
require.NotEmpty(t, newCd) | ||
test.expect(t, newCd) | ||
|
@@ -277,9 +278,8 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_ColumnType() { | |
for _, test := range tests { | ||
suite.Run(test.name, func() { | ||
t := suite.T() | ||
|
||
orig := test.getOrig() | ||
newCd := cloneColumnDefinitionable(orig) | ||
colNames := map[string]*columnDetails{} | ||
newCd := cloneColumnDefinitionable(test.getOrig(), colNames) | ||
|
||
require.NotEmpty(t, newCd) | ||
assert.True(t, test.checkFn(newCd)) | ||
|
@@ -332,7 +332,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
name string | ||
getList func() *models.List | ||
length int | ||
expectedColNames map[string]any | ||
expectedColNames map[string]*columnDetails | ||
}{ | ||
{ | ||
name: "all legacy columns", | ||
|
@@ -346,7 +346,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 0, | ||
expectedColNames: map[string]any{TitleColumnName: nil}, | ||
expectedColNames: map[string]*columnDetails{TitleColumnName: {}}, | ||
}, | ||
{ | ||
name: "title and legacy columns", | ||
|
@@ -361,7 +361,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 0, | ||
expectedColNames: map[string]any{TitleColumnName: nil}, | ||
expectedColNames: map[string]*columnDetails{TitleColumnName: {}}, | ||
}, | ||
{ | ||
name: "readonly and legacy columns", | ||
|
@@ -376,7 +376,7 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 0, | ||
expectedColNames: map[string]any{TitleColumnName: nil}, | ||
expectedColNames: map[string]*columnDetails{TitleColumnName: {}}, | ||
}, | ||
{ | ||
name: "legacy and a text column", | ||
|
@@ -391,9 +391,9 @@ func (suite *ListsUnitSuite) TestColumnDefinitionable_LegacyColumns() { | |
return lst | ||
}, | ||
length: 1, | ||
expectedColNames: map[string]any{ | ||
TitleColumnName: nil, | ||
textColumnName: nil, | ||
expectedColNames: map[string]*columnDetails{ | ||
TitleColumnName: {}, | ||
textColumnName: {}, | ||
}, | ||
}, | ||
} | ||
|
@@ -432,7 +432,7 @@ func (suite *ListsUnitSuite) TestFieldValueSetable() { | |
origFs := models.NewFieldValueSet() | ||
origFs.SetAdditionalData(additionalData) | ||
|
||
colNames := map[string]any{} | ||
colNames := map[string]*columnDetails{} | ||
|
||
fs := retrieveFieldData(origFs, colNames) | ||
fsAdditionalData := fs.GetAdditionalData() | ||
|
@@ -442,7 +442,7 @@ func (suite *ListsUnitSuite) TestFieldValueSetable() { | |
origFs = models.NewFieldValueSet() | ||
origFs.SetAdditionalData(additionalData) | ||
|
||
colNames["itemName"] = struct{}{} | ||
colNames["itemName"] = &columnDetails{} | ||
|
||
fs = retrieveFieldData(origFs, colNames) | ||
fsAdditionalData = fs.GetAdditionalData() | ||
|
@@ -509,8 +509,8 @@ func (suite *ListsUnitSuite) TestFieldValueSetable_Location() { | |
origFs := models.NewFieldValueSet() | ||
origFs.SetAdditionalData(additionalData) | ||
|
||
colNames := map[string]any{ | ||
"MyAddress": nil, | ||
colNames := map[string]*columnDetails{ | ||
"MyAddress": {}, | ||
} | ||
|
||
fs := retrieveFieldData(origFs, colNames) | ||
|
@@ -703,6 +703,75 @@ func (suite *ListsUnitSuite) TestConcatenateHyperlinkFields() { | |
} | ||
} | ||
|
||
func (suite *ListsUnitSuite) TestSetAdditionalDataByColumnNames() { | ||
t := suite.T() | ||
|
||
tests := []struct { | ||
name string | ||
additionalData map[string]any | ||
colName string | ||
assertFn assert.BoolAssertionFunc | ||
}{ | ||
{ | ||
name: "choice column, single value", | ||
additionalData: map[string]any{ | ||
"choice": "good", | ||
}, | ||
colName: "choice", | ||
assertFn: assert.False, | ||
}, | ||
{ | ||
name: "choice column, multiple values", | ||
additionalData: map[string]any{ | ||
"choice": []string{"good", "ok"}, | ||
}, | ||
colName: "choice", | ||
assertFn: assert.True, | ||
}, | ||
{ | ||
name: "person column, single value", | ||
additionalData: map[string]any{ | ||
"PersonsLookupId": 10, | ||
}, | ||
colName: "PersonsLookupId", | ||
assertFn: assert.False, | ||
}, | ||
{ | ||
name: "person column, multiple values", | ||
additionalData: map[string]any{ | ||
"Persons": []map[string]any{ | ||
{ | ||
"LookupId": 10, | ||
"LookupValue": "Who1", | ||
"Email": "[email protected]", | ||
}, | ||
{ | ||
"LookupId": 11, | ||
"LookupValue": "Who2", | ||
"Email": "[email protected]", | ||
}, | ||
}, | ||
}, | ||
colName: "Persons", | ||
assertFn: assert.True, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
origFs := models.NewFieldValueSet() | ||
origFs.SetAdditionalData(test.additionalData) | ||
|
||
colNames := map[string]*columnDetails{ | ||
test.colName: {}, | ||
} | ||
|
||
suite.Run(test.name, func() { | ||
setAdditionalDataByColumnNames(origFs, colNames) | ||
test.assertFn(t, colNames[test.colName].isMultipleEnabled) | ||
}) | ||
} | ||
} | ||
|
||
type ListsAPIIntgSuite struct { | ||
tester.Suite | ||
its intgTesterSetup | ||
|