Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEPP-37 Add gui testing via selenium #26

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
342 changes: 172 additions & 170 deletions dating_app/static/index.js
Original file line number Diff line number Diff line change
@@ -1,180 +1,182 @@
$('.ui.dropdown')
.dropdown();
$(document).on('click', '#loginButton', function () {
$('#loginModal')
.modal({
blurring: false
})
.modal('setting', 'transition', "scale")
.modal('show')
});
$('.ui.dropdown')
.dropdown();
$(document).on('click', '#loginButton', function () {
$('#loginModal')
.modal({
blurring: false
})
.modal('setting', 'transition', "scale")
.modal('show')
});

$(document).on('click', '#logoutButton', function () {
$('#logoutButton')
.api({
url: '/api/user/logout',
method: 'POST',
onResponse: function (response) {
console.log("logout response = ");
console.log(response);
$(document).on('click', '#logoutButton', function () {
$('#logoutButton')
.api({
url: '/api/user/logout',
method: 'POST',
onResponse: function (response) {
console.log("logout response = ");
console.log(response);

},
onSuccess: function (response, element, xhr) {
// valid response and response.success = true
console.log("xhr = ");
console.log(xhr);
$('body').toast({
class: 'success',
message: `${response.message}`,
pauseOnHover: false,
showProgress: 'top'
});
sessionStorage.removeItem('loggedIn');
sessionStorage.removeItem('user');
swap_buttons();
},
},
onSuccess: function (response, element, xhr) {
// valid response and response.success = true
console.log("xhr = ");
console.log(xhr);
$('body').toast({
class: 'success',
displayTime: 5000,
message: `${response.message}`,
pauseOnHover: false,
showProgress: 'top'
});
sessionStorage.removeItem('loggedIn');
sessionStorage.removeItem('user');
swap_buttons();
},
});
$('#loginForm .submit.button')
.api({
url: '/api/user/login',
method: 'POST',
serializeForm: true,
beforeSend: function (settings) {
console.log(settings)
return settings
},
onResponse: function (response) {
console.log("RESPONSE = ");
console.log(response);
$('#loginModal').modal('hide')
return response
},
onSuccess: function (response, element, xhr) {
// valid response and response.success = true
console.log("response = ");
console.log(response);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
$('#loginModal').modal('hide')
$('body').toast({
class: 'success',
message: `${response.message}`,
pauseOnHover: false,
showProgress: 'top'
});
sessionStorage.setItem('loggedIn', true)
sessionStorage.setItem('user', response.email)
console.log("deactivating login (and reg)")
swap_buttons()
},
onError(errorMessage, element, xhr) {
console.log("errorMessage = ");
console.log(errorMessage);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
response = xhr.responseJSON
$('#loginModal').modal('hide')
$('body').toast({
class: 'error',
message: `${response.message}`,
pauseOnHover: false,
showProgress: 'top'
});
},
});
$('#loginForm .submit.button')
.api({
url: '/api/user/login',
method: 'POST',
serializeForm: true,
beforeSend: function (settings) {
console.log(settings)
return settings
},
onResponse: function (response) {
console.log("RESPONSE = ");
console.log(response);
$('#loginModal').modal('hide')
return response
},
onSuccess: function (response, element, xhr) {
// valid response and response.success = true
console.log("response = ");
console.log(response);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
$('#loginModal').modal('hide')
$('body').toast({
class: 'success',
displayTime: 5000,
message: `${response.message}`,
pauseOnHover: false,
showProgress: 'top'
});

$('#registrationForm')
.form({
fields: {
match: {
identifier: 'confirmPassword',
rules: [
{
type: 'match[password]',
prompt: 'Please ensure the passwords match'
}
]
}
}
})
.api({
url: '/api/user/register',
method: 'POST',
serializeForm: true,
beforeSend: function (settings) {
console.log(settings)
return settings
},
onResponse: function (response) {
console.log("response = ");
console.log(response);
$('#registrationModal').modal('hide')
return response
},
onSuccess: function (response, element, xhr) {
// valid response and response.success = true
console.log("response = ");
console.log(response);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
$('#registrationModal').modal('hide')
$('body').toast({
class: 'success',
message: `${response.message} ${response.email}`,
pauseOnHover: false,
showProgress: 'top'
});
$('#loginModal').modal('show')
},
onError(errorMessage, element, xhr) {
console.log("errorMessage = ");
console.log(errorMessage);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
response = xhr.responseJSON
$('body').toast({
class: 'error',
message: `${response.message} ${response.email}`,
pauseOnHover: false,
showProgress: 'top'
});
},
sessionStorage.setItem('loggedIn', true)
sessionStorage.setItem('user', response.email)
console.log("deactivating login (and reg)")
swap_buttons()
},
onError(errorMessage, element, xhr) {
console.log("errorMessage = ");
console.log(errorMessage);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
response = xhr.responseJSON
$('#loginModal').modal('hide')
$('body').toast({
class: 'error',
message: `${response.message}`,
pauseOnHover: false,
showProgress: 'top'
});
},
});

$(document).on('click', '#registrationLink', function () {
$('#registrationModal')
.modal({
blurring: true
})
.modal('setting', 'transition', "scale")
.modal('show')
});
function swap_buttons() {
console.log("swapping buttons");
if (sessionStorage.getItem('loggedIn')) {
hidden_element = $('#logoutButton');
visible_element = $('#loginButton');
} else {
hidden_element = $('#loginButton');
visible_element = $('#logoutButton');
$('#registrationForm')
.form({
fields: {
match: {
identifier: 'confirmPassword',
rules: [
{
type: 'match[password]',
prompt: 'Please ensure the passwords match'
}
]
}
hidden_element.show();
visible_element.hide();
}

window.addEventListener("beforeunload", (ev) => {
$.ajax({
type: "POST",
url: "/api/user/logout"
})
.api({
url: '/api/user/register',
method: 'POST',
serializeForm: true,
beforeSend: function (settings) {
console.log(settings)
return settings
},
onResponse: function (response) {
console.log("response = ");
console.log(response);
$('#registrationModal').modal('hide')
return response
},
onSuccess: function (response, element, xhr) {
// valid response and response.success = true
console.log("response = ");
console.log(response);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
$('#registrationModal').modal('hide')
$('body').toast({
class: 'success',
message: `${response.message} ${response.email}`,
pauseOnHover: false,
showProgress: 'top'
});
});
window.onload = swap_buttons();//$('#logoutButton').hide();
$('#loginModal').modal('show')
},
onError(errorMessage, element, xhr) {
console.log("errorMessage = ");
console.log(errorMessage);
console.log("element = ");
console.log(element);
console.log("xhr = ");
console.log(xhr);
response = xhr.responseJSON
$('body').toast({
class: 'error',
message: `${response.message} ${response.email}`,
pauseOnHover: false,
showProgress: 'top'
});
},
});

$(document).on('click', '#registrationLink', function () {
$('#registrationModal')
.modal({
blurring: true
})
.modal('setting', 'transition', "scale")
.modal('show')
});
function swap_buttons() {
console.log("swapping buttons");
if (sessionStorage.getItem('loggedIn')) {
hidden_element = $('#logoutButton');
visible_element = $('#loginButton');
} else {
hidden_element = $('#loginButton');
visible_element = $('#logoutButton');
}
hidden_element.show();
visible_element.hide();
}

window.addEventListener("beforeunload", (ev) => {
$.ajax({
type: "POST",
url: "/api/user/logout"
});
});
window.onload = swap_buttons();//$('#logoutButton').hide();
8 changes: 6 additions & 2 deletions dating_app/static/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@ $('#searchForm')
}

console.log(settings.data)
if (document.querySelector("#searchResults")) {
document.querySelector("#searchResults").outerHTML = ""
}
return settings
},
onResponse: function (response) {
$('body').append("<h2> Search results </h2>");
$('body').append("<h2 id='searchResults'> Search results </h2>");

for (let i = 0; i < response.length; i++) {
card_name = response["data"][i]["name"]
card_age = response["data"][i]["age"]
card_gender = response["data"][i]["gender"]
card_email = response["data"][i]["email"]
card = create_card(card_name, card_age, card_gender, card_email)
$('body').append(card);
$('#searchResults').append(card)

}
},
});
Expand Down
6 changes: 3 additions & 3 deletions dating_app/templates/login_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ <h2 class="ui image header">
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="text" name="email" placeholder="E-mail address">
<input id="loginFormEmail" type="text" name="email" placeholder="E-mail address">
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input type="password" name="password" placeholder="Password">
<input id="loginFormPassword" type="password" name="password" placeholder="Password">
</div>
</div>
<!-- cant set brand colour -->
<div class="brand ui fluid large primary submit button">Login</div>
<div class="brand ui fluid large primary submit button" id="loginFormButton">Login</div>
</div>
</form>

Expand Down
Loading