@@ -4,12 +4,13 @@ import {
44 PIVOT_INSERT_TABLE_STYLE_ID ,
55 PIVOT_TOKEN_COLOR ,
66} from "@odoo/o-spreadsheet-engine/constants" ;
7+ import { datetimeGranularities } from "@odoo/o-spreadsheet-engine/helpers/pivot/pivot_registry" ;
78import { SpreadsheetPivot } from "@odoo/o-spreadsheet-engine/helpers/pivot/spreadsheet_pivot/spreadsheet_pivot" ;
89import { SpreadsheetChildEnv } from "@odoo/o-spreadsheet-engine/types/spreadsheet_env" ;
910import { Model , PivotSortedColumn , SpreadsheetPivotTable } from "../../../src" ;
1011import { SidePanels } from "../../../src/components/side_panel/side_panels/side_panels" ;
1112import { toXC , toZone } from "../../../src/helpers" ;
12- import { topbarMenuRegistry } from "../../../src/registries/menus" ;
13+ import { topbarMenuRegistry } from "../../../src/registries/menus/topbar_menu_registry " ;
1314import { NotificationStore } from "../../../src/stores/notification_store" ;
1415import {
1516 activateSheet ,
@@ -575,6 +576,43 @@ describe("Spreadsheet pivot side panel", () => {
575576 ] ) ;
576577 } ) ;
577578
579+ test ( "All granularities are displayed in order and not more than once" , async ( ) => {
580+ setCellContent ( model , "G1" , "=PIVOT(1)" ) ; // TODO: remove once task 4781740 is done
581+ setCellContent ( model , "A1" , "Date" ) ;
582+ setCellContent ( model , "A2" , "2023-01-01" ) ;
583+ setCellContent ( model , "A3" , "2023-01-02" ) ;
584+ updatePivot ( model , "1" , {
585+ columns : [ ] ,
586+ measures : [ { id : "Amount:sum" , fieldName : "Amount" , aggregator : "sum" } ] ,
587+ } ) ;
588+ await nextTick ( ) ;
589+
590+ for ( let i = 0 ; i < datetimeGranularities . length ; i ++ ) {
591+ await click ( fixture . querySelector ( ".add-dimension" ) ! ) ;
592+ await click ( fixture . querySelectorAll ( ".o-autocomplete-value" ) [ 0 ] ) ;
593+ }
594+
595+ expect ( model . getters . getPivotCoreDefinition ( "1" ) . columns ) . toMatchObject ( [
596+ { fieldName : "Date" , granularity : "year" } ,
597+ { fieldName : "Date" , granularity : "quarter_number" } ,
598+ { fieldName : "Date" , granularity : "month_number" } ,
599+ { fieldName : "Date" , granularity : "month" } ,
600+ { fieldName : "Date" , granularity : "iso_week_number" } ,
601+ { fieldName : "Date" , granularity : "day_of_month" } ,
602+ { fieldName : "Date" , granularity : "day" } ,
603+ { fieldName : "Date" , granularity : "day_of_week" } ,
604+ { fieldName : "Date" , granularity : "hour_number" } ,
605+ { fieldName : "Date" , granularity : "minute_number" } ,
606+ { fieldName : "Date" , granularity : "second_number" } ,
607+ ] ) ;
608+
609+ await click ( fixture . querySelector ( ".add-dimension" ) ! ) ;
610+ const availableFields = [ ...fixture . querySelectorAll ( ".o-autocomplete-value" ) ] . map (
611+ ( el ) => el . textContent
612+ ) ;
613+ expect ( availableFields ) . not . toContain ( "Date" ) ;
614+ } ) ;
615+
578616 test ( "Date dimensions with undefined granularity is correctly displayed as month" , async ( ) => {
579617 setCellContent ( model , "G1" , "=PIVOT(1)" ) ; // TODO: remove once task 4781740 is done
580618 setCellContent ( model , "A1" , "Date" ) ;
0 commit comments