overleaf/server-ce/test/helpers/project.ts
Miguel Serrano 6703ed7e27 Merge pull request #16508 from overleaf/msm-fix-ce-test
[server-ce] Fix cypress e2e tests

GitOrigin-RevId: ffb802d15491cd5fdb96486629da675d90cce18e
2024-01-17 09:03:09 +00:00

27 lines
777 B
TypeScript

export function createProject(
name: string,
{
type = 'Blank Project',
isFirstProject,
}: {
type?: 'Blank Project' | 'Example Project'
isFirstProject?: boolean
} = {}
): Cypress.Chainable<string> {
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()
}
// 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())
}