-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adapt getAllOptionsLists to return also faulty options lists if readi…
…ng them fails
- Loading branch information
Showing
37 changed files
with
366 additions
and
355 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
|
||
namespace Altinn.Studio.Designer.Models.Dto; | ||
|
||
public class OptionListData | ||
{ | ||
public string Title; | ||
[CanBeNull] public List<Option> Data; | ||
public bool? HasError; | ||
} |
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
58 changes: 0 additions & 58 deletions
58
...p-development/features/appContentLibrary/utils/convertOptionsListToCodeListResult.test.ts
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...nd/app-development/features/appContentLibrary/utils/convertOptionsListToCodeListResult.ts
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...velopment/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.test.ts
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { CodeListData } from '@studio/content-library'; | ||
import { convertOptionsListsDataToCodeListsData } from './convertOptionsListsDataToCodeListsData'; | ||
import type { OptionsListsResponse } from 'app-shared/types/api/OptionsLists'; | ||
|
||
describe('convertOptionsListsDataToCodeListsData', () => { | ||
it('converts option lists data to code lists data correctly', () => { | ||
const optionListId: string = 'optionListId'; | ||
const optionListsData: OptionsListsResponse = [ | ||
{ | ||
title: optionListId, | ||
data: [ | ||
{ label: 'Option 1', value: '1' }, | ||
{ label: 'Option 2', value: '2' }, | ||
], | ||
hasError: false, | ||
}, | ||
]; | ||
const result: CodeListData[] = convertOptionsListsDataToCodeListsData(optionListsData); | ||
expect(result).toEqual([ | ||
{ | ||
title: optionListId, | ||
data: [ | ||
{ label: 'Option 1', value: '1' }, | ||
{ label: 'Option 2', value: '2' }, | ||
], | ||
hasError: false, | ||
}, | ||
]); | ||
}); | ||
|
||
it('sets hasError to true in result when optionListsResponse returns an option list with error', () => { | ||
const optionListId: string = 'optionListId'; | ||
const optionListsData: OptionsListsResponse = [ | ||
{ | ||
title: optionListId, | ||
data: null, | ||
hasError: true, | ||
}, | ||
]; | ||
const result: CodeListData[] = convertOptionsListsDataToCodeListsData(optionListsData); | ||
expect(result).toEqual([{ title: optionListId, data: null, hasError: true }]); | ||
}); | ||
|
||
it('returns a result with empty code list data array when the input option list data is empty', () => { | ||
const optionListsData: OptionsListsResponse = []; | ||
const result: CodeListData[] = convertOptionsListsDataToCodeListsData(optionListsData); | ||
expect(result).toEqual([]); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
...pp-development/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.ts
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { OptionsListData, OptionsListsResponse } from 'app-shared/types/api/OptionsLists'; | ||
import type { CodeListData } from '@studio/content-library'; | ||
|
||
export const convertOptionsListsDataToCodeListsData = (optionListsData: OptionsListsResponse) => { | ||
const codeListsData = []; | ||
optionListsData.map((optionListData) => { | ||
const codeListData = convertOptionsListDataToCodeListData(optionListData); | ||
codeListsData.push(codeListData); | ||
}); | ||
return codeListsData; | ||
}; | ||
|
||
const convertOptionsListDataToCodeListData = (optionListData: OptionsListData) => { | ||
const codeListData: CodeListData = { | ||
title: optionListData.title, | ||
data: optionListData.data, | ||
hasError: optionListData.hasError, | ||
}; | ||
return codeListData; | ||
}; |
13 changes: 7 additions & 6 deletions
13
frontend/libs/studio-content-library/mocks/mockPagesConfig.ts
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
Oops, something went wrong.