11describe ( 'Plan creation flow' , ( ) => {
2- before ( 'Setup' , ( ) => {
2+ beforeEach ( 'Setup' , ( ) => {
33 cy . resetDbAndLogin ( ) ;
44 cy . visit ( '/app/home' ) ;
55 } ) ;
66
77 const planName = "Mr. Bob's Plan" ;
88
99 it ( 'Create blank plan' , ( ) => {
10+ // Open add plan dropdown
11+ cy . task ( 'log' , 'Opening blank plan modal...' ) ;
12+ cy . dataTestId ( 'add-new-plan-btn' ) . click ( ) ;
13+ cy . dataTestId ( 'add-blank-plan-btn' ) . click ( ) ;
14+
15+ // Modal should be visible
16+ cy . dataTestId ( 'create-blank-plan-page' ) . then ( ( $el ) => Cypress . dom . isVisible ( $el ) ) ;
17+
18+ // Fill out plan creation form
19+ cy . task ( 'log' , 'Filling out plan creation form...' ) ;
20+ cy . dataTestId ( 'plan-name-input' ) . type ( planName ) ;
21+ cy . dataTestId ( 'major-autocomplete' ) . type ( 'Computer' ) ;
22+ cy . getDropdownOptions ( )
23+ . contains ( 'Computer Science' )
24+ . then ( ( $el ) => {
25+ cy . wrap ( $el . get ( 0 ) . innerText ) . as ( 'major' ) ;
26+ $el . click ( ) ;
27+ } ) ;
28+
29+ // Create plan without upload transcript
30+ cy . task ( 'log' , 'Creating plan...' ) ;
31+ cy . dataTestId ( 'create-plan-btn' ) . click ( ) ;
32+
33+ // Wait and verify redirect to plan
34+ cy . task ( 'log' , 'Verifying redirect...' ) ;
35+ cy . url ( { timeout : 20000 } ) . should ( 'include' , '/app/plans/' ) ;
36+
37+ // Check plan information
38+ cy . task ( 'log' , 'Verifying plan information' ) ;
39+ cy . get ( '@major' ) . then ( ( majorAlias ) => {
40+ // Check plan title
41+ cy . dataTestId ( 'plan-title' )
42+ . then ( ( $el ) => $el . text ( ) )
43+ . should ( 'eq' , planName ) ;
44+
45+ // Check plan major
46+ const major = `${ majorAlias } ` ; // Whack workaround
47+ cy . dataTestId ( 'plan-major' )
48+ . then ( ( $el ) => $el . text ( ) )
49+ . should ( 'eq' , major ) ;
50+ } ) ;
51+ } ) ;
52+
53+ it ( 'Create custom plan' , ( ) => {
1054 // Open add plan dropdown
1155 cy . task ( 'log' , 'Opening custom plan modal...' ) ;
1256 cy . dataTestId ( 'add-new-plan-btn' ) . click ( ) ;
@@ -26,9 +70,56 @@ describe('Plan creation flow', () => {
2670 $el . click ( ) ;
2771 } ) ;
2872
29- // Create plan without upload transcript
73+ // Create plan with uploading transcript
3074 cy . task ( 'log' , 'Creating plan...' ) ;
3175 cy . dataTestId ( 'next-btn' ) . click ( ) ;
76+ cy . dataTestId ( 'upload-transcript-btn' ) . click ( ) ;
77+
78+ cy . get ( 'input[type=file]' ) . selectFile ( 'cypress/data/dummytranscript.pdf' , { force : true } ) ;
79+ cy . dataTestId ( 'create-plan-btn' ) . click ( ) ;
80+
81+ // Wait and verify redirect to plan
82+ cy . task ( 'log' , 'Verifying redirect...' ) ;
83+ cy . url ( { timeout : 20000 } ) . should ( 'include' , '/app/plans/' ) ;
84+
85+ // Check plan information
86+ cy . task ( 'log' , 'Verifying plan information' ) ;
87+ cy . get ( '@major' ) . then ( ( majorAlias ) => {
88+ // Check plan title
89+ cy . dataTestId ( 'plan-title' )
90+ . then ( ( $el ) => $el . text ( ) )
91+ . should ( 'eq' , planName ) ;
92+
93+ // Check plan major
94+ const major = `${ majorAlias } ` ; // Whack workaround
95+ cy . dataTestId ( 'plan-major' )
96+ . then ( ( $el ) => $el . text ( ) )
97+ . should ( 'eq' , major ) ;
98+ } ) ;
99+ } ) ;
100+
101+ it ( 'Create template plan' , ( ) => {
102+ // Open add plan dropdown
103+ cy . task ( 'log' , 'Opening template plan modal...' ) ;
104+ cy . dataTestId ( 'add-new-plan-btn' ) . click ( ) ;
105+ cy . dataTestId ( 'add-template-plan-btn' ) . click ( ) ;
106+
107+ // Modal should be visible
108+ cy . dataTestId ( 'create-template-plan-page' ) . then ( ( $el ) => Cypress . dom . isVisible ( $el ) ) ;
109+
110+ // Fill out plan creation form
111+ cy . task ( 'log' , 'Filling out plan creation form...' ) ;
112+ cy . dataTestId ( 'plan-name-input' ) . type ( planName ) ;
113+ cy . dataTestId ( 'major-autocomplete' ) . type ( 'Computer' ) ;
114+ cy . getDropdownOptions ( )
115+ . contains ( 'Computer Science' )
116+ . then ( ( $el ) => {
117+ cy . wrap ( $el . get ( 0 ) . innerText ) . as ( 'major' ) ;
118+ $el . click ( ) ;
119+ } ) ;
120+
121+ // Create template plan without upload transcript
122+ cy . task ( 'log' , 'Creating plan...' ) ;
32123 cy . dataTestId ( 'create-plan-btn' ) . click ( ) ;
33124
34125 // Wait and verify redirect to plan
0 commit comments