diff --git a/events/scripts/content-update.js b/events/scripts/content-update.js index eca390e0..43550542 100644 --- a/events/scripts/content-update.js +++ b/events/scripts/content-update.js @@ -167,14 +167,6 @@ export async function updateRSVPButtonState(rsvpBtn, miloLibs) { await registeredState(); } else if (rsvpData.registrationStatus === 'waitlisted') { await waitlistedState(); - } else if (!rsvpData.ok) { - if (rsvpData.error?.message === 'Request to ESP failed: Event is full') { - if (allowWaitlisting) { - await waitlistState(); - } else { - await closedState(); - } - } } } diff --git a/test/unit/scripts/content-update.test.js b/test/unit/scripts/content-update.test.js index e730a220..d98dc7a7 100644 --- a/test/unit/scripts/content-update.test.js +++ b/test/unit/scripts/content-update.test.js @@ -88,7 +88,7 @@ describe('Content Update Script', () => { const buttonOriginalText = document.querySelector('a[href$="#rsvp-form-1"]').textContent; autoUpdateContent(document, miloDeps); - BlockMediator.set('rsvpData', { ok: true, data: { status: { registered: false } } }); + BlockMediator.set('rsvpData', null); expect(document.querySelector('a[href$="#rsvp-form-1"]').textContent).to.be.equal(buttonOriginalText); }); @@ -131,7 +131,6 @@ describe('updateRSVPButtonState', () => { await updateRSVPButtonState(rsvpBtn, LIBS); expect(rsvpBtn.el.textContent).to.equal('RSVP'); - BlockMediator.set('rsvpData', { ok: false, error: { message: 'Request to ESP failed: Event is full' } }); BlockMediator.set('eventData', { isFull: true, allowWaitlisting: false }); await updateRSVPButtonState(rsvpBtn, LIBS); expect(rsvpBtn.el.classList.contains('disabled')).to.be.true; @@ -139,6 +138,24 @@ describe('updateRSVPButtonState', () => { BlockMediator.set('eventData', { isFull: true, allowWaitlisting: true }); await updateRSVPButtonState(rsvpBtn, LIBS); expect(rsvpBtn.el.classList.contains('disabled')).to.be.false; + + BlockMediator.set('rsvpData', { registrationStatus: 'registered' }); + BlockMediator.set('eventData', { isFull: true, allowWaitlisting: false }); + await updateRSVPButtonState(rsvpBtn, LIBS); + expect(rsvpBtn.el.classList.contains('disabled')).to.be.false; + + BlockMediator.set('eventData', { isFull: true, allowWaitlisting: true }); + await updateRSVPButtonState(rsvpBtn, LIBS); + expect(rsvpBtn.el.classList.contains('disabled')).to.be.false; + + BlockMediator.set('rsvpData', { registrationStatus: 'waitlisted' }); + BlockMediator.set('eventData', { isFull: true, allowWaitlisting: false }); + await updateRSVPButtonState(rsvpBtn, LIBS); + expect(rsvpBtn.el.classList.contains('disabled')).to.be.false; + + BlockMediator.set('eventData', { isFull: true, allowWaitlisting: true }); + await updateRSVPButtonState(rsvpBtn, LIBS); + expect(rsvpBtn.el.classList.contains('disabled')).to.be.false; }); });