Skip to content

Commit

Permalink
Save state of sidetabs in Project on reload/reopen
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Jul 24, 2024
1 parent b8dab5a commit c57166c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
9 changes: 8 additions & 1 deletion cypress/e2e/projects/detail/comments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ describe('Comments', () => {


beforeEach(() => {
cy.clearLocalStorage()

cy.task('questionnaire:delete')
cy.clearServerCache()

Expand All @@ -35,6 +37,7 @@ describe('Comments', () => {
project.openCommentsFor('Options Question 1')
project.startNewCommentThread('This is a new thread')
project.expectCommentCount(1)
cy.clearCurrentQuestionnaireSidePanelLocalStorage()
cy.reload()
project.expectCommentCount(1)
}
Expand All @@ -47,16 +50,18 @@ describe('Comments', () => {
project.openPrivateNotesFor('Options Question 1')
project.startNewPrivateNotesThread('This is a new thread')
project.expectCommentCount(2)
cy.clearCurrentQuestionnaireSidePanelLocalStorage()
cy.reload()
project.expectCommentCount(2)
}

const testNoPrivateNotes = () => {
project.openCommentsFor('Options Question 1')
cy.getCy('comments_nav_private-notes').should('not.exist')
cy.clearCurrentQuestionnaireSidePanelLocalStorage()
}

it('as DSW Admin', () => {
it('as Admin', () => {
cy.logout()
cy.loginAs('admin')
project.open(projectName)
Expand Down Expand Up @@ -231,6 +236,7 @@ describe('Comments', () => {
project.startNewCommentThread('This is a new thread')
project.addUser('Nikola Tesla', 'Commenter')
cy.logout()
cy.clearLocalStorage()

cy.loginAs('datasteward')
project.open(projectName)
Expand All @@ -245,6 +251,7 @@ describe('Comments', () => {
project.startNewPrivateNotesThread('This is a new thread')
project.addUser('Nikola Tesla', 'Editor')
cy.logout()
cy.clearLocalStorage()

cy.loginAs('datasteward')
project.open(projectName)
Expand Down
11 changes: 11 additions & 0 deletions cypress/e2e/projects/detail/questionnaire/basic.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,15 @@ describe('Basic Questionnaire Tests', () => {
cy.get('.nav-link').contains('Chapter 2').click()
project.checkAnswerChecked('Answer 2.2')
})


it('keep sidepanel open after refresh', () => {
// open comments tab
cy.get('.item').contains('Comments').click()
cy.get('.comments-overview').should('be.visible')

// check that it remains open after reopening the page
cy.reload()
cy.get('.comments-overview').should('be.visible')
})
})
5 changes: 4 additions & 1 deletion cypress/e2e/projects/detail/todos.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ describe('TODOs', () => {


beforeEach(() => {
cy.clearLocalStorage()

cy.task('questionnaire:delete')
cy.clearServerCache()

cy.createQuestionnaire({
visibility: project.VisibleView,
sharing: project.Restricted,
Expand Down Expand Up @@ -61,6 +63,7 @@ describe('TODOs', () => {

// save, reopen and check again
project.awaitSave()
cy.clearCurrentQuestionnaireSidePanelLocalStorage()
project.open(projectName)
project.expectTodo(test.question)
})
Expand Down
8 changes: 8 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ Cypress.Commands.add('updateQuestionnaireContent', (questionnaireUuid, data) =>
})
})

Cypress.Commands.add('clearCurrentQuestionnaireSidePanelLocalStorage', () => {
cy.url().then((url) => {
const projectUuid = url.match(/\/wizard\/projects\/(.*)/)[1]
cy.clearLocalStorage(`project-${projectUuid}-right-panel`)
})
})


// KM Editor commands

Expand Down Expand Up @@ -451,6 +458,7 @@ Cypress.Commands.add('wsSendAs', (role, url, msg) => {


// Cache

Cypress.Commands.add('clearServerCache', () => {
cy.task('user:addPermission', { perm: 'DEV_PERM', email: Cypress.env('admin_username') })

Expand Down

0 comments on commit c57166c

Please sign in to comment.