-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Add project creation & edition test scenario
- Loading branch information
Showing
5 changed files
with
78 additions
and
5 deletions.
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,70 @@ | ||
Cypress.Commands.add('getBySelectorId', (selectorId) => { | ||
cy.get('[data-cy="' + selectorId + '"]'); | ||
}); | ||
|
||
function generateId(): string { | ||
return Math.random().toString(16).slice(2); | ||
} | ||
|
||
function buildProjectName(id): string { | ||
return 'project ' + id; | ||
} | ||
|
||
function buildProjectSmallName(id): string { | ||
return id; | ||
} | ||
|
||
const projectId = generateId(); | ||
const projectName = buildProjectName(projectId); | ||
const projectSmallName = buildProjectSmallName(projectId); | ||
|
||
const newProjectId = generateId(); | ||
const projectNewName = buildProjectName(newProjectId) | ||
const projectNewSmallName = buildProjectSmallName(newProjectId); | ||
|
||
describe('project creation and edition afterwards', () => { | ||
it('create project', () => { | ||
cy.visit('/projects') | ||
cy.getBySelectorId('name') | ||
.type(projectName) | ||
.should('have.value', projectName) | ||
cy.getBySelectorId('smallName') | ||
.type(projectSmallName) | ||
.should('have.value', projectSmallName) | ||
cy.get('button[type=submit]').click() | ||
}) | ||
|
||
it('new project should appear in project hierarchies', () => { | ||
cy.visit('/') | ||
cy.contains(projectName); | ||
cy.contains(projectSmallName); | ||
}) | ||
|
||
it('edit newly created project', () => { | ||
cy.visit('/') | ||
cy.contains(projectName).click(); | ||
cy.getBySelectorId('editProject').click(); | ||
|
||
cy.getBySelectorId('name') | ||
.clear() | ||
.type(projectNewName) | ||
.should('have.value', projectNewName) | ||
cy.getBySelectorId('smallName') | ||
.clear() | ||
.type(projectNewSmallName) | ||
.should('have.value', projectNewSmallName) | ||
cy.get('button[type=submit]').click() | ||
}) | ||
|
||
it('new name should appear in project hierarchies', () => { | ||
cy.visit('/') | ||
cy.contains(projectNewName); | ||
cy.contains(projectNewSmallName); | ||
}) | ||
|
||
it('old name should not appear anywhere',() => { | ||
cy.visit('/') | ||
cy.contains(projectName).should('not.exist'); | ||
cy.contains(projectSmallName).should('not.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
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
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
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