itemengine-cypress-automation 1.0.555-IEI-5835-LIVE-a798850.0 → 1.0.555-IEI-7011-1ad4f1a.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { singleSelectionPage } from "../../../pages/singleSelectionPage";
|
|
2
2
|
import abortEarlySetup from "../../../support/helpers/abortEarly";
|
|
3
3
|
const css = Cypress.env('css');
|
|
4
|
+
const alternativeAnswerCheck = Cypress.env('ENABLE_ALTERNATIVE_ANSWER_ENHANCEMENT');
|
|
4
5
|
|
|
5
6
|
const options = ['Pollution caused by treating chemical waste', 'Pollution caused by cement production', 'Pollution caused by methane production', 'Pollution caused by cement and methane production'];
|
|
6
7
|
|
|
@@ -49,6 +50,9 @@ describe('Create item page - Single selection: All or nothing with alternative a
|
|
|
49
50
|
singleSelectionPage.steps.verifyCorrectIncorrectAnswerLabel('correct');
|
|
50
51
|
singleSelectionPage.steps.verifyCorrectIncorrectBorderNotExists();
|
|
51
52
|
singleSelectionPage.steps.verifyCorrectAnswerSectionNotExist();
|
|
53
|
+
if (alternativeAnswerCheck === 'true') {
|
|
54
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleNotExists();
|
|
55
|
+
}
|
|
52
56
|
//singleSelectionPage.steps.verifyQuestionPreviewStateWhenSwitchingBackToStudentView();
|
|
53
57
|
/*cy.log('When the user has attempted the question with responses from the correct accordion and clicks on \'Check answer\' button, then correct icons should be displayed besides correct responses, correct answer border and a label should not be displayed below the question preview')
|
|
54
58
|
singleSelectionPage.steps.checkAnswer();
|
|
@@ -96,6 +100,10 @@ describe('Create item page - Single selection: All or nothing with alternative a
|
|
|
96
100
|
singleSelectionPage.steps.verifyIncorrectOptionIconStudentView(3);
|
|
97
101
|
singleSelectionPage.steps.verifyCorrectIncorrectAnswerLabel('incorrect');
|
|
98
102
|
singleSelectionPage.steps.verifyCorrectIncorrectBorderNotExists();
|
|
103
|
+
//show alternative answers
|
|
104
|
+
if (alternativeAnswerCheck === 'true') {
|
|
105
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleFunctionality(1, 10);
|
|
106
|
+
}
|
|
99
107
|
//correct answer section
|
|
100
108
|
singleSelectionPage.steps.verifyCorrectOptionIconCorrectAnswerSection(1);
|
|
101
109
|
//singleSelectionPage.steps.verifyQuestionPreviewStateWhenSwitchingBackToStudentView();
|
|
@@ -215,6 +223,10 @@ describe('Create item page - Single selection: All or nothing with alternative a
|
|
|
215
223
|
singleSelectionPage.steps.verifyCorrectIncorrectIconNotVisibleStudentView(3);
|
|
216
224
|
singleSelectionPage.steps.verifyCorrectIncorrectAnswerLabel('incorrect');
|
|
217
225
|
singleSelectionPage.steps.verifyCorrectIncorrectBorderNotExists();
|
|
226
|
+
//show alternative answers
|
|
227
|
+
if (alternativeAnswerCheck === 'true') {
|
|
228
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleFunctionality(1, 10);
|
|
229
|
+
}
|
|
218
230
|
//correct answer section
|
|
219
231
|
singleSelectionPage.steps.verifyCorrectOptionIconCorrectAnswerSection(2);
|
|
220
232
|
singleSelectionPage.steps.verifyQuestionPreviewStateWhenSwitchingBackToStudentView();
|
|
@@ -314,6 +326,10 @@ describe('Create item page - Single selection: All or nothing with alternative a
|
|
|
314
326
|
singleSelectionPage.steps.verifyCorrectIncorrectIconNotVisibleStudentView(3);
|
|
315
327
|
singleSelectionPage.steps.verifyCorrectIncorrectAnswerLabel('incorrect');
|
|
316
328
|
singleSelectionPage.steps.verifyCorrectIncorrectBorderNotExists();
|
|
329
|
+
//show alternative answers
|
|
330
|
+
if (alternativeAnswerCheck === 'true') {
|
|
331
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleFunctionality(1, 20);
|
|
332
|
+
}
|
|
317
333
|
//correct answer section
|
|
318
334
|
singleSelectionPage.steps.verifyCorrectOptionIconCorrectAnswerSection(1);
|
|
319
335
|
singleSelectionPage.steps.verifyQuestionPreviewStateWhenSwitchingBackToStudentView();
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { singleSelectionPage } from "../pages/singleSelectionPage";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Example usage of the "Show alternative answers" toggle methods
|
|
5
|
+
* This demonstrates how to verify the presence and functionality of the toggle component
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
describe('Show Alternative Answers Toggle - Example Usage', () => {
|
|
9
|
+
before(() => {
|
|
10
|
+
cy.loginAs('admin');
|
|
11
|
+
// Navigate to a single selection question with alternative answers
|
|
12
|
+
singleSelectionPage.steps.navigateToCreateQuestion('single selection');
|
|
13
|
+
cy.barsPreLoaderWait();
|
|
14
|
+
|
|
15
|
+
// Set up a question with alternative answers
|
|
16
|
+
singleSelectionPage.steps.addTextInQuestionInstructionsInputField('Which of the following is the major contributor to increased carbon dioxide levels because of urbanization? Select your answer from the options below.');
|
|
17
|
+
const options = ['Pollution caused by treating chemical waste', 'Pollution caused by cement production', 'Pollution caused by methane production', 'Pollution caused by cement and methane production'];
|
|
18
|
+
singleSelectionPage.steps.addInputToOptionsInputField(options);
|
|
19
|
+
singleSelectionPage.steps.checkOptionInSpecifyCorrectAnswerSection(1);
|
|
20
|
+
singleSelectionPage.steps.allotPoints(20);
|
|
21
|
+
singleSelectionPage.steps.clickOnAddAlternativeAnswerButton();
|
|
22
|
+
singleSelectionPage.steps.allotPoints(10);
|
|
23
|
+
singleSelectionPage.steps.checkOptionInSpecifyCorrectAnswerSection(2);
|
|
24
|
+
singleSelectionPage.steps.switchToPreviewTab();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('Should verify the "Show alternative answers" toggle exists and has correct label', () => {
|
|
28
|
+
// Verify the toggle component is present with correct label
|
|
29
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleExists();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('Should verify the toggle is initially unchecked', () => {
|
|
33
|
+
// Verify the toggle starts in unchecked state
|
|
34
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleUnchecked();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('Should be able to click the toggle to enable it', () => {
|
|
38
|
+
// Click the toggle to enable it
|
|
39
|
+
singleSelectionPage.steps.clickShowAlternativeAnswersToggle();
|
|
40
|
+
|
|
41
|
+
// Verify it's now checked
|
|
42
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleChecked();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Should be able to click the toggle to disable it', () => {
|
|
46
|
+
// Click the toggle again to disable it
|
|
47
|
+
singleSelectionPage.steps.clickShowAlternativeAnswersToggle();
|
|
48
|
+
|
|
49
|
+
// Verify it's now unchecked
|
|
50
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleUnchecked();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('Should verify complete toggle functionality', () => {
|
|
54
|
+
// Test the complete functionality in one method
|
|
55
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleFunctionality();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('Should enable toggle if currently disabled', () => {
|
|
59
|
+
// Ensure toggle is enabled (will click only if currently disabled)
|
|
60
|
+
singleSelectionPage.steps.enableShowAlternativeAnswersToggle();
|
|
61
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleChecked();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('Should disable toggle if currently enabled', () => {
|
|
65
|
+
// Ensure toggle is disabled (will click only if currently enabled)
|
|
66
|
+
singleSelectionPage.steps.disableShowAlternativeAnswersToggle();
|
|
67
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleUnchecked();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('Should verify alternative answers section when incorrectly answered', () => {
|
|
71
|
+
// Answer the question incorrectly to trigger alternative answers display
|
|
72
|
+
singleSelectionPage.steps.checkOptionInPreviewTab(0);
|
|
73
|
+
singleSelectionPage.steps.switchToGradingView();
|
|
74
|
+
|
|
75
|
+
// Verify the alternative answers section is visible
|
|
76
|
+
singleSelectionPage.steps.verifyAlternativeAnswersSection();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -42,6 +42,16 @@ const selectors = {
|
|
|
42
42
|
correctIncorrectAnswerLabel: () => cy.get('[class*="style"][class*="__Status"]'),
|
|
43
43
|
answerStatusBanner: () => cy.get('[class*="StatusContainer"]'),
|
|
44
44
|
optionsInputFieldInQuestionPreviewTab: () => cy.get('.mcq-radio-control [data-testid="question-instruction-element"]'),
|
|
45
|
+
//Show alternative answers toggle
|
|
46
|
+
showAlternativeAnswersToggleWrapper: () => cy.get('[class*="ShowAlternativeAnswerSwitch"][class*="SwitchWrapper"]'),
|
|
47
|
+
showAlternativeAnswersToggleInput: () => cy.get('[class*="ShowAlternativeAnswerSwitch"][class*="SwitchWrapper"] input[type="checkbox"]'),
|
|
48
|
+
showAlternativeAnswersToggleLabel: () => cy.get('[class*="ShowAlternativeAnswerSwitch"][class*="SwitchWrapper"] [class*="SwitchLabelWrapper"]'),
|
|
49
|
+
showAlternativeAnswersToggleButton: () => cy.get('[class*="ShowAlternativeAnswerSwitch"][class*="SwitchWrapper"] .MuiButtonBase-root'),
|
|
50
|
+
//Alternative answers content section
|
|
51
|
+
alternativeAnswersSection: () => cy.get('[class*="CorrectAnswerLabelWrapper"]').contains('Alternative answer'),
|
|
52
|
+
alternativeAnswerLabelWrapper: () => cy.get('[class*="CorrectAnswerLabelWrapper"]:contains("Alternative answer")'),
|
|
53
|
+
alternativeAnswerGridWrapper: () => cy.get('[class*="CorrectAnswerGridWrapper"]'),
|
|
54
|
+
alternativeAnswerSelectionGrid: () => cy.get('.correct-ans-selection-grid'),
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
const steps = {
|
|
@@ -728,6 +738,152 @@ const steps = {
|
|
|
728
738
|
singleSelectionPage.steps.setCorrectAnswer(correctAnswer);
|
|
729
739
|
singleSelectionPage.saveQuestionButton().click();
|
|
730
740
|
},
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Verifies that the "Show alternative answers" toggle is present and visible
|
|
744
|
+
*/
|
|
745
|
+
verifyShowAlternativeAnswersToggleExists: () => {
|
|
746
|
+
singleSelectionPage.showAlternativeAnswersToggleWrapper()
|
|
747
|
+
.should('be.visible');
|
|
748
|
+
singleSelectionPage.showAlternativeAnswersToggleLabel()
|
|
749
|
+
.should('contain.text', 'Show alternative answers');
|
|
750
|
+
},
|
|
751
|
+
|
|
752
|
+
verifyShowAlternativeAnswersToggleNotExists: () => {
|
|
753
|
+
singleSelectionPage.showAlternativeAnswersToggleWrapper()
|
|
754
|
+
.should('not.exist');
|
|
755
|
+
},
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Verifies that the "Show alternative answers" toggle is in the checked (enabled) state
|
|
759
|
+
*/
|
|
760
|
+
verifyShowAlternativeAnswersToggleChecked: () => {
|
|
761
|
+
singleSelectionPage.showAlternativeAnswersToggleInput()
|
|
762
|
+
.should('be.checked')
|
|
763
|
+
.and('have.attr', 'aria-pressed', 'true');
|
|
764
|
+
// Verify the checked state visual indicator (tick icon)
|
|
765
|
+
singleSelectionPage.showAlternativeAnswersToggleWrapper()
|
|
766
|
+
.find('.icon-ILC-tick-icon')
|
|
767
|
+
.should('be.visible');
|
|
768
|
+
},
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Verifies that the "Show alternative answers" toggle is in the unchecked (disabled) state
|
|
772
|
+
*/
|
|
773
|
+
verifyShowAlternativeAnswersToggleUnchecked: () => {
|
|
774
|
+
singleSelectionPage.showAlternativeAnswersToggleInput()
|
|
775
|
+
.should('not.be.checked')
|
|
776
|
+
.and('have.attr', 'aria-pressed', 'false');
|
|
777
|
+
// Verify the unchecked state visual indicator (x-circle icon)
|
|
778
|
+
singleSelectionPage.showAlternativeAnswersToggleWrapper()
|
|
779
|
+
.find('.icon-x-circle')
|
|
780
|
+
.should('be.visible');
|
|
781
|
+
},
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Clicks the "Show alternative answers" toggle to change its state
|
|
785
|
+
*/
|
|
786
|
+
clickShowAlternativeAnswersToggle: () => {
|
|
787
|
+
singleSelectionPage.showAlternativeAnswersToggleButton()
|
|
788
|
+
.click();
|
|
789
|
+
},
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Enables the "Show alternative answers" toggle (clicks it if it's currently unchecked)
|
|
793
|
+
*/
|
|
794
|
+
enableShowAlternativeAnswersToggle: () => {
|
|
795
|
+
singleSelectionPage.showAlternativeAnswersToggleInput()
|
|
796
|
+
.then(($input) => {
|
|
797
|
+
if (!$input.prop('checked')) {
|
|
798
|
+
singleSelectionPage.steps.clickShowAlternativeAnswersToggle();
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
},
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Disables the "Show alternative answers" toggle (clicks it if it's currently checked)
|
|
805
|
+
*/
|
|
806
|
+
disableShowAlternativeAnswersToggle: () => {
|
|
807
|
+
singleSelectionPage.showAlternativeAnswersToggleInput()
|
|
808
|
+
.then(($input) => {
|
|
809
|
+
if ($input.prop('checked')) {
|
|
810
|
+
singleSelectionPage.steps.clickShowAlternativeAnswersToggle();
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
},
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* Verifies that the alternative answers section is visible
|
|
818
|
+
*/
|
|
819
|
+
|
|
820
|
+
verifyAlternativeAnswersSectionVisible: (index, points) => {
|
|
821
|
+
// Build the expected points text: "(1 point)" or "(20 points)"
|
|
822
|
+
const pointsText = `(${points} point${points === 1 ? '' : 's'})`;
|
|
823
|
+
|
|
824
|
+
cy.get('[class*="CorrectAnswerLabelWrapper"]')
|
|
825
|
+
.eq(index) // pick the specific "Alternative answer" by index
|
|
826
|
+
.should('be.visible')
|
|
827
|
+
.should('contain.text', `Alternative answer ${index}`)
|
|
828
|
+
.should('contain.text', `(${points} pointsText)`); // check points
|
|
829
|
+
},
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Verifies that the alternative answers section does not exist
|
|
834
|
+
*/
|
|
835
|
+
verifyAlternativeAnswersSectionNotExist: () => {
|
|
836
|
+
cy.get('[class*="CorrectAnswerLabelWrapper"]')
|
|
837
|
+
.contains('Alternative answer')
|
|
838
|
+
.should('not.exist');
|
|
839
|
+
},
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Verifies the complete alternative answers section including content and grid
|
|
843
|
+
*/
|
|
844
|
+
verifyAlternativeAnswersSectionComplete: () => {
|
|
845
|
+
// Verify the alternative answer label is visible
|
|
846
|
+
singleSelectionPage.alternativeAnswersSection()
|
|
847
|
+
.should('be.visible');
|
|
848
|
+
|
|
849
|
+
// Verify the selection grid is visible
|
|
850
|
+
singleSelectionPage.alternativeAnswerSelectionGrid()
|
|
851
|
+
.should('be.visible');
|
|
852
|
+
|
|
853
|
+
// Verify points are displayed
|
|
854
|
+
cy.get('[class*="CorrectAnswerLabelWrapper"]')
|
|
855
|
+
.contains('Alternative answer')
|
|
856
|
+
.parent()
|
|
857
|
+
.find('p')
|
|
858
|
+
.should('contain.text', 'points');
|
|
859
|
+
},
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Verifies the toggle functionality by checking both states
|
|
864
|
+
*/
|
|
865
|
+
verifyShowAlternativeAnswersToggleFunctionality: (index, points) => {
|
|
866
|
+
// Start with ensuring toggle exists
|
|
867
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleExists();
|
|
868
|
+
|
|
869
|
+
// Test unchecked state
|
|
870
|
+
singleSelectionPage.steps.disableShowAlternativeAnswersToggle();
|
|
871
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleUnchecked();
|
|
872
|
+
|
|
873
|
+
// Verify the alternative answers section do not exist
|
|
874
|
+
singleSelectionPage.steps.verifyAlternativeAnswersSectionNotExist();
|
|
875
|
+
|
|
876
|
+
// Test checked state
|
|
877
|
+
singleSelectionPage.steps.clickShowAlternativeAnswersToggle();
|
|
878
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleChecked();
|
|
879
|
+
|
|
880
|
+
// Verify the alternative answers section is visible
|
|
881
|
+
singleSelectionPage.steps.verifyAlternativeAnswersSectionVisible(index, points);
|
|
882
|
+
|
|
883
|
+
// Test toggle back to unchecked
|
|
884
|
+
singleSelectionPage.steps.clickShowAlternativeAnswersToggle();
|
|
885
|
+
singleSelectionPage.steps.verifyShowAlternativeAnswersToggleUnchecked();
|
|
886
|
+
},
|
|
731
887
|
};
|
|
732
888
|
|
|
733
889
|
const tests = {
|
package/package.json
CHANGED
package/service.yaml
CHANGED
|
@@ -102,21 +102,29 @@ namespaces:
|
|
|
102
102
|
value: "dev"
|
|
103
103
|
- name: FILE_CONFIG
|
|
104
104
|
value: "dev"
|
|
105
|
+
- name: ENABLE_ALTERNATIVE_ANSWER_ENHANCEMENT
|
|
106
|
+
value: "false"
|
|
105
107
|
qa:
|
|
106
108
|
env:
|
|
107
109
|
- name: STAGE
|
|
108
110
|
value: "qa"
|
|
109
111
|
- name: FILE_CONFIG
|
|
110
112
|
value: "qa"
|
|
113
|
+
- name: ENABLE_ALTERNATIVE_ANSWER_ENHANCEMENT
|
|
114
|
+
value: "true"
|
|
111
115
|
staging:
|
|
112
116
|
env:
|
|
113
117
|
- name: STAGE
|
|
114
118
|
value: "stage"
|
|
115
119
|
- name: FILE_CONFIG
|
|
116
120
|
value: "stage"
|
|
121
|
+
- name: ENABLE_ALTERNATIVE_ANSWER_ENHANCEMENT
|
|
122
|
+
value: "false"
|
|
117
123
|
prod:
|
|
118
124
|
env:
|
|
119
125
|
- name: STAGE
|
|
120
126
|
value: "prod"
|
|
121
127
|
- name: FILE_CONFIG
|
|
122
|
-
value: "prod"
|
|
128
|
+
value: "prod"
|
|
129
|
+
- name: ENABLE_ALTERNATIVE_ANSWER_ENHANCEMENT
|
|
130
|
+
value: "false"
|