diff --git a/assets/src/bundles/save/index.js b/assets/src/bundles/save/index.js --- a/assets/src/bundles/save/index.js +++ b/assets/src/bundles/save/index.js @@ -350,6 +350,14 @@ $('.nav-tabs a[href="#swh-origin-save-requests-list"]').tab('show'); } + $(window).on('hashchange', () => { + if (window.location.hash === '#requests') { + $('.nav-tabs a[href="#swh-origin-save-requests-list"]').tab('show'); + } else { + $('.nav-tabs a[href="#swh-origin-save-requests-create"]').tab('show'); + } + }); + }); } diff --git a/cypress/integration/origin-save.spec.js b/cypress/integration/origin-save.spec.js --- a/cypress/integration/origin-save.spec.js +++ b/cypress/integration/origin-save.spec.js @@ -751,4 +751,24 @@ }); + it('should switch tabs when playing with browser history', function() { + cy.intercept('/save/requests/list/**', {fixture: 'origin-save'}); + cy.intercept('/save/task/info/**', {fixture: 'save-task-info'}); + + cy.get('#swh-origin-save-request-help-tab') + .should('have.class', 'active'); + + cy.get('#swh-origin-save-requests-list-tab') + .click() + .should('have.class', 'active'); + + cy.go('back') + .get('#swh-origin-save-request-help-tab') + .should('have.class', 'active'); + + cy.go('forward') + .get('#swh-origin-save-requests-list-tab') + .should('have.class', 'active'); + }); + });