-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(Cypress): add tests for application navigation display
Signed-off-by: Cleopatra Enjeck M. <[email protected]>
- Loading branch information
Showing
2 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
let localUser | ||
let nonLocalUser | ||
let contextTitlePrefix = 'test application' | ||
let contextTitle = contextTitlePrefix | ||
let testNumber = 0 | ||
|
||
describe('Test context navigation', () => { | ||
before(function () { | ||
cy.createRandomUser().then(user => { | ||
localUser = user | ||
}) | ||
|
||
cy.createRandomUser().then(user => { | ||
nonLocalUser = user | ||
}) | ||
}) | ||
|
||
beforeEach(function () { | ||
testNumber += 1 | ||
contextTitle = contextTitlePrefix + ' ' + testNumber | ||
cy.login(localUser) | ||
cy.visit('apps/tables') | ||
cy.wait(1000) | ||
}) | ||
|
||
it('Create context that is hidden in nav by default', () => { | ||
cy.createContext(contextTitle, false) | ||
cy.visit('apps/tables') | ||
|
||
// Confirming that the context is not shown in the navigation for the owner | ||
cy.get(`#header .app-menu-entry [title="${contextTitle}"]`).should('not.exist') | ||
|
||
cy.loadContext(contextTitle) | ||
cy.wait(1000) | ||
cy.openContextEditModal(contextTitle) | ||
cy.get('[data-cy="contextResourceShare"] input').clear().type(nonLocalUser.userId) | ||
cy.get(`.vs__dropdown-menu [id="${nonLocalUser.userId}"]`).click() | ||
cy.get('[data-cy="contextResourceShare"] span').contains(nonLocalUser.userId).should('exist') | ||
cy.get('[data-cy="editContextSubmitBtn"]').click() | ||
|
||
// Confirming that the context is still not shown by default | ||
// in the navigation for the shared user | ||
cy.login(nonLocalUser) | ||
cy.visit('apps/tables') | ||
cy.get(`#header .app-menu-entry [title="${contextTitle}"]`).should('not.exist') | ||
|
||
// Showing the context in nav for the shared user | ||
cy.loadContext(contextTitle) | ||
cy.get('[data-cy="navigationContextItem"]').contains(`${contextTitle}"`).find('button').click({ force: true }) | ||
cy.get('[data-cy="navigationContextShowInNavSwitch"]').should('not.be.checked') | ||
cy.get('[data-cy="navigationContextShowInNavSwitch"]').click() | ||
cy.get('[data-cy="navigationContextShowInNavSwitch"]').should('be.checked') | ||
cy.get(`#header .app-menu-entry [title="${contextTitle}"]`).should('exist') | ||
}) | ||
|
||
it('Create context that shows in nav by default', () => { | ||
cy.createContext(contextTitle, true) | ||
cy.visit('apps/tables') | ||
|
||
// Confirming that the context is shown in the navigation for the owner | ||
cy.get(`#header .app-menu-entry [title="${contextTitle}"]`).should('exist') | ||
|
||
cy.loadContext(contextTitle) | ||
cy.wait(1000) | ||
cy.openContextEditModal(contextTitle) | ||
cy.get('[data-cy="contextResourceShare"] input').clear().type(nonLocalUser.userId) | ||
cy.get(`.vs__dropdown-menu [id="${nonLocalUser.userId}"]`).click() | ||
cy.get('[data-cy="contextResourceShare"] span').contains(nonLocalUser.userId).should('exist') | ||
cy.get('[data-cy="editContextSubmitBtn"]').click() | ||
|
||
// Hiding the context from nav for the current user | ||
cy.get('[data-cy="navigationContextItem"]').contains(`${contextTitle}"`).find('button').click({ force: true }) | ||
cy.get('[data-cy="navigationContextShowInNavSwitch"]').should('be.checked') | ||
cy.get('[data-cy="navigationContextShowInNavSwitch"]').click() | ||
cy.get('[data-cy="navigationContextShowInNavSwitch"]').should('not.be.checked') | ||
cy.get(`#header .app-menu-entry [title="${contextTitle}"]`).should('not.exist') | ||
|
||
// Confirming that the context is still shown by default | ||
// in the navigation for the shared user | ||
cy.login(nonLocalUser) | ||
cy.visit('apps/tables') | ||
cy.get(`#header .app-menu-entry [title="${contextTitle}"]`).should('exist') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters