project.ts 565 B

12345678910111213141516171819202122
  1. export function createProject(
  2. name: string,
  3. {
  4. type = 'Blank Project',
  5. }: {
  6. type?: 'Blank Project' | 'Example Project'
  7. } = {}
  8. ): Cypress.Chainable<string> {
  9. cy.findAllByRole('button')
  10. .contains(/new project/i)
  11. .click()
  12. // FIXME: This should only look in the left menu
  13. cy.findAllByText(type).first().click()
  14. cy.findByRole('dialog').within(() => {
  15. cy.get('input').type(name)
  16. cy.findByText('Create').click()
  17. })
  18. return cy
  19. .url()
  20. .should('match', /\/project\/[a-fA-F0-9]{24}/)
  21. .then(url => url.split('/').pop())
  22. }