itemengine-cypress-automation 1.0.350-feature-thinkSphere-01c175a.0 → 1.0.351-feature-thinkSphere-8768c9c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -435,4 +435,554 @@ Cypress.Commands.add('deleteItems', () => {
435
435
  itemReferenceIds.forEach((i) => {
436
436
  cy.deleteItem(i);
437
437
  });
438
+ });
439
+
440
+ Cypress.Commands.add('createThinkSphereItem', (itemName) => {
441
+ const token = window.localStorage.getItem('ngie_accessToken');
442
+ const firstName = window.localStorage.getItem('ngie_firstName');
443
+ const lastName = window.localStorage.getItem('ngie_lastName');
444
+ const userID = window.localStorage.getItem('ngie_userId');
445
+ var currentReferenceIds = [];
446
+ for (var i = 0; i < 1; i++) {
447
+ currentReferenceIds.push(uuid());
448
+ };
449
+ cy.log(currentReferenceIds)
450
+
451
+ cy.request({
452
+ headers: {
453
+ Authorization: `${token}`,
454
+ 'content-type': 'application/json',
455
+ },
456
+ method: 'POST',
457
+ url: `${Cypress.env('SANDBOX_GRAPHQL_SERVICES_URL')}/`,
458
+ body: [
459
+ {
460
+ "operationName": "generateSignedRequest",
461
+ "variables": {
462
+ "input": {
463
+ "service": "author",
464
+ "type": "item",
465
+ "userId": userID,
466
+ "requestPacket": {
467
+ "mode": "thinkSphereEdit",
468
+ "config": {
469
+ "itemEdit": {
470
+ "item": {
471
+ "back": false,
472
+ "save": {
473
+ "show": false,
474
+ "autoSave": true
475
+ },
476
+ "reference": {
477
+ "edit": true,
478
+ "show": false
479
+ },
480
+ "duplicate": {
481
+ "show": false
482
+ },
483
+ "responseMode": "all",
484
+ "title": {
485
+ "edit": true,
486
+ "show": true
487
+ },
488
+ "settings": {
489
+ "show": false,
490
+ "showPrintPreview": false,
491
+ "showScoring": false,
492
+ "showTags": false
493
+ }
494
+ },
495
+ "reviewItem": {
496
+ "back": true,
497
+ "duplicate": {
498
+ "show": false
499
+ },
500
+ "mode": {
501
+ "default": "preview",
502
+ "show": false
503
+ },
504
+ "reference": {
505
+ "show": false,
506
+ "edit": false
507
+ },
508
+ "title": {
509
+ "show": true,
510
+ "edit": true
511
+ },
512
+ "save": {
513
+ "show": true
514
+ },
515
+ "allowedItems": null,
516
+ "responseMode": "all"
517
+ },
518
+ "widget": {
519
+ "showPreviewRadioButtonsAndScore": true
520
+ }
521
+ },
522
+ "loaderType": "full-screen",
523
+ "isCustomLoader": true,
524
+ "customLoaderId": "globalLoader",
525
+ "isThinkSphereItem": true,
526
+ "theme": "theme1"
527
+ },
528
+ "user": {
529
+ "firstName": firstName,
530
+ "lastName": lastName,
531
+ "id": userID
532
+ },
533
+ "systemGeneratedItems": {
534
+ "referenceIds": [""]
535
+ }
536
+ },
537
+ "domain": domainName
538
+ }
539
+ },
540
+ "query": "query generateSignedRequest($input: GenerateSignedRequest) {\n generateSignedRequest(input: $input) {\n success\n signedRequest {\n authentication {\n timestamp\n domain\n consumerKey\n signature\n userId\n __typename\n }\n request\n __typename\n }\n __typename\n }\n}\n"
541
+ }
542
+ ]
543
+ }).then((resp) => {
544
+ if (resp.status.toString().startsWith('5') && retries > 0) {
545
+ cy.log('ENCOUNTERED A 5xx ERROR');
546
+ }
547
+
548
+ const request = resp.body[0].data.generateSignedRequest.signedRequest.request;
549
+ const authentication = resp.body[0].data.generateSignedRequest.signedRequest.authentication;
550
+ delete authentication.userId;
551
+ delete authentication.__typename;
552
+ delete request.__typename;
553
+ cy.request({
554
+ headers: {
555
+ Authorization: `${token}`,
556
+ 'content-type': 'application/json',
557
+ Origin: `${Cypress.env('SANDBOX_SERVICES_URL')}`
558
+ },
559
+ method: 'POST',
560
+ url: `${Cypress.env('SERVICES_URL')}${Cypress.env('GRAPHQL_URL')}/`,
561
+ body: {
562
+ "operationName": "setItem",
563
+ "variables": {
564
+ "input": {
565
+ "authentication": authentication,
566
+ "request": request,
567
+ "service": "author",
568
+ "userRequest": {
569
+ "referenceId": itemName,
570
+ "isNewVersion": false,
571
+ "isThinkSphereItem": true,
572
+ "metadata": [],
573
+ "questions": [
574
+ {
575
+ "serialNo": 1,
576
+ "referenceId": currentReferenceIds[0],
577
+ "correctResponse": [],
578
+ "instruction": "",
579
+ "isAutoScored": false,
580
+ "mappedCorrectResponse": [],
581
+ "defaultResponse": [],
582
+ "points": 0,
583
+ "scoringTypeId": 4,
584
+ "questionXml": "<assessmentItem xmlns=\"http://www.imsglobal.org/xsd/imsqti_v2p2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2p2.xsd\" identifier=\"thinkSphere\" title=\"Think Sphere Question\" timeDependent=\"false\"><responseDeclaration identifier=\"RESPONSE\" cardinality=\"single\" baseType=\"file\"/><outcomeDeclaration identifier=\"SCORE\" cardinality=\"single\" baseType=\"float\"/><itemBody><drawingInteraction responseIdentifier=\"RESPONSE\" height=\"3\" width=\"4\"><prompt>question instruction text</prompt></drawingInteraction></itemBody></assessmentItem>",
585
+ "typeId": 54,
586
+ "metadata": {
587
+ "acknowledgements": "",
588
+ "sampleAnswer": "",
589
+ "toolSettingsResourcesOrder": [
590
+ {
591
+ "resourceTypeId": 2,
592
+ "toolOrder": 3
593
+ },
594
+ {
595
+ "resourceTypeId": 3,
596
+ "toolOrder": 0
597
+ }
598
+ ]
599
+ },
600
+ "settings": {
601
+ "nonAccessible": false,
602
+ "fontSize": 1,
603
+ "canvasControls": [
604
+ {
605
+ "label": "Move",
606
+ "icon": "Bold",
607
+ "text": "Move",
608
+ "identifier": "move",
609
+ "value": "move",
610
+ "selected": true
611
+ },
612
+ {
613
+ "label": "Delete",
614
+ "icon": "Bold",
615
+ "text": "Delete",
616
+ "identifier": "delete",
617
+ "value": "delete",
618
+ "selected": true
619
+ },
620
+ {
621
+ "label": "Undo",
622
+ "icon": "Bold",
623
+ "text": "Undo",
624
+ "identifier": "undo",
625
+ "value": "undo",
626
+ "selected": true
627
+ },
628
+ {
629
+ "label": "Redo",
630
+ "icon": "Bold",
631
+ "text": "Redo",
632
+ "identifier": "redo",
633
+ "value": "redo",
634
+ "selected": true
635
+ },
636
+ {
637
+ "label": "Clear all",
638
+ "icon": "Bold",
639
+ "text": "Clear all",
640
+ "identifier": "clearAll",
641
+ "value": "clearAll",
642
+ "selected": true
643
+ }
644
+ ],
645
+ "canvasTools": [
646
+ {
647
+ "label": "Text",
648
+ "icon": "Bold",
649
+ "text": "Text",
650
+ "identifier": "text",
651
+ "value": "text",
652
+ "selected": true
653
+ },
654
+ {
655
+ "label": "Pen",
656
+ "icon": "Bold",
657
+ "text": "Pen",
658
+ "identifier": "pen",
659
+ "value": "pen",
660
+ "selected": true
661
+ },
662
+ {
663
+ "label": "Highlighter",
664
+ "icon": "Bold",
665
+ "text": "Highlighter",
666
+ "identifier": "highlighter",
667
+ "value": "highlighter",
668
+ "selected": true
669
+ },
670
+ {
671
+ "label": "Image",
672
+ "icon": "Bold",
673
+ "text": "Image",
674
+ "identifier": "image",
675
+ "value": "image",
676
+ "selected": true
677
+ },
678
+ {
679
+ "label": "Shapes",
680
+ "icon": "Bold",
681
+ "text": "Shapes",
682
+ "identifier": "shapes",
683
+ "value": "shapes",
684
+ "selected": true
685
+ },
686
+ {
687
+ "label": "Stamps",
688
+ "icon": "Bold",
689
+ "text": "Stamps",
690
+ "identifier": "stamps",
691
+ "value": "stamps",
692
+ "selected": true
693
+ },
694
+ {
695
+ "label": "Number bond",
696
+ "icon": "Bold",
697
+ "text": "Number bond",
698
+ "identifier": "numberBond",
699
+ "value": "numberBond",
700
+ "selected": false
701
+ },
702
+ {
703
+ "label": "Unifix Cube",
704
+ "icon": "Bold",
705
+ "text": "Unifix Cube",
706
+ "identifier": "unifixCube",
707
+ "value": "unifixCube",
708
+ "selected": false
709
+ },
710
+ {
711
+ "label": "Diagrams",
712
+ "icon": "Bold",
713
+ "text": "Diagrams",
714
+ "identifier": "diagrams",
715
+ "value": "diagrams",
716
+ "selected": false
717
+ },
718
+ {
719
+ "label": "Array",
720
+ "icon": "Bold",
721
+ "text": "Array",
722
+ "identifier": "array",
723
+ "value": "array",
724
+ "selected": false
725
+ },
726
+ {
727
+ "label": "Number line",
728
+ "icon": "Bold",
729
+ "text": "Number line",
730
+ "identifier": "numberLine",
731
+ "value": "numberLine",
732
+ "selected": false
733
+ },
734
+ {
735
+ "label": "Fraction bars",
736
+ "icon": "Bold",
737
+ "text": "Fraction bars",
738
+ "identifier": "fractionBars",
739
+ "value": "fractionBars",
740
+ "selected": false
741
+ },
742
+ {
743
+ "label": "Protractor",
744
+ "icon": "Bold",
745
+ "text": "Protractor",
746
+ "identifier": "protractor",
747
+ "value": "protractor",
748
+ "selected": false
749
+ },
750
+ {
751
+ "label": "Table",
752
+ "icon": "Bold",
753
+ "text": "Table",
754
+ "identifier": "table",
755
+ "value": "table",
756
+ "selected": false
757
+ },
758
+ {
759
+ "label": "Grids",
760
+ "icon": "Bold",
761
+ "text": "Grids",
762
+ "identifier": "grids",
763
+ "value": "grids",
764
+ "selected": false
765
+ },
766
+ {
767
+ "label": "Equation editor",
768
+ "icon": "Bold",
769
+ "text": "Equation editor",
770
+ "identifier": "equationEditor",
771
+ "value": "equationEditor",
772
+ "selected": false
773
+ },
774
+ {
775
+ "label": "Algebra tiles",
776
+ "icon": "Bold",
777
+ "text": "Algebra tiles",
778
+ "identifier": "algebraTiles",
779
+ "value": "algebraTiles",
780
+ "selected": false
781
+ }
782
+ ],
783
+ "defaultCanvasTool": "pen",
784
+ "sentenceFrames": [
785
+ {
786
+ "text": "The strategy I’m going to use is",
787
+ "selected": true,
788
+ "id": 1
789
+ },
790
+ {
791
+ "text": "First, I will",
792
+ "selected": true,
793
+ "id": 2
794
+ },
795
+ {
796
+ "text": "Then, I will",
797
+ "selected": true,
798
+ "id": 3
799
+ },
800
+ {
801
+ "text": "I will check my work by",
802
+ "selected": true,
803
+ "id": 4
804
+ },
805
+ {
806
+ "text": "If my strategy is not working, I will",
807
+ "selected": true,
808
+ "id": 5
809
+ }
810
+ ],
811
+ "strategies": [
812
+ {
813
+ "text": "The strategy I’m going to use is",
814
+ "selected": true,
815
+ "id": 1
816
+ },
817
+ {
818
+ "text": "Look for a pattern",
819
+ "selected": true,
820
+ "id": 2
821
+ },
822
+ {
823
+ "text": "Guess, check, and revise",
824
+ "selected": true,
825
+ "id": 3
826
+ },
827
+ {
828
+ "text": "Try with friendlier numbers",
829
+ "selected": true,
830
+ "id": 4
831
+ },
832
+ {
833
+ "text": "Show with an equation",
834
+ "selected": true,
835
+ "id": 5
836
+ }
837
+ ],
838
+ "backgroundImg": {
839
+ "type": "",
840
+ "uploadUrl": "",
841
+ "width": "",
842
+ "height": "",
843
+ "name": "",
844
+ "originalName": ""
845
+ }
846
+ },
847
+ "content": {
848
+ "questionItemInstruction": "question instruction text"
849
+ },
850
+ "penaltyPoints": null,
851
+ "minScoreIfAttempted": null,
852
+ "teacherGuideline": "",
853
+ "scoringGuidance": "",
854
+ "sampleResponse": "",
855
+ "resources": []
856
+ }
857
+ ],
858
+ "resources": [],
859
+ "statusId": 1,
860
+ "version": 1
861
+ }
862
+ }
863
+ },
864
+ "query": "mutation setItem($input: SetItemInput) {\n setItem(input: $input) {\n success\n statusCode\n message\n data {\n settings\n id\n version\n contentVersion\n contentId\n title\n statusId\n instruction\n description\n authorName\n createdAt\n updatedAt\n createdBy\n referenceId\n questionId\n questionTags {\n id\n name\n type\n __typename\n }\n metadata {\n id\n metaKey\n metaKeyValue\n __typename\n }\n questions {\n id\n instruction\n points\n typeId\n questionXml\n referenceId\n updatedAt\n createdBy\n scoringTypeId\n teacherGuideline\n penaltyPoints\n minScoreIfAttempted\n minScoreType\n penaltyPointType\n isAutoPenaltySetting\n isNegativeRounded\n specificPenaltyType\n penaltyPointsForEach\n isAutoScored\n createdAt\n scoringGuidance\n sampleResponse\n resources {\n id\n name\n referenceId\n resourceTypeId\n metadata\n settings\n content\n type\n isCustomResource\n __typename\n }\n type {\n id\n name\n __typename\n }\n serialNo\n metadata\n correctResponse {\n id\n questionPartId\n xmlIdentifier\n mappedKey\n isCaseSensitive\n answerSetId\n alternateId\n __typename\n }\n mappedCorrectResponse {\n id\n questionPartId\n mappedKey\n mappedValue\n xmlIdentifier\n answerSetId\n alternateId\n __typename\n }\n defaultResponse {\n id\n questionPartId\n xmlIdentifier\n responseText\n __typename\n }\n answerSets {\n id\n points\n cellFillCount\n matchPositionOfSelectedCells\n __typename\n }\n __typename\n }\n resources {\n id\n name\n referenceId\n resourceTypeId\n serialNo\n metadata\n createdAt\n updatedAt\n createdBy\n resourceList {\n id\n name\n referenceId\n resourceTypeId\n metadata\n settings\n content\n type\n isCustomResource\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}\n"
865
+ }
866
+ }).then((resp) => {
867
+ if (resp.status.toString().startsWith('5') && retries > 0) {
868
+ cy.log('ENCOUNTERED A 5xx ERROR');
869
+ }
870
+ var currCreatedAndUpdatedAtDate = [];
871
+ currCreatedAndUpdatedAtDate.push(resp.body.data.setItem.data.createdAt);
872
+ currCreatedAndUpdatedAtDate.push(resp.body.data.setItem.data.updatedAt);
873
+ createdAndUpdatedAtDate.push(currCreatedAndUpdatedAtDate);
874
+ questionAndResourceReferenceIds.push(currentReferenceIds);
875
+ itemReferenceIds.push(itemName);
876
+ cy.log(createdAndUpdatedAtDate);
877
+ cy.log(questionAndResourceReferenceIds);
878
+ cy.log(itemReferenceIds);
879
+ });
880
+ });
881
+ });
882
+
883
+
884
+ Cypress.Commands.add('deleteThinkSphereItem', (itemName) => {
885
+ const token = window.localStorage.getItem('ngie_accessToken');
886
+ const firstName = window.localStorage.getItem('ngie_firstName');
887
+ const lastName = window.localStorage.getItem('ngie_lastName');
888
+ const userID = window.localStorage.getItem('ngie_userId');
889
+
890
+ cy.request({
891
+ headers: {
892
+ Authorization: `${token}`,
893
+ 'content-type': 'application/json',
894
+ },
895
+ method: 'POST',
896
+ url: `${Cypress.env('SANDBOX_GRAPHQL_SERVICES_URL')}/`,
897
+ body: [
898
+ {
899
+ "operationName": "generateSignedRequest",
900
+ "variables": {
901
+ "input": {
902
+ "service": "author",
903
+ "type": "item",
904
+ "userId": userID,
905
+ "requestPacket": {
906
+ "mode": "thinkSphereItemList",
907
+ "config": {
908
+ "loaderType": "full-screen",
909
+ "itemList": {
910
+ "limit": 20,
911
+ "toolbar": {
912
+ "add": true
913
+ },
914
+ "filter": {
915
+ "enableFilter": true,
916
+ "filterBackdrop": "div",
917
+ "showFilterPopup": false
918
+ },
919
+ "actions": {
920
+ "showActionsColumn": true,
921
+ "options": [
922
+ {
923
+ "id": "delete",
924
+ "label": "Delete"
925
+ },
926
+ {
927
+ "id": "duplicate",
928
+ "label": "Duplicate/New Version"
929
+ }
930
+ ]
931
+ }
932
+ },
933
+ "isCustomLoader": true,
934
+ "customLoaderId": "globalLoader"
935
+ },
936
+ "user": {
937
+ "firstName": firstName,
938
+ "lastName": lastName,
939
+ "id": userID
940
+ },
941
+ "systemGeneratedItems": {
942
+ "referenceIds": [""]
943
+ }
944
+ },
945
+ "domain": domainName
946
+ }
947
+ },
948
+ "query": "query generateSignedRequest($input: GenerateSignedRequest) {\n generateSignedRequest(input: $input) {\n success\n signedRequest {\n authentication {\n timestamp\n domain\n consumerKey\n signature\n userId\n __typename\n }\n request\n __typename\n }\n __typename\n }\n}\n"
949
+ }
950
+ ]
951
+ }).then((resp) => {
952
+ if (resp.status.toString().startsWith('5') && retries > 0) {
953
+ cy.log('ENCOUNTERED A 5xx ERROR');
954
+ }
955
+ const currRequest = resp.body[0].data.generateSignedRequest.signedRequest.request;
956
+ const currAuthentication = resp.body[0].data.generateSignedRequest.signedRequest.authentication;
957
+ delete currAuthentication.userId;
958
+ delete currAuthentication.__typename;
959
+ delete currRequest.__typename;
960
+ cy.request({
961
+ headers: {
962
+ Authorization: `${token}`,
963
+ 'content-type': "application/json",
964
+ Origin: `${Cypress.env('SANDBOX_SERVICES_URL')}`,
965
+ },
966
+ method: 'POST',
967
+ url: `${Cypress.env('SERVICES_URL')}${Cypress.env('GRAPHQL_URL')}/`,
968
+ body: {
969
+ "operationName": "deleteItem",
970
+ "variables": {
971
+ "input": {
972
+ "authentication": currAuthentication,
973
+ "request": currRequest,
974
+ "service": "author",
975
+ "userRequest": {
976
+ "itemReference": `${itemName}`
977
+ }
978
+ }
979
+ },
980
+ "query": "mutation deleteItem($input: DeleteItemInput) {\n deleteItem(input: $input) {\n message\n success\n __typename\n }\n}\n"
981
+ }
982
+ }).then((resp) => {
983
+ if (resp.status.toString().startsWith('5') && retries > 0) {
984
+ cy.log('ENCOUNTERED A 5xx ERROR');
985
+ }
986
+ });
987
+ });
438
988
  });
@@ -23,6 +23,17 @@ const utilities = {
23
23
  return null;
24
24
  },
25
25
 
26
+ /**
27
+ * @description verify the contain text of an element
28
+ * @param {*} selector cy.get selector
29
+ * @param {string} text contain text string
30
+ * @returns null
31
+ */
32
+ verifyContainText: (selector, text) => {
33
+ selector.should('contain.text', text);
34
+ return null;
35
+ },
36
+
26
37
  /**
27
38
  * @description get the nth element with the same selector, needs to be stored in appropriate named variables and passed into the methods
28
39
  * @param {*} selector cy.get selector
@@ -81,6 +92,49 @@ const utilities = {
81
92
  }
82
93
  },
83
94
 
95
+ /**
96
+ * @description verify multiple states of an element- 'visible'| 'hidden' | 'exist' | 'notExist'
97
+ * @param {*} selector cy.get selector
98
+ * @param {string} state state 'visible'| 'hidden' | 'exist' | 'notExist'
99
+ * @param {object} option options to pass to the should method
100
+ */
101
+ verifyElementVisibilityStateWithOption: (selector, state, option) => {
102
+ switch (state) {
103
+ case 'visible':
104
+ selector.should('be.visible', option);
105
+ break;
106
+ case 'hidden':
107
+ selector.should('not.be.visible', option);
108
+ break;
109
+ case 'exist':
110
+ selector.should('exist', option);
111
+ break;
112
+ case 'notExist':
113
+ selector.should('not.exist', option);
114
+ break;
115
+ default:
116
+ throw new Error('invalid state string');
117
+ }
118
+ },
119
+
120
+ /**
121
+ * @description verify multiple states of an element- 'checked' | 'notChecked'
122
+ * @param {*} selector cy.get selector
123
+ * @param {string} state state 'checked' | 'notChecked'
124
+ */
125
+ verifyElementCheckedNotCheckedState: (selector, state) => {
126
+ switch (state) {
127
+ case 'checked':
128
+ selector.should('be.checked');
129
+ break;
130
+ case 'notChecked':
131
+ selector.should('not.be.checked');
132
+ break;
133
+ default:
134
+ throw new Error('invalid state string');
135
+ }
136
+ },
137
+
84
138
  /**
85
139
  * @description scroll element into view
86
140
  * @param {*} selector cy.get selector
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itemengine-cypress-automation",
3
- "version": "1.0.350-feature-thinkSphere-01c175a.0",
3
+ "version": "1.0.351-feature-thinkSphere-8768c9c.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {