Skip to content

Commit

Permalink
chore: add compatibility with tombstone records (#2541)
Browse files Browse the repository at this point in the history
showing the illustrated 404 error
  • Loading branch information
rwd authored Feb 10, 2025
1 parent b40f325 commit b09e5e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/portal/src/pages/item/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
if (errorResponse?.status === 502 && errorResponse?.data?.code === '502-TS' && !this.fromTranslationError) {
this.fromTranslationError = true;
data = await this.$apis.record.get(this.identifier);
} else if (error.statusCode === 410) {
// TODO: temporary workaround to handle tombstone records like 404s
// til tombstone page implemented
return this.$error({ ...error, statusCode: 404, message: 'Not Found' }, { scope: 'item' });
} else {
return this.$error(error, { scope: 'item' });
}
Expand Down
12 changes: 12 additions & 0 deletions packages/portal/tests/unit/pages/item/_.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createLocalVue } from '@vue/test-utils';
import { shallowMountNuxt } from '../../utils';
import BootstrapVue from 'bootstrap-vue';
import sinon from 'sinon';
import createHttpError from 'http-errors';

import page from '@/pages/item/_';
import useDeBias from '@/composables/deBias.js';
Expand Down Expand Up @@ -523,6 +524,17 @@ describe('pages/item/_.vue', () => {

expect(wrapper.vm.$error.called).toBe(true);
});

describe('when error is 410 Gone (tombstone)', () => {
it('(temporarily) calls $error as with 404 Not Found', async() => {
const wrapper = factory();
wrapper.vm.$apis.record.get = sinon.stub().throws(() => createHttpError(410));

await wrapper.vm.fetch();

expect(wrapper.vm.$error.calledWith(sinon.match.has('statusCode', 404))).toBe(true);
});
});
});

describe('on client-side request', () => {
Expand Down

0 comments on commit b09e5e2

Please sign in to comment.