@@ -1020,53 +1020,6 @@ describe('Appointment Form', () => {
10201020 } ) ;
10211021 } ) ;
10221022 } ) ;
1023-
1024- describe ( 'Customization' , ( ) => {
1025- it ( 'should propagate editing.form options to the form instance' , async ( ) => {
1026- const { scheduler, POM } = await createScheduler ( {
1027- ...getDefaultConfig ( ) ,
1028- editing : {
1029- allowAdding : true ,
1030- allowUpdating : true ,
1031- form : {
1032- height : 500 ,
1033- } ,
1034- } ,
1035- } ) ;
1036-
1037- scheduler . showAppointmentPopup ( commonAppointment ) ;
1038-
1039- const { dxForm : form } = POM . popup ;
1040- const formHeight = form . option ( 'height' ) as number ;
1041-
1042- expect ( formHeight ) . toBe ( 500 ) ;
1043- } ) ;
1044-
1045- it ( 'should merge editing.form options with default form configuration' , async ( ) => {
1046- const { scheduler, POM } = await createScheduler ( {
1047- ...getDefaultConfig ( ) ,
1048- editing : {
1049- allowAdding : true ,
1050- allowUpdating : true ,
1051- form : {
1052- height : 500 ,
1053- elementAttr : { id : 'custom-form' } ,
1054- } ,
1055- } ,
1056- } ) ;
1057-
1058- scheduler . showAppointmentPopup ( commonAppointment ) ;
1059-
1060- const { dxForm : form } = POM . popup ;
1061- const formHeight = form . option ( 'height' ) as number ;
1062- const elementAttr = form . option ( 'elementAttr' ) as { class ?: string ; id ?: string } ;
1063- const { class : className , id } = elementAttr ;
1064-
1065- expect ( formHeight ) . toBe ( 500 ) ;
1066- expect ( className ) . toBe ( 'dx-scheduler-form' ) ;
1067- expect ( id ) . toBe ( 'custom-form' ) ;
1068- } ) ;
1069- } ) ;
10701023} ) ;
10711024
10721025describe ( 'Appointment Popup' , ( ) => {
@@ -1260,214 +1213,6 @@ describe('Appointment Popup', () => {
12601213 } ) ;
12611214
12621215 describe ( 'Customization' , ( ) => {
1263- it ( 'should pass custom popup options from editing.popup to appointment popup' , async ( ) => {
1264- const { scheduler, POM } = await createScheduler ( {
1265- ...getDefaultConfig ( ) ,
1266- editing : {
1267- allowAdding : true ,
1268- allowUpdating : true ,
1269- popup : {
1270- showTitle : true ,
1271- title : 'Custom Appointment Form' ,
1272- maxHeight : '80%' ,
1273- dragEnabled : true ,
1274- } ,
1275- } ,
1276- } ) ;
1277-
1278- scheduler . showAppointmentPopup ( commonAppointment ) ;
1279-
1280- expect ( POM . popup . component . option ( 'showTitle' ) ) . toBe ( true ) ;
1281- expect ( POM . popup . component . option ( 'title' ) ) . toBe ( 'Custom Appointment Form' ) ;
1282- expect ( POM . popup . component . option ( 'maxHeight' ) ) . toBe ( '80%' ) ;
1283- expect ( POM . popup . component . option ( 'dragEnabled' ) ) . toBe ( true ) ;
1284- } ) ;
1285-
1286- it ( 'should use default popup options when editing.popup is not specified' , async ( ) => {
1287- const { scheduler, POM } = await createScheduler ( {
1288- ...getDefaultConfig ( ) ,
1289- editing : {
1290- allowAdding : true ,
1291- allowUpdating : true ,
1292- } ,
1293- } ) ;
1294-
1295- scheduler . showAppointmentPopup ( commonAppointment ) ;
1296-
1297- expect ( POM . popup . component . option ( 'showTitle' ) ) . toBe ( false ) ;
1298- expect ( POM . popup . component . option ( 'height' ) ) . toBe ( 'auto' ) ;
1299- expect ( POM . popup . component . option ( 'maxHeight' ) ) . toBe ( '90%' ) ;
1300- } ) ;
1301-
1302- it ( 'should merge custom popup options with default options' , async ( ) => {
1303- const { scheduler, POM } = await createScheduler ( {
1304- ...getDefaultConfig ( ) ,
1305- editing : {
1306- allowAdding : true ,
1307- allowUpdating : true ,
1308- popup : {
1309- showTitle : true ,
1310- title : 'My Form' ,
1311- } ,
1312- } ,
1313- } ) ;
1314-
1315- scheduler . showAppointmentPopup ( commonAppointment ) ;
1316-
1317- expect ( POM . popup . component . option ( 'showTitle' ) ) . toBe ( true ) ;
1318- expect ( POM . popup . component . option ( 'title' ) ) . toBe ( 'My Form' ) ;
1319-
1320- expect ( POM . popup . component . option ( 'showCloseButton' ) ) . toBe ( false ) ;
1321- expect ( POM . popup . component . option ( 'enableBodyScroll' ) ) . toBe ( false ) ;
1322- expect ( POM . popup . component . option ( 'preventScrollEvents' ) ) . toBe ( false ) ;
1323- } ) ;
1324-
1325- it ( 'should allow overriding default popup options' , async ( ) => {
1326- const { scheduler, POM } = await createScheduler ( {
1327- ...getDefaultConfig ( ) ,
1328- editing : {
1329- allowAdding : true ,
1330- allowUpdating : true ,
1331- popup : {
1332- showCloseButton : true ,
1333- enableBodyScroll : true ,
1334- } ,
1335- } ,
1336- } ) ;
1337-
1338- scheduler . showAppointmentPopup ( commonAppointment ) ;
1339-
1340- expect ( POM . popup . component . option ( 'showCloseButton' ) ) . toBe ( true ) ;
1341- expect ( POM . popup . component . option ( 'enableBodyScroll' ) ) . toBe ( true ) ;
1342- } ) ;
1343-
1344- it ( 'should apply wrapperAttr configuration to popup' , async ( ) => {
1345- const { scheduler, POM } = await createScheduler ( {
1346- ...getDefaultConfig ( ) ,
1347- editing : {
1348- allowAdding : true ,
1349- allowUpdating : true ,
1350- popup : {
1351- wrapperAttr : {
1352- id : 'test' ,
1353- } ,
1354- } ,
1355- } ,
1356- } ) ;
1357-
1358- scheduler . showAppointmentPopup ( commonAppointment ) ;
1359-
1360- const wrapperAttr = POM . popup . component . option ( 'wrapperAttr' ) ;
1361- expect ( wrapperAttr . id ) . toBe ( 'test' ) ;
1362- expect ( wrapperAttr . class ) . toBeDefined ( ) ;
1363- } ) ;
1364-
1365- it ( 'should call onInitialized callback when popup is initialized' , async ( ) => {
1366- const onInitialized = jest . fn ( ) ;
1367- const { scheduler, POM } = await createScheduler ( {
1368- ...getDefaultConfig ( ) ,
1369- editing : {
1370- allowAdding : true ,
1371- allowUpdating : true ,
1372- popup : {
1373- onInitialized,
1374- } ,
1375- } ,
1376- } ) ;
1377-
1378- scheduler . showAppointmentPopup ( commonAppointment ) ;
1379-
1380- expect ( POM . isPopupVisible ( ) ) . toBe ( true ) ;
1381- expect ( onInitialized ) . toHaveBeenCalled ( ) ;
1382- expect ( onInitialized ) . toHaveBeenCalledTimes ( 1 ) ;
1383- } ) ;
1384-
1385- it ( 'should call onShowing callback when popup is shown' , async ( ) => {
1386- const onShowing = jest . fn ( ) ;
1387- const onAppointmentFormOpening = jest . fn ( ) ;
1388- const { scheduler } = await createScheduler ( {
1389- ...getDefaultConfig ( ) ,
1390- editing : {
1391- allowAdding : true ,
1392- allowUpdating : true ,
1393- popup : {
1394- onShowing,
1395- } ,
1396- } ,
1397- onAppointmentFormOpening,
1398- } ) ;
1399-
1400- scheduler . showAppointmentPopup ( commonAppointment ) ;
1401-
1402- expect ( onShowing ) . toHaveBeenCalled ( ) ;
1403- expect ( onShowing ) . toHaveBeenCalledTimes ( 1 ) ;
1404- expect ( onAppointmentFormOpening ) . toHaveBeenCalled ( ) ;
1405- expect ( onAppointmentFormOpening ) . toHaveBeenCalledTimes ( 1 ) ;
1406- } ) ;
1407-
1408- it ( 'should call onHiding callback when popup is hidden' , async ( ) => {
1409- const onHiding = jest . fn ( ) ;
1410- const { scheduler } = await createScheduler ( {
1411- ...getDefaultConfig ( ) ,
1412- editing : {
1413- allowAdding : true ,
1414- allowUpdating : true ,
1415- popup : {
1416- onHiding,
1417- } ,
1418- } ,
1419- } ) ;
1420-
1421- const focusSpy = jest . spyOn ( scheduler , 'focus' ) ;
1422-
1423- scheduler . showAppointmentPopup ( commonAppointment ) ;
1424-
1425- expect ( onHiding ) . not . toHaveBeenCalled ( ) ;
1426- expect ( focusSpy ) . not . toHaveBeenCalled ( ) ;
1427-
1428- scheduler . hideAppointmentPopup ( ) ;
1429-
1430- expect ( onHiding ) . toHaveBeenCalled ( ) ;
1431- expect ( onHiding ) . toHaveBeenCalledTimes ( 1 ) ;
1432- expect ( focusSpy ) . toHaveBeenCalled ( ) ;
1433- expect ( focusSpy ) . toHaveBeenCalledTimes ( 1 ) ;
1434-
1435- focusSpy . mockRestore ( ) ;
1436- } ) ;
1437-
1438- it ( 'should preserve custom toolbarItems when popup opens' , async ( ) => {
1439- const { scheduler, POM } = await createScheduler ( {
1440- ...getDefaultConfig ( ) ,
1441- editing : {
1442- popup : {
1443- toolbarItems : [ {
1444- toolbar : 'top' , location : 'before' , text : 'Custom Title' , cssClass : 'custom-title' ,
1445- } , {
1446- toolbar : 'top' , location : 'after' , widget : 'dxButton' , options : { text : 'Custom Save' } ,
1447- } ] ,
1448- } ,
1449- } ,
1450- } ) ;
1451-
1452- scheduler . showAppointmentPopup ( commonAppointment ) ;
1453-
1454- const toolbarItems = POM . popup . component . option ( 'toolbarItems' ) ;
1455-
1456- expect ( toolbarItems ) . toBeDefined ( ) ;
1457- expect ( toolbarItems ) . toHaveLength ( 2 ) ;
1458- expect ( toolbarItems ) . toContainEqual ( expect . objectContaining ( {
1459- cssClass : 'custom-title' , location : 'before' , text : 'Custom Title' , toolbar : 'top' ,
1460- } ) ) ;
1461- expect ( toolbarItems ) . toContainEqual ( expect . objectContaining (
1462- {
1463- toolbar : 'top' ,
1464- location : 'after' ,
1465- widget : 'dxButton' ,
1466- options : expect . objectContaining ( { text : 'Custom Save' } ) ,
1467- } ,
1468- ) ) ;
1469- } ) ;
1470-
14711216 it ( 'should preserve custom toolbarItems when popup is reopened' , async ( ) => {
14721217 const { scheduler, POM } = await createScheduler ( {
14731218 ...getDefaultConfig ( ) ,
@@ -1489,93 +1234,6 @@ describe('Appointment Popup', () => {
14891234 expect ( toolbarItems ) . toHaveLength ( 1 ) ;
14901235 expect ( toolbarItems ?. [ 0 ] ?. text ) . toBe ( 'Custom Toolbar' ) ;
14911236 } ) ;
1492-
1493- it ( 'should open popup if popup.deferRendering is false' , async ( ) => {
1494- const { scheduler, POM } = await createScheduler ( {
1495- ...getDefaultConfig ( ) ,
1496- editing : {
1497- allowAdding : true ,
1498- allowUpdating : true ,
1499- popup : {
1500- deferRendering : false ,
1501- } ,
1502- } ,
1503- } ) ;
1504-
1505- scheduler . showAppointmentPopup ( commonAppointment ) ;
1506-
1507- expect ( POM . isPopupVisible ( ) ) . toBe ( true ) ;
1508- } ) ;
1509-
1510- describe ( 'Popup width and maxWidth options' , ( ) => {
1511- // Mock window width to avoid fullscreen mode
1512- beforeEach ( ( ) => {
1513- Object . defineProperty ( document . documentElement , 'clientWidth' , {
1514- value : 1280 ,
1515- } ) ;
1516- } ) ;
1517-
1518- it ( 'should use custom maxWidth when specified' , async ( ) => {
1519- const { scheduler, POM } = await createScheduler ( {
1520- ...getDefaultConfig ( ) ,
1521- editing : {
1522- allowAdding : true ,
1523- allowUpdating : true ,
1524- popup : {
1525- maxWidth : 500 ,
1526- } ,
1527- } ,
1528- } ) ;
1529-
1530- scheduler . showAppointmentPopup ( commonAppointment ) ;
1531-
1532- const maxWidth = POM . popup . component . option ( 'maxWidth' ) ;
1533- expect ( maxWidth ) . toBe ( 500 ) ;
1534- } ) ;
1535-
1536- it ( 'should use custom width as maxWidth when maxWidth is not specified' , async ( ) => {
1537- const { scheduler, POM } = await createScheduler ( {
1538- ...getDefaultConfig ( ) ,
1539- editing : {
1540- allowAdding : true ,
1541- allowUpdating : true ,
1542- popup : {
1543- width : 600 ,
1544- } ,
1545- } ,
1546- } ) ;
1547-
1548- scheduler . showAppointmentPopup ( commonAppointment ) ;
1549-
1550- const width = POM . popup . component . option ( 'width' ) ;
1551- expect ( width ) . toBe ( 600 ) ;
1552-
1553- const maxWidth = POM . popup . component . option ( 'maxWidth' ) ;
1554- expect ( maxWidth ) . toBe ( 600 ) ;
1555- } ) ;
1556-
1557- it ( 'should use maxWidth option value (not width) for maxWidth when both maxWidth and width are specified' , async ( ) => {
1558- const { scheduler, POM } = await createScheduler ( {
1559- ...getDefaultConfig ( ) ,
1560- editing : {
1561- allowAdding : true ,
1562- allowUpdating : true ,
1563- popup : {
1564- width : 600 ,
1565- maxWidth : 500 ,
1566- } ,
1567- } ,
1568- } ) ;
1569-
1570- scheduler . showAppointmentPopup ( commonAppointment ) ;
1571-
1572- const width = POM . popup . component . option ( 'width' ) ;
1573- expect ( width ) . toBe ( 600 ) ;
1574-
1575- const maxWidth = POM . popup . component . option ( 'maxWidth' ) ;
1576- expect ( maxWidth ) . toBe ( 500 ) ;
1577- } ) ;
1578- } ) ;
15791237 } ) ;
15801238} ) ;
15811239
0 commit comments