mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 04:09:07 -04:00
Refactor code/initial tests
This commit is contained in:
@@ -12,21 +12,17 @@
|
||||
var seconds = Math.floor((difference % (1000 * 60)) / 1000);
|
||||
document.getElementById("timeLeft").innerHTML = + minutes + "m " + seconds + "s";
|
||||
showTimer();
|
||||
document.getElementById("logOutTimer").addEventListener("click", logoutByUser);
|
||||
document.getElementById("logOutTimer").addEventListener("click", logoutUser);
|
||||
document.getElementById("extendSessionTimer").addEventListener("click", extendSession);
|
||||
if (difference < 0) {
|
||||
clearInterval(x);
|
||||
closeTimer();
|
||||
redirectToSignin();
|
||||
logoutUser();
|
||||
}
|
||||
}, 1000);
|
||||
}, 60 * 1000);
|
||||
}, 25 * 60 * 1000);
|
||||
|
||||
function redirectToSignin() {
|
||||
window.location.href = '/sign-in';
|
||||
}
|
||||
|
||||
function logoutByUser() {
|
||||
function logoutUser() {
|
||||
window.location.href = '/sign-out';
|
||||
}
|
||||
|
||||
|
||||
@@ -11,47 +11,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
{# {% if current_user.is_authenticated %}#}
|
||||
{# {% block sessionUserWarning %}#}
|
||||
{# <dialog class="usa-modal" id="sessionTimer" aria-labelledby="sessionTimerHeading" aria-describedby="timerWarning">#}
|
||||
{# <div class="usa-modal__content">#}
|
||||
{# <div class="usa-modal__main">#}
|
||||
{# <h2 class="usa-modal__heading" id="sessionTimerHeading">#}
|
||||
{# Your session will end soon.#}
|
||||
{# </h2>#}
|
||||
{# <div class="usa-prose">#}
|
||||
{# <p aria-live="polite" id="timerWarning">#}
|
||||
{# </p>#}
|
||||
{# </div>#}
|
||||
{# <div class="usa-modal__footer">#}
|
||||
{# <ul class="usa-button-group">#}
|
||||
{# <li class="usa-button-group__item">#}
|
||||
{# <button type="button" class="usa-button usa-button--unstyled" id="extendSessionTimer" data-close-modal>#}
|
||||
{# Extend Session#}
|
||||
{# </button>#}
|
||||
{# </li>#}
|
||||
{# <li class="usa-button-group__item">#}
|
||||
{# <button type="button" class="usa-button usa-button--unstyled padding-105 text-center" id="logOutTimer" data-close-modal>#}
|
||||
{# Sign out#}
|
||||
{# </button>#}
|
||||
{# </li>#}
|
||||
{# </ul>#}
|
||||
{# </div>#}
|
||||
{# <button type="button" class="usa-button usa-modal__close" aria-label="Close this window">#}
|
||||
{# <svg class="usa-icon" aria-hidden="true" focusable="false" role="img">#}
|
||||
{# <use xlink:href="/assets/img/usa-icons/close.svg"></use>#}
|
||||
{# </svg>#}
|
||||
{# </button>#}
|
||||
{# </div>#}
|
||||
{# </div>#}
|
||||
{# </dialog>#}
|
||||
{# <!-- <dialog id="sessionTimer">#}
|
||||
{# <p aria-live="polite" id="timerWarning"></p>#}
|
||||
{# <button class="usa-button" id="logOutTimer">Log Out</button>#}
|
||||
{# <button class="usa-button" id="extendSessionTimer">Extend Session</button>#}
|
||||
{# </dialog> -->#}
|
||||
{# {% endblock %}#}
|
||||
{# {% endif %}#}
|
||||
{%- for font in font_paths %}
|
||||
<link rel="preload" href="{{ asset_url(font, with_querystring_hash=False) }}" as="font" type="font/woff2" crossorigin>
|
||||
{%- endfor %}
|
||||
|
||||
18
tests/javascripts/timeoutPopup.test.js
Normal file
18
tests/javascripts/timeoutPopup.test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const timeoutPopup = require('../../app/assets/javascripts/timeoutPopup.js');
|
||||
|
||||
|
||||
describe('Test popup process', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('Test timers work', () => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user