Skip to content

Commit

Permalink
Don't show modal if user is logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
lfarrell committed Nov 5, 2024
1 parent 3f78b78 commit ede09b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</div>

<div class="modal" :class="{ 'is-active': modal_open }">
<div v-if="!isLoggedIn && (showNonImageDownload(recordData) || showImageDownload(recordData))" class="modal" :class="{ 'is-active': modal_open }">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
Expand Down
34 changes: 25 additions & 9 deletions static/js/vue-cdr-access/tests/unit/downloadOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,42 @@ describe('downloadOption.vue', () => {
await setRecordPermissions(record, ['viewAccessCopies', 'viewReducedResImages', 'viewOriginal']);
await store.$patch({ username: '' });
await store.$patch({ isLoggedIn: false });
// await wrapper.find('.login-modal-link').trigger('click'); // Open
await wrapper.find('.login-modal-link').trigger('click'); // Open
await wrapper.find('button.close').trigger('click'); // Close
expect(wrapper.find('.modal').classes('is-active')).toBe(false);
});

it('hides the list of visible options when any non dropdown page element is clicked', async () => {
it('closes the modal when the "ESC" key is hit', async () => {
await setRecordPermissions(record, ['viewAccessCopies', 'viewReducedResImages', 'viewOriginal']);
await store.$patch({ username: '' });
await store.$patch({ isLoggedIn: false });
await wrapper.find('.login-modal-link').trigger('click'); // Open
expect(wrapper.find('.modal').classes('is-active')).toBe(true);
await wrapper.trigger('keyup.esc'); // Close
expect(wrapper.find('.modal').classes('is-active')).toBe(false);
});

it('shows the list of download options', async () => {
await setRecordPermissions(record, ['viewAccessCopies', 'viewReducedResImages', 'viewOriginal']);

await wrapper.find('.login-link').trigger('click'); // Open
await wrapper.find('.download-images').trigger('click'); // Open
expect(wrapper.find('#dropdown-menu').classes('show-list')).toBe(true);
});

it('hides the list of download options when any non dropdown page element is clicked', async () => {
await setRecordPermissions(record, ['viewAccessCopies', 'viewReducedResImages', 'viewOriginal']);

await wrapper.find('.download-images').trigger('click'); // Open
await wrapper.trigger('click'); // Close
expect(wrapper.find('.modal').classes('is-active')).toBe(false);
expect(wrapper.find('#dropdown-menu').classes('show-list')).toBe(false);
});

it('hides the list of visible options when the "ESC" key is hit', async () => {
it('hides the list of download options when the "ESC" key is hit', async () => {
await setRecordPermissions(record, ['viewAccessCopies', 'viewReducedResImages', 'viewOriginal']);
await store.$patch({ username: '' });
await store.$patch({ isLoggedIn: false });
await wrapper.find('.login-modal-link').trigger('click'); // Open

await wrapper.find('.download-images').trigger('click'); // Open
await wrapper.trigger('keyup.esc'); // Close
expect(wrapper.find('.modal').classes('is-active')).toBe(false);
expect(wrapper.find('#dropdown-menu').classes('show-list')).toBe(false);
});

async function setRecordPermissions(rec, permissions) {
Expand Down

0 comments on commit ede09b2

Please sign in to comment.