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 4, 2023
2 parents 5c5ed1d + c33be78 commit 388dc33
Show file tree
Hide file tree
Showing 39 changed files with 308 additions and 1,975 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,28 @@ 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: |
scripts/generate_e2e_fixtures.sh
# start gitea so we can generate the admin token required for e2e
docker-compose -f docker-compose.yml -f docker-compose.deploy.yml up -d
until docker logs kitspace_gitea_1 | grep -q 'ORM engine initialization successful' ; do sleep 3s; done
token="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)"
docker-compose stop
echo "CYPRESS_GITEA_ADMIN_TOKEN=${token}" >> $GITHUB_ENV
- name: e2e
timeout-minutes: 40
Expand Down
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,30 +328,37 @@ We configure our staging servers using [Ansible](https://docs.ansible.com/ansibl

## Running Integration Tests

1. Make sure the frontend is being served at [http://kitspace.test:3000](http://kitspace.test:3000); by following the "Set Up" steps. You can use one of the following options.
Make sure that:
1. the frontend is being served at [http://kitspace.test:3000](http://kitspace.test:3000); by following the "Set Up" steps. You can use one of the following options.
2. test fixtures are generated: `scripts/generate_e2e_fixtures.sh`
3. npm packages are installed: `yarn --cwd e2e` (when running the tests outside of docker).

### Run the tests in a docker container

> Note: The GITEA_ADMIN_TOKEN is needed when because the Gitea service is hidden and inaccessible to other containers.
### 1. Run the tests in a docker container
```console
export CYPRESS_GITEA_ADMIN_TOKEN="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)"
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.e2e.yml up e2e
```
##


### Without docker

### 2. Without docker
```console
cd e2e
yarn
yarn e2e
export CYPRESS_GITEA_ADMIN_TOKEN="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)"
yarn --cwd e2e e2e
```

### GUI

### 3. GUI
```console
cd e2e
yarn
yarn gui
export CYPRESS_GITEA_ADMIN_TOKEN="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)"
yarn --cwd e2e gui
```



### Recording new visual tests:

1. Make sure you have Chrome installed on your machine.
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 388dc33

Please sign in to comment.