1
1
var APP_ID = '58fa312bea9bbd061b0ea8f3' ,
2
- BASE_URL = 'https://flat.io/ embed' ,
2
+ BASE_URL = 'https://flat- embed.com ' ,
3
3
PUBLIC_SCORE = '56ae21579a127715a02901a6' ;
4
4
5
5
// APP_ID = '58e90082688f3e99d1244f58';
6
- // BASE_URL = 'http://flat.dev :3000/embed';
7
- // PUBLIC_SCORE = '58f93f70874b3f526d3d45e0 ';
6
+ // BASE_URL = 'http://vincent.ovh :3000/embed';
7
+ // PUBLIC_SCORE = '5bcc8e5b32023d903fb5fb26 ';
8
8
9
9
describe ( 'Integration - Embed' , ( ) => {
10
10
describe ( 'Loading embed' , ( ) => {
@@ -115,7 +115,8 @@ describe('Integration - Embed', () => {
115
115
116
116
it ( 'should plug into an existing iframe' , ( done ) => {
117
117
var iframe = document . createElement ( 'iframe' ) ;
118
- iframe . setAttribute ( 'src' , BASE_URL + '/' + PUBLIC_SCORE + '?jsapi=true&appId=' + APP_ID ) ;
118
+ var baseUrl = BASE_URL || 'https://flat-embed.com' ;
119
+ iframe . setAttribute ( 'src' , baseUrl + '/' + PUBLIC_SCORE + '?jsapi=true&appId=' + APP_ID ) ;
119
120
document . body . appendChild ( iframe ) ;
120
121
121
122
var embed = new Flat . Embed ( iframe ) ;
@@ -142,6 +143,10 @@ describe('Integration - Embed', () => {
142
143
143
144
embed . getJSON ( ) . then ( ( json ) => {
144
145
assert . ok ( json [ 'score-partwise' ] ) ;
146
+ return embed . getFlatScoreMetadata ( ) ;
147
+ } )
148
+ . then ( ( meta ) => {
149
+ assert . equal ( meta . title , 'House of the Rising Sun' ) ;
145
150
container . parentNode . removeChild ( container ) ;
146
151
done ( ) ;
147
152
} ) ;
@@ -447,6 +452,10 @@ describe('Integration - Embed', () => {
447
452
assert . equal ( position . voiceIdx , 0 ) ;
448
453
assert . equal ( position . measureIdx , 0 ) ;
449
454
assert . equal ( position . noteIdx , 0 ) ;
455
+ assert . ok ( position . partUuid ) ;
456
+ assert . ok ( position . staffUuid ) ;
457
+ assert . ok ( position . measureUuid ) ;
458
+ assert . ok ( position . voiceUuid ) ;
450
459
container . parentNode . removeChild ( container ) ;
451
460
done ( ) ;
452
461
} )
@@ -510,13 +519,11 @@ describe('Integration - Embed', () => {
510
519
} ) ;
511
520
512
521
embed . setCursorPosition ( {
513
- partIdx : 0 ,
514
- staffIdx : 0 ,
515
- measureIdx : 2 ,
516
522
noteIdx : 1
517
523
} )
518
524
. catch ( ( error ) => {
519
- assert . equal ( error . message , '`voiceIdx` should be an integer' ) ;
525
+ assert . equal ( error . code , 'BadPartIdxError' ) ;
526
+ assert . equal ( error . message , 'There is no part at the index [undefined<undefined>].' ) ;
520
527
container . parentNode . removeChild ( container ) ;
521
528
done ( ) ;
522
529
} ) ;
@@ -537,12 +544,12 @@ describe('Integration - Embed', () => {
537
544
embed . setCursorPosition ( {
538
545
partIdx : 0 ,
539
546
staffIdx : 0 ,
540
- measureIdx : 2 ,
541
- noteIdx : 1.1 ,
547
+ measureIdx : true ,
548
+ noteIdx : 0 ,
542
549
voiceIdx : 0
543
550
} )
544
551
. catch ( ( error ) => {
545
- assert . equal ( error . message , '`noteIdx` should be an integer ' ) ;
552
+ assert . equal ( error . message , 'Parameter measureIdx should be a number, not boolean ' ) ;
546
553
container . parentNode . removeChild ( container ) ;
547
554
done ( ) ;
548
555
} ) ;
@@ -601,6 +608,18 @@ describe('Integration - Embed', () => {
601
608
assert . ok ( Number . isFinite ( zoom ) ) ;
602
609
assert . ok ( zoom >= 0.5 ) ;
603
610
assert . ok ( zoom < 3 ) ;
611
+ return embed . getAutoZoom ( ) ;
612
+ } )
613
+ . then ( ( autoZoom ) => {
614
+ assert . ok ( autoZoom ) ;
615
+ return embed . setAutoZoom ( false ) ;
616
+ } )
617
+ . then ( ( autoZoom ) => {
618
+ assert . ok ( ! autoZoom ) ;
619
+ return embed . getAutoZoom ( ) ;
620
+ } )
621
+ . then ( ( autoZoom ) => {
622
+ assert . ok ( ! autoZoom ) ;
604
623
container . parentNode . removeChild ( container ) ;
605
624
done ( ) ;
606
625
} ) ;
@@ -620,7 +639,7 @@ describe('Integration - Embed', () => {
620
639
} ) ;
621
640
622
641
embed . setZoom ( 2 , ( zoom ) => {
623
- assert . equal ( zoo , 2 ) ;
642
+ assert . equal ( zoom , 2 ) ;
624
643
done ( ) ;
625
644
} )
626
645
. then ( ( ) => {
@@ -672,11 +691,7 @@ describe('Integration - Embed', () => {
672
691
} ) ;
673
692
674
693
embed . on ( 'playbackPosition' , ( pos ) => {
675
- assert . equal ( pos . beat , 4 ) ;
676
- assert . equal ( pos . beatType , 4 ) ;
677
- assert . ok ( pos . tempo >= 60 ) ;
678
- assert . ok ( pos . timePerMeasure >= 1 ) ;
679
- assert . ok ( pos . currentMeasure >= 1 ) ; // 1 or 2? Event should be sent for first measure?
694
+ assert . ok ( pos . currentMeasure >= 0 , 'currentMeasure' ) ;
680
695
container . parentNode . removeChild ( container ) ;
681
696
done ( ) ;
682
697
} ) ;
@@ -729,181 +744,58 @@ describe('Integration - Embed', () => {
729
744
} ) ;
730
745
} ) ;
731
746
732
- describe ( 'Editor config' , ( ) => {
733
- it ( 'should fetch the viewer config' , ( done ) => {
734
- var container = document . createElement ( 'div' ) ;
735
- document . body . appendChild ( container ) ;
736
-
737
- var embed = new Flat . Embed ( container , {
738
- score : PUBLIC_SCORE ,
739
- baseUrl : BASE_URL ,
740
- embedParams : {
741
- appId : APP_ID ,
742
- controlsFloating : false ,
743
- branding : false
744
- }
745
- } ) ;
746
-
747
- embed . getEmbedConfig ( ) . then ( ( config ) => {
748
- assert . equal ( config . branding , false ) ;
749
- assert . equal ( config . controlsPlay , true ) ;
750
- assert . equal ( config . controlsFloating , false ) ;
751
- container . parentNode . removeChild ( container ) ;
752
- done ( ) ;
753
- } ) ;
754
- } ) ;
755
-
756
- it ( 'should use the edit mode and set a tools config' , ( done ) => {
757
- var container = document . createElement ( 'div' ) ;
758
- document . body . appendChild ( container ) ;
759
-
760
- var embed = new Flat . Embed ( container , {
761
- baseUrl : BASE_URL ,
762
- embedParams : {
763
- appId : APP_ID ,
764
- mode : 'edit' ,
765
- controlsFloating : false ,
766
- branding : false
767
- }
768
- } ) ;
769
-
770
- embed . setEditorConfig ( {
771
- noteMode : {
772
- durations : true ,
773
- tuplet : false
774
- } ,
775
- articulationMode : false
776
- } ) . then ( ( config ) => {
777
- assert . ok ( config . global ) ;
778
- assert . equal ( config . articulationMode , false ) ;
779
- assert . equal ( config . noteMode . durations , true ) ;
780
- assert . equal ( config . noteMode . tuplet , false ) ;
781
- container . parentNode . removeChild ( container ) ;
782
- done ( ) ;
783
- } ) . catch ( done ) ;
784
- } ) ;
785
- } ) ;
786
-
787
- describe ( 'Editor modifications' , ( ) => {
788
- it ( 'should make a modification, get the event and get the document updated' , ( done ) => {
789
- var container = document . createElement ( 'div' ) ;
790
- document . body . appendChild ( container ) ;
791
-
792
- var embed = new Flat . Embed ( container , {
793
- score : PUBLIC_SCORE ,
794
- baseUrl : BASE_URL ,
795
- embedParams : {
796
- appId : APP_ID ,
797
- mode : 'edit'
798
- }
799
- } ) ;
800
-
801
- embed . on ( 'edit' , ( operations ) => {
802
- assert . equal ( operations . length , 1 ) ;
803
- assert . equal ( operations [ 0 ] . name , 'action.SetTempo' ) ;
804
- assert . equal ( operations [ 0 ] . opts . startMeasureIdx , 0 ) ;
805
- assert . equal ( operations [ 0 ] . opts . stopMeasureIdx , 1 ) ;
806
- assert . deepEqual ( operations [ 0 ] . opts . tempo , {
807
- bpm : 142 ,
808
- qpm : 142 ,
809
- durationType : 3 ,
810
- nbDots : 0
811
- } ) ;
812
- } ) ;
813
-
814
- embed . edit ( [
815
- {
816
- name : 'action.SetTempo' ,
817
- opts : {
818
- startMeasureIdx : 0 ,
819
- stopMeasureIdx : 1 ,
820
- tempo : {
821
- bpm : 142 ,
822
- qpm : 142 ,
823
- durationType : 3 ,
824
- nbDots : 0
825
- }
826
- }
827
- }
828
- ] ) . then ( ( ) => {
829
- return embed . getJSON ( ) ;
830
- } ) . then ( ( json ) => {
831
- assert . equal ( json [ 'score-partwise' ] . part [ 0 ] . measure [ 0 ] . sound . $tempo , 142 ) ;
832
- container . parentNode . removeChild ( container ) ;
833
- done ( ) ;
834
- } ) . catch ( done ) ;
835
- } ) ;
836
-
837
- it ( 'should fail to edit with bad ops arguments (edit error)' , ( done ) => {
838
- var container = document . createElement ( 'div' ) ;
839
- document . body . appendChild ( container ) ;
840
-
841
- var embed = new Flat . Embed ( container , {
842
- score : PUBLIC_SCORE ,
843
- baseUrl : BASE_URL ,
844
- embedParams : {
845
- appId : APP_ID ,
846
- mode : 'edit'
847
- }
848
- } ) ;
849
-
850
- embed . edit ( [
851
- {
852
- name : 'action.SetTempo' ,
853
- opts : {
854
- startMeasureIdx : 0 ,
855
- stopMeasureIdx : 1000000 ,
856
- tempo : {
857
- bpm : 142 ,
858
- qpm : 142 ,
859
- durationType : 3 ,
860
- nbDots : 0
861
- }
862
- }
863
- }
864
- ] ) . then ( ( ) => {
865
- return done ( 'Should have fail' ) ;
866
- } ) . catch ( ( error ) => {
867
- assert . equal ( error . code , 'BadMeasureIdxError' ) ;
868
- assert . equal ( error . message , 'There is no measure at the index [1000000<number>].' ) ;
869
- container . parentNode . removeChild ( container ) ;
870
- done ( ) ;
871
- } )
872
- } ) ;
873
-
874
- it ( 'should fail to edit with bad ops arguments (bad ops format)' , ( done ) => {
875
- var container = document . createElement ( 'div' ) ;
876
- document . body . appendChild ( container ) ;
877
-
878
- var embed = new Flat . Embed ( container , {
879
- score : PUBLIC_SCORE ,
880
- baseUrl : BASE_URL ,
881
- embedParams : {
882
- appId : APP_ID ,
883
- mode : 'edit'
884
- }
885
- } ) ;
886
-
887
- embed . edit ( {
888
- name : 'action.SetTempo' ,
889
- opts : {
890
- startMeasureIdx : 0 ,
891
- stopMeasureIdx : 1000000 ,
892
- tempo : {
893
- bpm : 142 ,
894
- qpm : 142 ,
895
- durationType : 3 ,
896
- nbDots : 0
897
- }
898
- }
899
- } ) . then ( ( ) => {
900
- return done ( 'Should have fail' ) ;
901
- } ) . catch ( ( error ) => {
902
- assert . equal ( error . code , 'TypeError' ) ;
903
- assert . equal ( error . message , 'Operations must be an array of operations' ) ;
904
- container . parentNode . removeChild ( container ) ;
905
- done ( ) ;
906
- } )
907
- } ) ;
908
- } ) ;
747
+ // describe('Editor config', () => {
748
+ // it('should fetch the viewer config', (done) => {
749
+ // var container = document.createElement('div');
750
+ // document.body.appendChild(container);
751
+
752
+ // var embed = new Flat.Embed(container, {
753
+ // score: PUBLIC_SCORE,
754
+ // baseUrl: BASE_URL,
755
+ // embedParams: {
756
+ // appId: APP_ID,
757
+ // controlsFloating: false,
758
+ // branding: false
759
+ // }
760
+ // });
761
+
762
+ // embed.getEmbedConfig().then((config) => {
763
+ // assert.equal(config.branding, false);
764
+ // assert.equal(config.controlsPlay, true);
765
+ // assert.equal(config.controlsFloating, false);
766
+ // container.parentNode.removeChild(container);
767
+ // done();
768
+ // });
769
+ // });
770
+
771
+ // it('should use the edit mode and set a tools config', (done) => {
772
+ // var container = document.createElement('div');
773
+ // document.body.appendChild(container);
774
+
775
+ // var embed = new Flat.Embed(container, {
776
+ // baseUrl: BASE_URL,
777
+ // embedParams: {
778
+ // appId: APP_ID,
779
+ // mode: 'edit',
780
+ // controlsFloating: false,
781
+ // branding: false
782
+ // }
783
+ // });
784
+
785
+ // embed.setEditorConfig({
786
+ // noteMode: {
787
+ // durations: true,
788
+ // tuplet: false
789
+ // },
790
+ // articulationMode: false
791
+ // }).then((config) => {
792
+ // assert.ok(config.global);
793
+ // assert.equal(config.articulationMode, false);
794
+ // assert.equal(config.noteMode.durations, true);
795
+ // assert.equal(config.noteMode.tuplet, false);
796
+ // container.parentNode.removeChild(container);
797
+ // done();
798
+ // }).catch(done);
799
+ // });
800
+ // });
909
801
} ) ;
0 commit comments