2023-11-23 10:40:13 +00:00
|
|
|
export function createProject(
|
|
|
|
name: string,
|
|
|
|
{
|
|
|
|
type = 'Blank Project',
|
2024-01-16 09:40:22 +00:00
|
|
|
isFirstProject,
|
|
|
|
}: {
|
|
|
|
type?: 'Blank Project' | 'Example Project'
|
|
|
|
isFirstProject?: boolean
|
|
|
|
} = {}
|
2023-11-23 10:40:13 +00:00
|
|
|
): Cypress.Chainable<string> {
|
2024-01-16 09:40:22 +00:00
|
|
|
if (isFirstProject) {
|
|
|
|
cy.findByText('Create a new project').click()
|
|
|
|
} else {
|
|
|
|
// FIXME: This should be be a data-test-id shared between the welcome page and project list
|
|
|
|
cy.get('.new-project-button').first().click()
|
|
|
|
}
|
2023-11-23 10:40:13 +00:00
|
|
|
// FIXME: This should only look in the left menu
|
|
|
|
cy.findAllByText(type).first().click()
|
|
|
|
cy.findByRole('dialog').within(() => {
|
|
|
|
cy.get('input').type(name)
|
|
|
|
cy.findByText('Create').click()
|
|
|
|
})
|
|
|
|
return cy
|
|
|
|
.url()
|
|
|
|
.should('match', /\/project\/[a-fA-F0-9]{24}/)
|
|
|
|
.then(url => url.split('/').pop())
|
|
|
|
}
|