Skip to content

Commit

Permalink
e2e: add a command to import repos without the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulrhmnGhanem committed Apr 10, 2023
1 parent 227586d commit c1e4030
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 343 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,18 @@ jobs:
run: |
scripts/install_gitea.sh
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Pre e2e
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FRONTEND_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.frontend_sha_short }}'
PROCESSOR_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.processor_sha_short }}'
NGINX_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.nginx_sha_short }}'
GITEA_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.gitea_sha_short }}'
shell: bash
run: scripts/pre_e2e.sh

Expand All @@ -344,6 +355,7 @@ jobs:
COMMIT_INFO_SHA: '${{ github.event.head_commit.id }}'
COMMIT_INFO_TIMESTAMP: '${{ github.event.head_commit.timestamp }}'
COMMIT_INFO_BRANCH: '${{ github.ref_name || github.head_ref }}'
CYPRESS_ADMIN_TOKEN: ${{ env.CYPRESS_ADMIN_TOKEN }}
run: |
docker-compose -f docker-compose.yml -f docker-compose.deploy.yml -f docker-compose.e2e.yml up \
--abort-on-container-exit --exit-code-from e2e
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ services:
- COMMIT_INFO_SHA=${COMMIT_INFO_SHA}
- COMMIT_INFO_TIMESTAMP=${COMMIT_INFO_TIMESTAMP}
- COMMIT_INFO_BRANCH=${COMMIT_INFO_BRANCH}
- CYPRESS_ADMIN_TOKEN=${CYPRESS_ADMIN_TOKEN}

depends_on:
- nginx
working_dir: /e2e
Expand Down
63 changes: 19 additions & 44 deletions e2e/cypress/integration/IBOM.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,98 +10,73 @@ describe('IBOM page', () => {
})

it('should redirect to project page (multi project)', () => {
const { username, email, password } = getFakeUser()

cy.createUser(username, email, password)
cy.visit('/')
cy.get('[data-cy=user-menu]')

cy.forceVisit('/projects/new')
const user = getFakeUser()

const multiProjectsNames = ['alpha-spectrometer', 'electron-detector']
const multiProjectsRepoName = 'DIY_particle_detector'
const syncedRepoUrlMultiProjects =
'https://github.com/kitspace-test-repos/DIY_particle_detector'

/* Migrate the multiproject repo */
cy.get('[data-cy=sync-field]').type(syncedRepoUrlMultiProjects)
cy.get('button').contains('Sync').click()
cy.importRepo(syncedRepoUrlMultiProjects, multiProjectsRepoName, user)

cy.forceVisit(`/${user.username}/${multiProjectsRepoName}`)

// Wait for redirection for project page
cy.url({ timeout: 60_000 }).should(
'contain',
`${username}/${multiProjectsRepoName}`,
)
// Wait for the repo to finish processing, by checking the visibility sub projects cards.
cy.get('[data-cy=project-card]', { timeout: 120_000 }).as('projectCards')

cy.get('@projectCards').should('have.length', multiProjectsNames.length)

// Go to IBOM page for a subproject
const subProjectName = multiProjectsNames[0]
cy.visit(`${username}/${multiProjectsRepoName}/${subProjectName}/IBOM`)
cy.visit(`${user.username}/${multiProjectsRepoName}/${subProjectName}/IBOM`)

// Click on the title
cy.get('#title').click()

// It should redirect to the subproject page
cy.url({ timeout: 20_000 }).should(
'eq',
`${
Cypress.config().baseUrl
}/${username}/${multiProjectsRepoName}/${subProjectName}`,
`${Cypress.config().baseUrl}/${
user.username
}/${multiProjectsRepoName}/${subProjectName}`,
)
})

it('should redirect to the project page (normal project)', () => {
const { username, email, password } = getFakeUser()

cy.createUser(username, email, password)
cy.visit('/')
cy.get('[data-cy=user-menu]')

/* Migrate the normal repo */
cy.forceVisit('/projects/new')
const user = getFakeUser()

const syncedRepoUrl = 'https://github.com/kitspace-test-repos/CH330_Hardware'
const normalRepoName = 'CH330_Hardware'
cy.importRepo(syncedRepoUrl, normalRepoName, user)

cy.get('[data-cy=sync-field]').type(syncedRepoUrl)
cy.get('button').contains('Sync').click()

// Wait for redirection for project page
cy.url({ timeout: 60_000 }).should('contain', `${username}/${normalRepoName}`)
cy.forceVisit(`/${user.username}/${normalRepoName}`)
// Wait for the repo to finish processing, by checking the visibility of info-bar.
cy.get('[data-cy=info-bar]', { timeout: 60_000 }).should('be.visible')

// Go to IBOM page for a single (not multi) project
cy.get('[data-cy=ibom]').should('be.visible')
cy.visit(`${username}/${normalRepoName}/_/IBOM`)
cy.visit(`${user.username}/${normalRepoName}/_/IBOM`)

// Click on the title
cy.get('#title').click()

// It should redirect to the project page
cy.url({ timeout: 20_000 }).should(
'eq',
`${Cypress.config().baseUrl}/${username}/${normalRepoName}`,
`${Cypress.config().baseUrl}/${user.username}/${normalRepoName}`,
)
})

it('should not render `Assembly Guide` button for projects with `ibom-enabled: false', () => {
const { username, email, password } = getFakeUser()
cy.createUser(username, email, password)
cy.visit('/')
cy.get('[data-cy=user-menu]')
const user = getFakeUser()
/* Migrate a repo with `omit-ibom` set to `true` */
cy.forceVisit('/projects/new')
const repoName = 'solarbird_shenzen_rdy'
const IBOMDisabledRepoURL =
'https://github.com/kitspace-test-repos/solarbird_shenzen_rdy'
const repoName = 'solarbird_shenzen_rdy'
cy.get('[data-cy=sync-field]').type(IBOMDisabledRepoURL)
cy.get('button').contains('Sync').click()
// Wait for redirection for project page
cy.url({ timeout: 60_000 }).should('contain', `${username}/${repoName}`)
cy.importRepo(IBOMDisabledRepoURL, repoName, user)

cy.forceVisit(`/${user.username}/${repoName}`)
cy.url({ timeout: 60_000 }).should('contain', `${user.username}/${repoName}`)
// Wait for the repo to finish processing, by checking the visibility of info-bar.
cy.get('[data-cy=info-bar]', { timeout: 100_000 }).should('be.visible')
// The ibom button shouldn't get rendered for this project.
Expand Down
18 changes: 4 additions & 14 deletions e2e/cypress/integration/IBOM.visual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,17 @@ import { getFakeUser } from '../support/getFakeUser'

describe.skip('Regression test for IBOM ', () => {
before(() => {
const { username, email, password } = getFakeUser()
const user = getFakeUser()

const repoName = 'CH330_Hardware'
const syncedRepoUrl = 'https://github.com/kitspace-test-repos/CH330_Hardware'

cy.createUser(username, email, password)
cy.visit('/')
cy.get('[data-cy=user-menu]')

cy.forceVisit('/projects/new')

// Migrate the repo
cy.get('[data-cy=sync-field]').type(syncedRepoUrl)
cy.get('button').contains('Sync').click()

// Wait for redirection for project page
cy.url({ timeout: 60_000 }).should('contain', `${username}/${repoName}`)
cy.importRepo(syncedRepoUrl, repoName, user)
cy.forceVisit(`/${user.username}/${repoName}`)
// Wait for the repo to finish processing, by checking the visibility of info-bar.
cy.get('[data-cy=info-bar]', { timeout: 60_000 }).should('be.visible')

cy.visit(`${username}/${repoName}/IBOM`)
cy.visit(`${user.username}/${repoName}/IBOM`)

// Wait until the ibom is visible
cy.get('.topmostdiv').should('be.visible')
Expand Down
42 changes: 10 additions & 32 deletions e2e/cypress/integration/legacyRedirect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,78 +10,56 @@ describe('Legacy redirects', () => {
})

it('should redirect `/boards/*/user/project/*` to `/user/project/*`', () => {
const { username, email, password } = getFakeUser()
cy.createUser(username, email, password)
cy.visit('/')
cy.get('[data-cy=user-menu]')

cy.forceVisit('/projects/new')
const user = getFakeUser()

const multiProjectsRepoName = 'DIY_particle_detector'
const multiProjectsNames = ['alpha-spectrometer', 'electron-detector']
const syncedRepoUrlMultiProjects =
'https://github.com/kitspace-test-repos/DIY_particle_detector'

/* Migrate the multiproject repo */
cy.get('[data-cy=sync-field]').type(syncedRepoUrlMultiProjects)
cy.get('button').contains('Sync').click()
cy.importRepo(syncedRepoUrlMultiProjects, multiProjectsRepoName, user)

// Wait for redirection for project page
cy.url({ timeout: 60_000 }).should(
'contain',
`${username}/${multiProjectsRepoName}`,
)
cy.forceVisit(`/${user.username}/${multiProjectsRepoName}`)
// Wait for the repo to finish processing, by checking the visibility sub projects cards.
cy.get('[data-cy=project-card]', { timeout: 120_000 }).as('projectCards')

cy.get('@projectCards').should('have.length', multiProjectsNames.length)

/* Legacy redirect */
cy.visit(
`/boards/github.com/${username}/${multiProjectsRepoName}/${multiProjectsNames[0]}`,
`/boards/github.com/${user.username}/${multiProjectsRepoName}/${multiProjectsNames[0]}`,
)
cy.url().should(
'eq',
`${Cypress.config().baseUrl}/${username}/${multiProjectsRepoName}/${
`${Cypress.config().baseUrl}/${user.username}/${multiProjectsRepoName}/${
multiProjectsNames[0]
}`,
)
})

it('should redirect `/interactive_bom/?*/user/project*` to `/user/project/IBOM`', () => {
const { username, email, password } = getFakeUser()
cy.createUser(username, email, password)
cy.visit('/')
cy.get('[data-cy=user-menu]')

cy.forceVisit('/projects/new')

const user = getFakeUser()
const multiProjectsRepoName = 'DIY_particle_detector'
const multiProjectsNames = ['alpha-spectrometer', 'electron-detector']
const syncedRepoUrlMultiProjects =
'https://github.com/kitspace-test-repos/DIY_particle_detector'

/* Migrate the multiproject repo */
cy.get('[data-cy=sync-field]').type(syncedRepoUrlMultiProjects)
cy.get('button').contains('Sync').click()
cy.importRepo(syncedRepoUrlMultiProjects, multiProjectsRepoName, user)

// Wait for redirection for project page
cy.url({ timeout: 60_000 }).should(
'contain',
`${username}/${multiProjectsRepoName}`,
)
cy.forceVisit(`/${user.username}/${multiProjectsRepoName}`)
// Wait for the repo to finish processing, by checking the visibility sub projects cards.
cy.get('[data-cy=project-card]', { timeout: 120_000 }).as('projectCards')

cy.get('@projectCards').should('have.length', multiProjectsNames.length)

/* Legacy redirect */
cy.visit(
`/interactive_bom/?github.com/${username}/${multiProjectsRepoName}/${multiProjectsNames[0]}`,
`/interactive_bom/?github.com/${user.username}/${multiProjectsRepoName}/${multiProjectsNames[0]}`,
)
cy.url().should(
'eq',
`${Cypress.config().baseUrl}/${username}/${multiProjectsRepoName}/${
`${Cypress.config().baseUrl}/${user.username}/${multiProjectsRepoName}/${
multiProjectsNames[0]
}/IBOM`,
)
Expand Down
Loading

0 comments on commit c1e4030

Please sign in to comment.