project.ts 777 B

123456789101112131415161718192021222324252627
  1. export function createProject(
  2. name: string,
  3. {
  4. type = 'Blank Project',
  5. isFirstProject,
  6. }: {
  7. type?: 'Blank Project' | 'Example Project'
  8. isFirstProject?: boolean
  9. } = {}
  10. ): Cypress.Chainable<string> {
  11. if (isFirstProject) {
  12. cy.findByText('Create a new project').click()
  13. } else {
  14. // FIXME: This should be be a data-test-id shared between the welcome page and project list
  15. cy.get('.new-project-button').first().click()
  16. }
  17. // FIXME: This should only look in the left menu
  18. cy.findAllByText(type).first().click()
  19. cy.findByRole('dialog').within(() => {
  20. cy.get('input').type(name)
  21. cy.findByText('Create').click()
  22. })
  23. return cy
  24. .url()
  25. .should('match', /\/project\/[a-fA-F0-9]{24}/)
  26. .then(url => url.split('/').pop())
  27. }