Skip to content

Commit

Permalink
Merge branch 'ag/del-auth' of https://github.com/kitspace/kitspace-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitspace Auto-Merge Bot committed Jul 2, 2023
2 parents 3799789 + fca1920 commit 61d6ec7
Show file tree
Hide file tree
Showing 39 changed files with 320 additions and 1,970 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,22 @@ jobs:
run: |
scripts/install_gitea.sh
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Pre e2e
env:
FRONTEND_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.frontend_sha }}'
PROCESSOR_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.processor_sha }}'
NGINX_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.nginx_sha }}'
GITEA_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.gitea_sha }}'
shell: bash
run: scripts/pre_e2e.sh
run: |
token=$(scripts/pre_e2e.sh)
docker-compose stop
echo "CYPRESS_GITEA_ADMIN_TOKEN=${token}" >> $GITHUB_ENV
- name: e2e
timeout-minutes: 40
Expand Down
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,39 @@ We configure our staging servers using [Ansible](https://docs.ansible.com/ansibl
```console
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.e2e.yml up e2e
```
##

> Note: The GITEA_ADMIN_TOKEN is needed because the Gitea service is hidden and inaccessible to other containers.
> Before running e2e tests locally make sure to source the `.env` file: ` set -o allexport && source .env && set +o allexport`

### Without docker

Make sure that npm packages are installed

```console
yarn --cwd e2e
```
then you can run the tests with

```console
cd e2e
yarn
yarn e2e
yarn --cwd e2e e2e --env GITEA_ADMIN_TOKEN=$(scripts/pre_e2e.sh)
```

### GUI
Make sure that npm packages are installed

```console
cd e2e
yarn
yarn gui
yarn --cwd e2e
```
then you can open the GUI with

```console
yarn --cwd e2e gui --env GITEA_ADMIN_TOKEN=$(scripts/pre_e2e.sh)
```



### Recording new visual tests:

Expand Down
1 change: 1 addition & 0 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
- COMMIT_INFO_SHA=${COMMIT_INFO_SHA}
- COMMIT_INFO_TIMESTAMP=${COMMIT_INFO_TIMESTAMP}
- COMMIT_INFO_BRANCH=${COMMIT_INFO_BRANCH}
- CYPRESS_GITEA_ADMIN_TOKEN=${CYPRESS_GITEA_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
Loading

0 comments on commit 61d6ec7

Please sign in to comment.