Skip to content

Commit

Permalink
e2e: remove authRedirect.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulrhmnGhanem committed Apr 10, 2023
1 parent c1e4030 commit deea697
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 204 deletions.
187 changes: 0 additions & 187 deletions e2e/cypress/integration/authRedirects.spec.js

This file was deleted.

18 changes: 8 additions & 10 deletions e2e/cypress/integration/multiProject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Render project cards', () => {
})
})

it.only('should display card thumbnail', () => {
it('should display card thumbnail', () => {
const user = getFakeUser()

// Migrate the multiproject repo
Expand All @@ -53,6 +53,11 @@ describe('Render project cards', () => {
// Migrate the normal repo
cy.importRepo(syncedRepoUrl, normalRepoName, user)

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: 100_000 }).should('be.visible')

cy.visit(`/${user.username}`)
// There should be 3 cards = 2 form multiprojects + 1 normal project
cy.get('[data-cy=project-card]', { timeout: 60_000 }).should(
Expand Down Expand Up @@ -133,10 +138,7 @@ describe('Multi project page', () => {
// Migrate the multiproject repo
cy.importRepo(syncedRepoUrlMultiProjects, multiProjectsRepoName, user)

cy.url({ timeout: 60_000 }).should(
'contain',
`${user.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: 60_000 }).as('projectCards')

Expand All @@ -152,7 +154,6 @@ describe('Multi project page', () => {

// Different page elements should be visible.
const pageComponents = [
'sync-msg',
'info-bar',
'board-showcase',
'board-showcase-top',
Expand All @@ -175,10 +176,7 @@ describe('Multi project page', () => {
// Migrate the multiproject repo
cy.importRepo(syncedRepoUrlMultiProjects, multiProjectsRepoName, user)

cy.url({ timeout: 10_000 }).should(
'contain',
`${user.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 }).should(
'have.length',
Expand Down
27 changes: 20 additions & 7 deletions e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,31 @@ Cypress.Commands.add('createGiteaUser', user => {

const url = 'http://gitea.kitspace.test:3000/api/v1/admin/users'

// check if the user already exists
cy.request({
url,
method: 'POST',
url: `http://gitea.kitspace.test:3000/api/v1/users/${user.username}`,
method: 'GET',
headers,
body: JSON.stringify(user),
failOnStatusCode: false,
}).then(response => {
if (!response.status === 201) {
throw new Error('Failed to create user')
if (response.status === 200) {
return response.body
}

return response.body
// if the user doesn't exist, create a new user and return the user object.
return cy
.request({
url,
method: 'POST',
headers,
body: JSON.stringify(user),
failOnStatusCode: false,
})
.then(response => {
if (response.status !== 201) {
throw new Error('Failed to create user')
}
return response.body
})
})
})

Expand Down

0 comments on commit deea697

Please sign in to comment.