Skip to content

Commit

Permalink
♻️ Extract navigateToProjectPage as cypress custom command to use it …
Browse files Browse the repository at this point in the history
…in other tests
  • Loading branch information
Lysoun committed Jan 23, 2024
1 parent c3b405c commit ae61bad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 1 addition & 2 deletions modules/ui/cypress/e2e/project-creation-and-edition.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ describe('project creation and edition afterwards', () => {
})

it('edit newly created project', () => {
cy.visit('/')
cy.contains(projectName).click();
cy.navigateToProjectPage(projectName)
cy.getBySelectorId('editProject').click();
fillProjectForm(projectNewName, projectNewSmallName);
})
Expand Down
5 changes: 5 additions & 0 deletions modules/ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@

Cypress.Commands.add('getBySelectorId', (selectorId) => {
cy.get('[data-cy="' + selectorId + '"]');
});

Cypress.Commands.add('navigateToProjectPage', (projectName) => {
cy.visit('/')
cy.contains(projectName).click();
});
10 changes: 9 additions & 1 deletion modules/ui/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ declare global {
/**
* Retrieves the element that has `selectorId` as its ID.
*
* @param selectorId - The ID of the element to retrieve.
* @param selectorId The ID of the element to retrieve.
*/
getBySelectorId(selectorId: string): Chainable<Element>

/**
* Navigates to root page and clicks on the project name that should appear
* in the sidebar to navigate to the project page
*
* @param projectName Name of the project
*/
navigateToProjectPage(projectName: string): Chainable<Element>
}
}
}
Expand Down

0 comments on commit ae61bad

Please sign in to comment.