-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
114 additions
and
62 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
backend/test/swlkup/resolver/supervisors_deactivate_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
(ns swlkup.resolver.supervisors-deactivate-test | ||
(:require [clojure.test :refer [use-fixtures deftest is]] | ||
[mount.core :as mount] | ||
[swlkup.resolver.core :refer [->graphql]])) | ||
|
||
(def mail "[email protected]") | ||
(def password "i!A;z\\\"'^G3Q)w])%83)") | ||
|
||
(use-fixtures :once (fn [testcases] (mount/stop) (mount/start) (testcases) (mount/stop))) | ||
|
||
|
||
(deftest deactivate-wrong-login | ||
(let [graphql (->graphql)] | ||
|
||
(is (= (graphql {:query "mutation x($auth: Auth) { | ||
supervisor_deactivate(auth: $auth, deactivated: true)}" | ||
:variables {:auth {:mail mail :password "wrong"}}}) | ||
{:data {:supervisor_deactivate false}})) | ||
|
||
(is (= (graphql {:query "{lookup(token: \"R4nd0m\") {supervisors{name_full}}}"}) | ||
{:data {:lookup {:supervisors [{:name_full "Max Müller"}]}}})))) | ||
|
||
|
||
(deftest deactivate-correct-login | ||
(let [graphql (->graphql)] | ||
|
||
(is (= (graphql {:query "{lookup(token: \"R4nd0m\") {supervisors{name_full}}}"}) | ||
{:data {:lookup {:supervisors [{:name_full "Max Müller"}]}}})) | ||
|
||
(is (= (graphql {:query "mutation x($auth: Auth) { | ||
supervisor_deactivate(auth: $auth, deactivated: true)}" | ||
:variables {:auth {:mail mail :password password}}}) | ||
{:data {:supervisor_deactivate true}})) | ||
|
||
(is (= (graphql {:query "{lookup(token: \"R4nd0m\") {supervisors{name_full}}}"}) | ||
{:data {:lookup {:supervisors []}}})) | ||
|
||
;; There exist 2 mutations that can reactivate a profile (supervisor_update and supervisor_deactivate). | ||
;; Neither is security critical. | ||
|
||
(is (= (graphql {:query "mutation x($auth: Auth) { | ||
supervisor_deactivate(auth: $auth, deactivated: false)}" | ||
:variables {:auth {:mail mail :password password}}}) | ||
{:data {:supervisor_deactivate true}})) | ||
|
||
(is (= (graphql {:query "{lookup(token: \"R4nd0m\") {supervisors{name_full}}}"}) | ||
{:data {:lookup {:supervisors [{:name_full "Max Müller"}]}}})))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
(ns swlkup.resolver.supervisors-delete-test | ||
(:require [clojure.test :refer [use-fixtures deftest is]] | ||
[mount.core :as mount] | ||
[swlkup.resolver.core :refer [->graphql graphql]])) | ||
[swlkup.resolver.core :refer [->graphql]])) | ||
|
||
(def mail "[email protected]") | ||
(def password "i!A;z\\\"'^G3Q)w])%83)") | ||
(def supervisor_updated {:deactivated false | ||
:name_full "Max M. Müller" | ||
:languages ["de"] | ||
:ngos "any" #_["lifeline", "seawatch"] | ||
:offers ["counseling", "moderation"] | ||
:contacts {:phone "0123456789" | ||
:email "[email protected]" | ||
:website "https://praxis.mueller.de"} | ||
:location {:zip "01099"}}) | ||
|
||
(use-fixtures :once (fn [testcases] (mount/stop) (mount/start) (testcases) (mount/stop))) | ||
|
||
|
@@ -22,7 +13,7 @@ | |
(let [graphql (->graphql)] | ||
|
||
(is (= (graphql {:query "mutation x($auth: Auth) { | ||
supervisor_delete(auth: $auth, supervisor_input: $supervisor)}" | ||
supervisor_delete(auth: $auth)}" | ||
:variables {:auth {:mail mail :password "wrong"}}}) | ||
{:data {:supervisor_delete false}})) | ||
|
||
|
@@ -37,15 +28,9 @@ | |
{:data {:lookup {:supervisors [{:name_full "Max Müller"}]}}})) | ||
|
||
(is (= (graphql {:query "mutation x($auth: Auth) { | ||
supervisor_delete(auth: $auth, supervisor_input: $supervisor)}" | ||
supervisor_delete(auth: $auth)}" | ||
:variables {:auth {:mail mail :password password}}}) | ||
{:data {:supervisor_delete true}})) | ||
|
||
(is (= (graphql {:query "{lookup(token: \"R4nd0m\") {supervisors{name_full}}}"}) | ||
{:data {:lookup {:supervisors []}}})) | ||
|
||
(is (= (graphql {:query "mutation x($auth: Auth, $supervisor: SupervisorInput) { | ||
supervisor_update(auth: $auth, supervisor_input: $supervisor)}" | ||
:variables {:supervisor supervisor_updated | ||
:auth {:mail mail :password password}}}) | ||
{:data {:supervisor_update false}})))) | ||
{:data {:lookup {:supervisors []}}})))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
let token_url = "" // will be set once a new token was generated | ||
let supervisor_password = "" // will be set once a new supervisor was invited | ||
|
||
function login_supervisor() { | ||
cy.visit('/supervisor/edit') | ||
cy.get('form').within($form => { | ||
cy.get('input[name=mail]') | ||
.type("[email protected]") | ||
cy.get('input[name=password]') | ||
.type(supervisor_password) | ||
cy.get($form).submit() | ||
}) | ||
} | ||
|
||
function assert_visible() { | ||
cy.log(token_url) | ||
cy.visit(token_url) | ||
cy.get('main').contains('F. Nord') | ||
} | ||
|
||
function assert_invisible() { | ||
cy.log(token_url) | ||
cy.visit(token_url) | ||
cy.get('main').contains('1 Supervisor matches these filters') | ||
cy.get('main').not(':contains("F. Nord")') | ||
} | ||
|
||
/** High level checking the lifecycle of a supervisor. **/ | ||
describe('Walk through', () => { | ||
|
||
|
@@ -37,14 +61,7 @@ describe('Walk through', () => { | |
}) | ||
|
||
it('Edit new supervisor', () => { | ||
cy.visit('/supervisor/edit') | ||
cy.get('form').within($form => { | ||
cy.get('input[name=mail]') | ||
.type("[email protected]") | ||
cy.get('input[name=password]') | ||
.type(supervisor_password) | ||
cy.get($form).submit() | ||
}) | ||
login_supervisor() | ||
cy.get('form[id="supervisor_form"]').within($form => { | ||
cy.get('#it').check({force: true}) | ||
cy.get('#moderation').check() | ||
|
@@ -59,30 +76,32 @@ describe('Walk through', () => { | |
}) | ||
|
||
it('Token: New supervisor visible by new token?', () => { | ||
cy.log(token_url) | ||
cy.visit(token_url) | ||
cy.get('main').contains('F. Nord') | ||
assert_visible() | ||
}) | ||
|
||
it('Delete profile of the new supervisor', () => { | ||
cy.visit('/supervisor/edit') | ||
cy.get('form').within($form => { | ||
cy.get('input[name=mail]') | ||
.type("[email protected]") | ||
cy.get('input[name=password]') | ||
.type(supervisor_password) | ||
it('Deactivate the supervisor', () => { | ||
login_supervisor() | ||
cy.get('input[type=button][name=deactivate]').click() | ||
cy.get('main').contains('Your profile is inactive.') | ||
assert_invisible() | ||
}) | ||
|
||
it('Reactivate the supervisor', () => { | ||
login_supervisor() | ||
cy.get('form[id="supervisor_form"]').within($form => { | ||
cy.get('input[name=confirm_privacy_policy]').check() | ||
cy.get($form).submit() | ||
}) | ||
cy.get('main').contains('Your profile is online') | ||
assert_visible() | ||
}) | ||
|
||
it('Delete profile of supervisor', () => { | ||
login_supervisor() | ||
cy.get('input[type=button][name=delete]').click() | ||
cy.get('input[id=confirm_delete]').check() | ||
cy.get('input[type=button][name=delete]').click() | ||
cy.get('main').contains('Your account has been deleted.') | ||
}) | ||
|
||
it('New supervisor should not be longer visible', () => { | ||
cy.log(token_url) | ||
cy.visit(token_url) | ||
cy.get('main').contains('1 Supervisor matches these filters') | ||
cy.get('main').not(':contains("F. Nord")') | ||
assert_invisible() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.