import { SCREEN_SIZES , UTILS } from "../support/cypress-utils" ; /** ===========================================================================
 * Test app navigation
 * ============================================================================
 */ const visitSettingsPage = ( type ) => { if ( type . isMobile ( ) ) { UTILS . findAndClick ( "hamburger-menu-button" ) ; } UTILS . findAndClick ( "settings-navigation-link" ) ; cy . contains ( "Settings" ) ; cy . url ( ) . should ( "contain" , "/settings" ) ; } ; SCREEN_SIZES . forEach ( ( { type , size } ) => { describe ( `Test Dashboard Portfolio Routes, viewport: ${ size }` , ( ) => { beforeEach ( ( ) => { UTILS . setViewportSize ( size ) ; UTILS . loginWithAddress ( type , "celo" ) ; visitSettingsPage ( type ) ; } ) ; afterEach ( ( ) => { UTILS . logout ( type ) ; } ) ; /**
         * Test dark theme setting.
         */ it ( "Dark theme can be toggled on and off" , ( ) => { cy . get ( UTILS . find ( "settings-theme-switch" ) ) . should ( "not.be.checked" ) ; UTILS . findAndClick ( "settings-theme-switch" ) ; cy . get ( UTILS . find ( "settings-theme-switch" ) ) . should ( "be.checked" ) ; cy . reload ( ) ; cy . get ( UTILS . find ( "settings-theme-switch" ) ) . should ( "be.checked" ) ; UTILS . findAndClick ( "settings-theme-switch" ) ; cy . get ( UTILS . find ( "settings-theme-switch" ) ) . should ( "not.be.checked" ) ; } ) ; /**
         * Test fiat|crypto setting.
         */ it ( "Fiat|Crypto currency settings can be toggled" , ( ) => { UTILS . findAndClick ( "crypto-currency-setting-radio" ) ; cy . get ( UTILS . find ( "crypto-currency-setting-radio" ) ) . should ( "be.checked" ) ; cy . get ( UTILS . find ( "fiat-currency-setting-radio" ) ) . should ( "not.be.checked" ) ; cy . reload ( ) ; cy . get ( UTILS . find ( "crypto-currency-setting-radio" ) ) . should ( "be.checked" ) ; cy . get ( UTILS . find ( "fiat-currency-setting-radio" ) ) . should ( "not.be.checked" ) ; UTILS . findAndClick ( "fiat-currency-setting-radio" ) ; cy . get ( UTILS . find ( "fiat-currency-setting-radio" ) ) . should ( "be.checked" ) ; cy . get ( UTILS . find ( "crypto-currency-setting-radio" ) ) . should ( "not.be.checked" ) ; } ) ; /**
         * Test i18n setting.
         */ it ( "App i18n language option can be changed" , ( ) => { UTILS . shouldMatchText ( "settings-page-title" , "Anthem Settings" ) ; UTILS . findAndClick ( "settings-language-select-menu" ) ; UTILS . findAndClick ( "de-language-option" ) ; UTILS . shouldMatchText ( "settings-page-title" , "Anthem Einstellungen" ) ; cy . reload ( ) ; UTILS . shouldMatchText ( "settings-page-title" , "Anthem Einstellungen" ) ; UTILS . findAndClick ( "settings-language-select-menu" ) ; UTILS . findAndClick ( "en-US-language-option" ) ; UTILS . shouldMatchText ( "settings-page-title" , "Anthem Settings" ) ; } ) ; /**
         * Test display currency setting.
         */ it ( "App display currency option can be changed" , ( ) => { UTILS . findAndClick ( "settings-currency-select-menu" ) ; UTILS . findAndClick ( "KRW-currency-option" ) ; cy . get ( UTILS . find ( "fiat-currency-setting-radio" ) ) . parent ( ) . should ( "have.text" , "Korean Won" ) ; cy . reload ( ) ; cy . get ( UTILS . find ( "fiat-currency-setting-radio" ) ) . parent ( ) . should ( "have.text" , "Korean Won" ) ; UTILS . findAndClick ( "settings-currency-select-menu" ) ; UTILS . findAndClick ( "USD-currency-option" ) ; cy . get ( UTILS . find ( "fiat-currency-setting-radio" ) ) . parent ( ) . should ( "have.text" , "US Dollar" ) ; } ) ; /**
         * Test i18n setting.
         */ it . skip ( "Newsletter email signup" , ( ) => { /**
             * NOTE: stubbing requests does not work with the fetch API currently...
             *
             * Reference: https://github.com/cypress-io/cypress/issues/95
             */ cy . server ( ) ; cy . route ( "POST" , "**/newsletter" , "OK" ) ; const email = "sean@chorus.one" ; cy . get ( "[data-cy=settings-form-email-newsletter-input]" ) . type ( email ) ; cy . get ( "[data-cy=newsletter-signup-form]" ) . submit ( ) ; cy . get ( ".blueprint-toaster-bar > span" ) . should ( "have.text" , "Successfully signed up for the Chorus One newsletter. Please check your email for details." ) ; } ) ; } ) ; } ) ;