 (def stonecutter-authorise-share-profile-button ".func--authorise-share-profile__button")
 (def stonecutter-delete-account-page-body ".func--delete-account-page")
 (def stonecutter-delete-account-button ".func--delete-account__button")
-(def stonecutter-profile-deleted-page-body ".func--profile-deleted-page")
 
 (def client-home-page-body ".func--home-page")
 (def client-poll-page-body ".func--poll-page")

    (go-to-delete-account)
    (confirm-delete-account)))

(defn logout-of-client-and-go-through-auth-flow-again-without-having-to-sign-in-again []
  (wd/click client-logout-link)
  (wait-for-selector client-home-page-body)
  (wd/click "button")
  (wait-for-selector stonecutter-authorise-page-body)
  (wd/click stonecutter-authorise-share-profile-button)
  (wait-for-selector client-poll-page-body))

(against-background

          (wd/current-url) => (contains "stonecutter-client.herokuapp.com/voting")
          (wd/page-source) => (contains "stonecutter-journey-test@tw.com"))

    (fact "logging out in client app and logging in again will skip sign in page
          and authorise page (repeats twice as there was a bug)"
          (logout-of-client-and-go-through-auth-flow-again-without-having-to-sign-in-or-authorise-app-again)
          (wd/current-url) => (contains "stonecutter-client.herokuapp.com/voting")
          (wd/page-source) => (contains "stonecutter-journey-test@tw.com")

          (logout-of-client-and-go-through-auth-flow-again-without-having-to-sign-in-or-authorise-app-again)
          (wd/current-url) => (contains "stonecutter-client.herokuapp.com/voting")
          (wd/page-source) => (contains "stonecutter-journey-test@tw.com"))

    (fact "can unshare profile card and then logging in to client app will require authorising the app again"
          ;; unshare profile card
          (wd/to "https://stonecutter.herokuapp.com/profile")
          (wait-for-selector stonecutter-profile-page-body)
          (screenshot "stonecutter_profile_with_client_app")
          (wd/click stonecutter-profile-unshare-profile-card-link)
          (wait-for-selector stonecutter-unshare-profile-card-page-body)
          (screenshot "stonecutter_unshare_profile_card")
          (wd/click stonecutter-unshare-profile-card-button)
          (wait-for-selector stonecutter-profile-page-body)
          (screenshot "stonecutter_profile_without_client_app")

          ;; login to client app
          (wd/to "https://stonecutter-client.herokuapp.com")
          (logout-of-client-and-click-sign-in-to-vote)
          (wait-for-selector stonecutter-authorise-page-body)
          (screenshot "stonecutter_authorisation_form_again")
          (wd/current-url) => (contains "stonecutter.herokuapp.com/authorisation")

          ;; authorise client app
          (wd/click stonecutter-authorise-share-profile-button)
          (wait-for-selector client-poll-page-body)
          (screenshot "client_voting_page_again")
          (wd/current-url) => (contains "stonecutter-client.herokuapp.com/voting")
          (wd/page-source) => (contains "stonecutter-journey-test@tw.com"))

