@@ -4253,6 +4253,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
42534253 const mocks = getBlockMocks ( ) ;
42544254 const nodes = nodesForSuite ( ) ;
42554255
4256+ nodes . pds . sort = undefined ;
4257+
42564258 const persistedSort = {
42574259 method : Sorting . DatasetSortOpts . DateCreated ,
42584260 direction : Sorting . SortDirection . Descending ,
@@ -4264,8 +4266,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
42644266
42654267 expect ( mocks . nodeDataChanged ) . toHaveBeenCalled ( ) ;
42664268 expect ( mocks . refreshElement ) . not . toHaveBeenCalled ( ) ;
4267- expect ( nodes . pds . sort ?. method ) . toBe ( Sorting . DatasetSortOpts . Name ) ;
4268- expect ( nodes . pds . sort ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
4269+ expect ( ( nodes . pds . sort as any ) ?. method ) . toBe ( Sorting . DatasetSortOpts . Name ) ;
4270+ expect ( ( nodes . pds . sort as any ) ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
42694271 } ) ;
42704272
42714273 it ( "falls back to default sort options when no persistence available" , async ( ) => {
@@ -4281,8 +4283,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
42814283
42824284 expect ( mocks . nodeDataChanged ) . toHaveBeenCalled ( ) ;
42834285 expect ( mocks . refreshElement ) . not . toHaveBeenCalled ( ) ;
4284- expect ( nodes . pds . sort ?. method ) . toBe ( Sorting . DatasetSortOpts . DateCreated ) ;
4285- expect ( nodes . pds . sort ?. direction ) . toBe ( Sorting . SortDirection . Ascending ) ;
4286+ expect ( ( nodes . pds . sort as any ) ?. method ) . toBe ( Sorting . DatasetSortOpts . DateCreated ) ;
4287+ expect ( ( nodes . pds . sort as any ) ?. direction ) . toBe ( Sorting . SortDirection . Ascending ) ;
42864288 } ) ;
42874289
42884290 it ( "saves sort settings to persistence after sorting" , async ( ) => {
@@ -4347,6 +4349,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
43474349 const mocks = getBlockMocks ( ) ;
43484350 const nodes = nodesForSuite ( ) ;
43494351
4352+ nodes . session . sort = undefined ;
4353+
43504354 const persistedSessionSort = {
43514355 method : Sorting . DatasetSortOpts . LastModified ,
43524356 direction : Sorting . SortDirection . Descending ,
@@ -4358,8 +4362,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
43584362
43594363 expect ( mocks . nodeDataChanged ) . toHaveBeenCalled ( ) ;
43604364 expect ( mocks . refreshElement ) . not . toHaveBeenCalled ( ) ;
4361- expect ( nodes . session . sort ?. method ) . toBe ( Sorting . DatasetSortOpts . UserId ) ;
4362- expect ( nodes . session . sort ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
4365+ expect ( ( nodes . session . sort as any ) ?. method ) . toBe ( Sorting . DatasetSortOpts . UserId ) ;
4366+ expect ( ( nodes . session . sort as any ) ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
43634367 } ) ;
43644368
43654369 it ( "does not interfere with sort when getSortSetting returns undefined" , async ( ) => {
@@ -4413,8 +4417,8 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
44134417 mocks . showQuickPick . mockResolvedValueOnce ( { label : "$(account) User ID" } ) ;
44144418 await tree . sortPdsMembersDialog ( nodes . pds ) ;
44154419
4416- expect ( nodes . pds . sort ?. method ) . toBe ( Sorting . DatasetSortOpts . UserId ) ;
4417- expect ( nodes . pds . sort ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
4420+ expect ( ( nodes . pds . sort as any ) ?. method ) . toBe ( Sorting . DatasetSortOpts . UserId ) ;
4421+ expect ( ( nodes . pds . sort as any ) ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
44184422 expect ( mocks . nodeDataChanged ) . toHaveBeenCalled ( ) ;
44194423 } ) ;
44204424
@@ -4487,6 +4491,67 @@ describe("Dataset Tree Unit Tests - Sorting and Filtering operations", () => {
44874491
44884492 expect ( favPdsNode . children ?. map ( ( c : IZoweDatasetTreeNode ) => c . label ) ) . toStrictEqual ( [ "C" , "B" , "A" ] ) ;
44894493 } ) ;
4494+
4495+ it ( "allows changing sort direction when node already has sort set and persistence exists" , async ( ) => {
4496+ const mocks = getBlockMocks ( ) ;
4497+ const nodes = nodesForSuite ( ) ;
4498+
4499+ nodes . pds . sort = {
4500+ method : Sorting . DatasetSortOpts . Name ,
4501+ direction : Sorting . SortDirection . Descending ,
4502+ } ;
4503+
4504+ const persistedSort = {
4505+ method : Sorting . DatasetSortOpts . Name ,
4506+ direction : Sorting . SortDirection . Descending ,
4507+ } ;
4508+ const getSortSettingSpy = jest . spyOn ( DatasetTree . prototype , "getSortSetting" ) . mockReturnValue ( persistedSort ) ;
4509+
4510+ mocks . showQuickPick . mockResolvedValueOnce ( { label : "$(fold) Sort Direction" } ) ;
4511+ mocks . showQuickPick . mockResolvedValueOnce ( "Ascending" ) ;
4512+ mocks . showQuickPick . mockResolvedValueOnce ( { label : "$(case-sensitive) Name" } ) ;
4513+
4514+ await tree . sortPdsMembersDialog ( nodes . pds ) ;
4515+
4516+ expect ( nodes . pds . sort ?. direction ) . toBe ( Sorting . SortDirection . Ascending ) ;
4517+ expect ( nodes . pds . sort ?. method ) . toBe ( Sorting . DatasetSortOpts . Name ) ;
4518+ expect ( mocks . nodeDataChanged ) . toHaveBeenCalled ( ) ;
4519+
4520+ getSortSettingSpy . mockRestore ( ) ;
4521+ } ) ;
4522+
4523+ it ( "does not let persistence override sort direction changes by user" , async ( ) => {
4524+ const mocks = getBlockMocks ( ) ;
4525+ const nodes = nodesForSuite ( ) ;
4526+
4527+ nodes . pds . sort = {
4528+ method : Sorting . DatasetSortOpts . Name ,
4529+ direction : Sorting . SortDirection . Ascending ,
4530+ } ;
4531+
4532+ const persistedSort = {
4533+ method : Sorting . DatasetSortOpts . Name ,
4534+ direction : Sorting . SortDirection . Ascending ,
4535+ } ;
4536+ jest . spyOn ( DatasetTree . prototype , "getSortSetting" ) . mockReturnValue ( persistedSort ) ;
4537+ const addSortSettingSpy = jest . spyOn ( DatasetTree . prototype , "addSortSetting" ) ;
4538+
4539+ mocks . showQuickPick . mockResolvedValueOnce ( { label : "$(fold) Sort Direction" } ) ;
4540+ mocks . showQuickPick . mockResolvedValueOnce ( "Descending" ) ;
4541+ mocks . showQuickPick . mockResolvedValueOnce ( { label : "$(case-sensitive) Name" } ) ;
4542+
4543+ await tree . sortPdsMembersDialog ( nodes . pds ) ;
4544+
4545+ expect ( nodes . pds . sort ?. direction ) . toBe ( Sorting . SortDirection . Descending ) ;
4546+
4547+ expect ( addSortSettingSpy ) . toHaveBeenCalledWith (
4548+ nodes . pds ,
4549+ expect . objectContaining ( {
4550+ method : Sorting . DatasetSortOpts . Name ,
4551+ direction : Sorting . SortDirection . Descending ,
4552+ } )
4553+ ) ;
4554+ } ) ;
44904555 } ) ;
44914556
44924557 describe ( "filterBy & filterPdsMembersDialog" , ( ) => {
0 commit comments