1+ const ERROR_MESSAGES = {
2+ ACCESS_DENIED : 'access denied' ,
3+ UNEXPECTED_ERROR : 'There was an unexpected error' ,
4+ } ;
5+
6+ const SELECTORS = {
7+ FLAVOR_CARD : '.pf-v6-c-card' ,
8+ CARD_TITLE : '.pf-v6-c-card__title' ,
9+ LABEL : '.pf-v6-c-label' ,
10+ FLAVOR_TOGGLE : 'input[name="flavor-filter-toggle"]' ,
11+ PAGE_HEADING : 'h2' ,
12+ } ;
13+
114describe ( 'Flavor Selection' , ( ) => {
215 beforeEach ( ( ) => {
316 // Authenticate for local development before visiting the page
@@ -7,41 +20,41 @@ describe('Flavor Selection', () => {
720
821 it ( 'should load the page without authentication errors' , ( ) => {
922 // Verify no error messages (confirms LOCAL_DEPLOY mode is working)
10- cy . get ( 'body' ) . should ( 'not.contain' , 'access denied' ) ;
11- cy . get ( 'body' ) . should ( 'not.contain' , 'There was an unexpected error' ) ;
23+ cy . get ( 'body' ) . should ( 'not.contain' , ERROR_MESSAGES . ACCESS_DENIED ) ;
24+ cy . get ( 'body' ) . should ( 'not.contain' , ERROR_MESSAGES . UNEXPECTED_ERROR ) ;
1225 } ) ;
1326
1427 it ( 'should display a list of available flavors' , ( ) => {
15- // Wait for flavors to load (check for either "My Flavors" or "All Flavors" title )
16- cy . contains ( 'h2' , / M y F l a v o r s | A l l F l a v o r s / ) . should ( 'be.visible' ) ;
28+ // Wait for the page heading to be visible (indicates page has loaded )
29+ cy . get ( SELECTORS . PAGE_HEADING ) . should ( 'be.visible' ) ;
1730
1831 // Verify that the flavor gallery is not empty
1932 // Each flavor is rendered as a LinkCard inside a GalleryItem
20- cy . get ( '.pf-v6-c-card' ) . should ( 'have.length.at.least' , 1 ) ;
33+ cy . get ( SELECTORS . FLAVOR_CARD ) . should ( 'have.length.at.least' , 1 ) ;
2134 } ) ;
2235
2336 it ( 'should display flavor details for each flavor card' , ( ) => {
2437 // Wait for flavors to load
25- cy . contains ( 'h2' , / M y F l a v o r s | A l l F l a v o r s / ) . should ( 'be.visible' ) ;
38+ cy . get ( SELECTORS . PAGE_HEADING ) . should ( 'be.visible' ) ;
2639
2740 // Get the first flavor card and verify it has required elements
28- cy . get ( '.pf-v6-c-card' )
41+ cy . get ( SELECTORS . FLAVOR_CARD )
2942 . first ( )
3043 . within ( ( ) => {
3144 // Each flavor card should have a name (header text)
32- cy . get ( '.pf-v6-c-card__title' ) . should ( 'exist' ) . and ( 'not.be.empty' ) ;
45+ cy . get ( SELECTORS . CARD_TITLE ) . should ( 'exist' ) . and ( 'not.be.empty' ) ;
3346
3447 // Each flavor card should have an availability label
35- cy . get ( '.pf-v6-c-label' ) . should ( 'exist' ) ;
48+ cy . get ( SELECTORS . LABEL ) . should ( 'exist' ) ;
3649 } ) ;
3750 } ) ;
3851
3952 it ( 'should have clickable flavor cards that navigate to launch page' , ( ) => {
4053 // Wait for flavors to load
41- cy . contains ( 'h2' , / M y F l a v o r s | A l l F l a v o r s / ) . should ( 'be.visible' ) ;
54+ cy . get ( SELECTORS . PAGE_HEADING ) . should ( 'be.visible' ) ;
4255
4356 // Click the first flavor card
44- cy . get ( '.pf-v6-c-card' ) . first ( ) . click ( ) ;
57+ cy . get ( SELECTORS . FLAVOR_CARD ) . first ( ) . click ( ) ;
4558
4659 // Verify navigation to launch page (URL should contain /launch/)
4760 cy . url ( ) . should ( 'include' , '/launch/' ) ;
@@ -50,24 +63,27 @@ describe('Flavor Selection', () => {
5063 cy . contains ( 'h1' , / L a u n c h / ) . should ( 'be.visible' ) ;
5164 } ) ;
5265
53- it ( 'should toggle between "My Flavors" and "All Flavors"' , ( ) => {
54- // Verify initial state
55- cy . contains ( 'h2' , 'My Flavors' ) . should ( 'be.visible' ) ;
56-
57- // Find and click the "Show All Flavors" toggle switch
58- // Use force:true because PatternFly switch has a visual element covering the input
59- cy . get ( 'input[name="flavor-filter-toggle"]' ) . click ( { force : true } ) ;
66+ it ( 'should toggle between flavor filter states' , ( ) => {
67+ // Get the initial heading text
68+ cy . get ( SELECTORS . PAGE_HEADING )
69+ . should ( 'be.visible' )
70+ . invoke ( 'text' )
71+ . then ( ( initialHeading ) => {
72+ // Find and click the flavor filter toggle switch
73+ // Use force:true because PatternFly switch has a visual element covering the input
74+ cy . get ( SELECTORS . FLAVOR_TOGGLE ) . click ( { force : true } ) ;
6075
61- // Verify the title changed to "All Flavors"
62- cy . contains ( 'h2' , 'All Flavors' ) . should ( 'be.visible' ) ;
76+ // Verify the heading text changed
77+ cy . get ( SELECTORS . PAGE_HEADING ) . invoke ( 'text' ) . should ( 'not.equal' , initialHeading ) ;
6378
64- // Verify URL parameter was updated
65- cy . url ( ) . should ( 'include' , 'showAllFlavors=true' ) ;
79+ // Verify URL parameter was updated
80+ cy . url ( ) . should ( 'include' , 'showAllFlavors=true' ) ;
6681
67- // Toggle back
68- cy . get ( 'input[name="flavor-filter-toggle"]' ) . click ( { force : true } ) ;
82+ // Toggle back
83+ cy . get ( SELECTORS . FLAVOR_TOGGLE ) . click ( { force : true } ) ;
6984
70- // Verify we're back to "My Flavors"
71- cy . contains ( 'h2' , 'My Flavors' ) . should ( 'be.visible' ) ;
85+ // Verify we're back to the original heading
86+ cy . get ( SELECTORS . PAGE_HEADING ) . invoke ( 'text' ) . should ( 'equal' , initialHeading ) ;
87+ } ) ;
7288 } ) ;
7389} ) ;
0 commit comments