project.ts 647 B

12345678910111213141516171819202122
  1. export function createProject(
  2. name: string,
  3. {
  4. type = 'Blank Project',
  5. newProjectButtonMatcher = /new project/i,
  6. }: {
  7. type?: 'Blank Project' | 'Example Project'
  8. newProjectButtonMatcher?: RegExp
  9. } = {}
  10. ): Cypress.Chainable<string> {
  11. cy.findAllByRole('button').contains(newProjectButtonMatcher).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. }