Skip to content

Commit e206b36

Browse files
committed
fix a bug related to invalid sort error in recordedit
clicking on the ok button is supposed to reload the page without the sort criteria, but it was also redirecting users to recordset page.
1 parent bb406fc commit e206b36

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

src/providers/recordedit.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,16 @@ export default function RecordeditProvider({
433433
setInitialized(true);
434434
}, (response: any) => {
435435
const errorData: any = {};
436-
errorData.redirectUrl = reference.unfilteredReference.contextualize.compact.appLink;
437436
errorData.gotoTableDisplayname = reference.displayname.value;
438-
response.errorData = errorData;
439-
440437
if (isObjectAndKeyDefined(response.errorData, 'redirectPath')) {
441438
let redirectLink = createRedirectLinkFromPath(response.errorData.redirectPath);
442439
if (response instanceof ERMrest.InvalidFilterOperatorError) redirectLink = redirectLink.replace('recordedit', 'recordset');
443-
response.errorData.redirectUrl = redirectLink;
440+
errorData.redirectUrl = redirectLink;
441+
} else {
442+
errorData.redirectUrl = reference.unfilteredReference.contextualize.compact.appLink;
444443
}
445444

445+
response.errorData = errorData;
446446
dispatchError({ error: response });
447447
});
448448
} else if (session) {

test/e2e/specs/all-features-confirmation/errors/errors.spec.ts

+51
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,58 @@ test.describe('error handling', () => {
332332
await expect.soft(errorModal).not.toBeAttached();
333333
await expect.soft(RecordeditLocators.getPageTitle(page)).toHaveText('Create 1 Accommodations record');
334334
});
335+
});
336+
337+
test('navigating to a page with invalid sort criteria', async ({ page, baseURL }, testInfo) => {
338+
const errorModal = ModalLocators.getErrorModal(page);
339+
340+
await test.step('should display the Invalid Sort Criteria error', async () => {
341+
await page.goto(getChaiseURL(APP_NAMES.RECORDEDIT, 'accommodation', baseURL, testInfo) + '/id=2002@sort(some_column_that_does_not_exist)');
342+
await expect.soft(errorModal).toBeVisible();
343+
await testModalTitleAndText(errorModal,
344+
'Invalid Sort Criteria',
345+
'Given column name `some_column_that_does_not_exist` in sort is not valid.Click OK to reload this page without Invalid Sort Criteria.'
346+
);
347+
});
348+
349+
await test.step('On click of OK button the page should reload the page without the sort.', async () => {
350+
await ModalLocators.getOkButton(errorModal).click();
351+
await RecordeditLocators.waitForRecordeditPageReady(page);
352+
await expect.soft(errorModal).not.toBeAttached();
353+
await expect.soft(RecordeditLocators.getPageTitle(page)).toHaveText('Edit Accommodations: Sherathon Hotel');
354+
});
355+
});
356+
357+
test('navigating to a page with invalid sort criteria and valid facets', async ({ page, baseURL }, testInfo) => {
358+
const errorModal = ModalLocators.getErrorModal(page);
359+
360+
await test.step('should display the Invalid Page Criteria error', async () => {
361+
/**
362+
* facet blob:
363+
* {
364+
* "and": [
365+
* {
366+
* "source": ["id"],
367+
* "choices": ["2001", "2003"]
368+
* }
369+
* ]
370+
* }
371+
*/
372+
const facet = 'N4IghgdgJiBcDaoDOB7ArgJwMYFM7xAEsYBdAGhCwAsVDcl8QAmABhYEYQLWWBmEEgF8hQA';
373+
await page.goto(getChaiseURL(APP_NAMES.RECORDEDIT, 'accommodation', baseURL, testInfo) + '/*::facets::' + facet + '@sort(invalid_col)');
374+
await expect.soft(errorModal).toBeVisible();
375+
await testModalTitleAndText(errorModal,
376+
'Invalid Sort Criteria',
377+
'Given column name `invalid_col` in sort is not valid.Click OK to reload this page without Invalid Sort Criteria.'
378+
);
379+
});
335380

381+
await test.step('On click of OK button the page should reload the page without the sort but keep the facets.', async () => {
382+
await ModalLocators.getOkButton(errorModal).click();
383+
await RecordeditLocators.waitForRecordeditPageReady(page);
384+
await expect.soft(errorModal).not.toBeAttached();
385+
await expect.soft(RecordeditLocators.getPageTitle(page)).toHaveText('Edit 2 Accommodations records');
386+
});
336387
});
337388

338389
test('editting a record without changing data', async ({ baseURL, page }, testInfo) => {

0 commit comments

Comments
 (0)