Skip to content

Commit

Permalink
Updated with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedgemon4 committed Jan 17, 2024
2 parents fffe0b5 + 0c3d35e commit a92c9c8
Show file tree
Hide file tree
Showing 65 changed files with 2,709 additions and 607 deletions.
9 changes: 8 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import getRequestedSubmissions from './cypress/tasks/getRequestedSubmissions'
import createSubmissionBoxWithEmail from './cypress/tasks/createSubmissionBoxWithEmail'
import loadInSubmissionBoxes from './cypress/tasks/loadInSubmissionBoxes'
import loadOutSubmissionBoxes from './cypress/tasks/loadOutSubmissionBoxes'
import submitVideoToSubmissionBox from './cypress/tasks/submitVideoToSubmissionBox'
import createRequestSubmissionForUser from './cypress/tasks/createRequestSubmissionForUser'

require('dotenv').config()

Expand All @@ -33,6 +35,8 @@ export default defineConfig({
getLatestVideo,
loadInSubmissionBoxes,
loadOutSubmissionBoxes,
submitVideoToSubmissionBox,
createRequestSubmissionForUser,
})
},
experimentalModifyObstructiveThirdPartyCode: true,
Expand All @@ -49,8 +53,11 @@ export default defineConfig({
},

env: {
CYPRESS_RUN_LOCAL_ONLY: process.env.CYPRESS_RUN_LOCAL_ONLY,
CYPRESS_RUN_LOCAL_ONLY: process.env.CYPRESS_RUN_LOCAL_ONLY?.toLowerCase() === 'true',
},

viewportWidth: 1920,
viewportHeight: 1080,
},

component: {
Expand Down
11 changes: 7 additions & 4 deletions cypress/e2e/app/api/dashboard/requestedsubmissions.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { v4 as uuidv4 } from 'uuid'

describe('Test requested submission API', () => {

beforeEach(() => {
Expand All @@ -19,7 +21,7 @@ describe('Test requested submission API', () => {

context('Logged in', () => {
it('should return an empty submissionBox array when a user does not have any outgoing submission boxes', () => {
const email = 'noSubmission@user.com'
const email = 'noSubmission' + uuidv4() + '@user.com'
const password = 'noSubmission1'

cy.visit('/signup')
Expand Down Expand Up @@ -47,17 +49,18 @@ describe('Test requested submission API', () => {
})

it('should return a correct submissionBox array of outgoing submission boxes when a user has outgoing submission boxes', () => {
const email = 'submission@out.box'
const email = 'submission' + uuidv4() + '@out.box'
const password = 'submissionOut1'
const title = 'Outgoing Submission Box'
const title = 'Outgoing Submission Box ' + uuidv4()
const description = null
const closesAt = new Date('2050-12-01T03:24:00')
const videoStoreToDate = null
const maxVideoLength = null
const isPublic = false

// Load database
cy.task('loadOutSubmissionBoxes')
cy.task('loadOutSubmissionBoxes', { email, password, title })

// Login
cy.visit('/login')
cy.get('[data-cy=email]').type(email)
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/app/dashboard/myboxes.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ describe('Dashboard My Submission Boxes Tests', () => {
cy.visit('/dashboard')
runWithRetry(() => {
cy.get('[data-cy="My Boxes"]', { timeout: TIMEOUT.EXTRA_LONG }).click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'myboxes')
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'dashboard')
})
cy.get('[data-cy="no submission text"]', { timeout: TIMEOUT.EXTRA_LONG })
cy.get('[data-cy="no-submission-text"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.and('contain', 'You Do Not Have Any Active Submission Boxes')
.and('contain', 'You Do Not Have Any Submission Boxes')
})

it('should display incoming submission boxes for a user that has incoming submission boxes', () => {
Expand All @@ -52,7 +52,7 @@ describe('Dashboard My Submission Boxes Tests', () => {
cy.visit('/dashboard')
runWithRetry(() => {
cy.get('[data-cy="My Boxes"]', { timeout: TIMEOUT.EXTRA_EXTRA_LONG }).click()
cy.url({ timeout: TIMEOUT.EXTRA_EXTRA_LONG }).should('contain', 'myboxes')
cy.url({ timeout: TIMEOUT.EXTRA_EXTRA_LONG }).should('contain', 'dashboard')
})
cy.get('[data-cy="Incoming Submission Box"]', { timeout: TIMEOUT.EXTRA_EXTRA_LONG })
.should('be.visible')
Expand Down
16 changes: 9 additions & 7 deletions cypress/e2e/app/dashboard/requestedsubmissions.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TIMEOUT } from '../../../utils/constants'
import runWithRetry from '../../../utils/runUntilExist'
import { v4 as uuidv4 } from 'uuid'

describe('Dashboard Requested Submission Boxes Tests', () => {
beforeEach(() => {
Expand Down Expand Up @@ -28,18 +29,19 @@ describe('Dashboard Requested Submission Boxes Tests', () => {

cy.visit('/dashboard')
cy.get('[data-cy="My Requests"]', { timeout: TIMEOUT.EXTRA_LONG }).click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'requestedsubmissions')
cy.get('[data-cy="no submission text"]', { timeout: TIMEOUT.EXTRA_LONG })
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'dashboard')
cy.get('[data-cy="no-submission-text"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.and('contain', 'You Have Not Submitted To Any Active Submission Boxes')
.and('contain', 'You Do Not Have Any Submission Boxes')
})

it('should display outgoing submission boxes for a user that has outgoing submission boxes', () => {
const email = 'submission@out.box'
const password = 'submissionOut1'
const title = 'Outgoing Submission Box' + uuidv4()

// Load database
cy.task('loadOutSubmissionBoxes')
cy.task('loadOutSubmissionBoxes', { email, password, title })
// Login
cy.visit('/login')
cy.get('[data-cy=email]').type(email)
Expand All @@ -50,10 +52,10 @@ describe('Dashboard Requested Submission Boxes Tests', () => {
cy.visit('/dashboard')
runWithRetry(() => {
cy.get('[data-cy="My Requests"]', { timeout: TIMEOUT.EXTRA_EXTRA_LONG }).click()
cy.url({ timeout: TIMEOUT.EXTRA_EXTRA_LONG }).should('contain', 'requestedsubmissions')
cy.url({ timeout: TIMEOUT.EXTRA_EXTRA_LONG }).should('contain', 'dashboard')
})
cy.get('[data-cy="Outgoing Submission Box"]', { timeout: TIMEOUT.EXTRA_EXTRA_LONG })
cy.get(`[data-cy="${ title }"]`, { timeout: TIMEOUT.EXTRA_EXTRA_LONG })
.should('be.visible')
.and('contain', 'Outgoing Submission Box')
.and('contain', title)
})
})
97 changes: 97 additions & 0 deletions cypress/e2e/app/dashboard/searchBar.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { v4 as uuidv4 } from 'uuid'
import { TIMEOUT } from '../../../utils/constants'

describe('Dashboard Search Bar', () => {
let email: string

beforeEach(() => {
cy.task('clearDB')

email = 'user' + uuidv4() + '@example.com'
const password = 'Password1'

// Sign up
cy.visit('/signup')
cy.get('[data-cy="email"]').type(email)
cy.get('[data-cy="password"]').type(password)
cy.get('[data-cy="passwordConfirmation"]').type(password)
cy.get('[data-cy="submit"]').click()
cy.url().should('contain', 'login')

// Login
cy.get('[data-cy=email]').type(email)
cy.get('[data-cy=password]').type(password)
cy.get('[data-cy=submit]').click()
cy.url({ timeout: TIMEOUT.EXTRA_EXTRA_LONG }).should('not.contain', 'login')
})

it('should display search bar', () => {
cy.visit('/dashboard')
cy.get('[data-cy="dashboard-search-bar"]').should('be.visible')
})

it('should only display searched videos', () => {
cy.visit('/dashboard')

const visibleVideo1 = 'Test Video Title ' + uuidv4()
const visibleVideo2 = 'Test Video Title ' + uuidv4()
const videoShouldNotBeDisplayed = 'Not Display' + uuidv4()
cy.task('getUserId', email).then((userId) => {
cy.task('createRequestSubmissionForUser', { userId }).then((submissionBoxId) => {
cy.task('createOneVideoAndRetrieveVideoId', { ownerId: userId, title: visibleVideo1 }).then((videoId) => {
cy.task('submitVideoToSubmissionBox', { requestedSubmissionId: submissionBoxId, videoId })
})
cy.task('createOneVideoAndRetrieveVideoId', { ownerId: userId, title: visibleVideo2 }).then((videoId) => {
cy.task('submitVideoToSubmissionBox', { requestedSubmissionId: submissionBoxId, videoId })
})
cy.task('createOneVideoAndRetrieveVideoId', { ownerId: userId, title: videoShouldNotBeDisplayed }).then(
(videoId) => {
cy.task('submitVideoToSubmissionBox', { requestedSubmissionId: submissionBoxId, videoId })
}
)
})
})

cy.reload()
cy.get('[data-cy="video-list"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.children()
.should('have.length', 3)

cy.get('[data-cy="dashboard-search-bar"]').type('Test Video Title')


cy.get('[data-cy="video-list"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.children()
.should('have.length', 2)
})


it('should display different string when no videos are found', () => {
cy.visit('/dashboard')

cy.get('[data-cy="no-video-text"]', { timeout: TIMEOUT.EXTRA_LONG }).should('be.visible').should('contain', 'You Do Not Have Any Videos')

const videoShouldNotBeDisplayed = 'Not Display' + uuidv4()
cy.task('getUserId', email).then((userId) => {
cy.task('createRequestSubmissionForUser', { userId }).then((submissionBoxId) => {
cy.task('createOneVideoAndRetrieveVideoId', { ownerId: userId, title: videoShouldNotBeDisplayed }).then(
(videoId) => {
cy.task('submitVideoToSubmissionBox', { requestedSubmissionId: submissionBoxId, videoId })
}
)
})
})

cy.reload()
cy.get('[data-cy="video-list"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.children()
.should('have.length', 1)

cy.get('[data-cy="dashboard-search-bar"]').type('Random String')

cy.get('[data-cy="no-video-text"]', { timeout: TIMEOUT.EXTRA_LONG }).should('be.visible').should('contain', 'There Are No Videos That Match This Search')
})
})
143 changes: 143 additions & 0 deletions cypress/e2e/app/dashboard/videoTabs.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { TIMEOUT } from '../../../utils/constants'
import { v4 as uuidv4 } from 'uuid'

describe('Dashboard Recent Videos Tests', () => {
if (!Cypress.env('CYPRESS_RUN_LOCAL_ONLY')) {
// TODO: Remove this when we have a way to get the video ID (aka using Cognito)
it.skip('Skipped in production', () => {})
return
}

beforeEach(() => {
cy.task('clearDB')
})

it('should not display any recent videos when no video is provided', () => {
const email = 'noVideos@box.com'
const password = 'noSubmissions1'

cy.visit('/signup')

// Sign up
cy.visit('/signup')
cy.get('[data-cy="email"]').type(email)
cy.get('[data-cy="password"]').type(password)
cy.get('[data-cy="passwordConfirmation"]').type(password)
cy.get('[data-cy="submit"]').click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'login')

// Login
cy.get('[data-cy=email]').type(email)
cy.get('[data-cy=password]').type(password)
cy.get('[data-cy=submit]').click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('not.contain', 'login')

cy.visit('/dashboard')
cy.get('[data-cy="Recent"]')
.should('be.visible')
.and('contain', 'Recent')
.and('have.css', 'background-color', 'rgb(225, 240, 255)') // Check if the tab is focused

cy.get('[data-cy="no-video-text"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.and('contain', 'You Do Not Have Any Videos')
})

it('should display sent videos when a user has sent videos', () => {
const email = 'user' + uuidv4() + '@example.com'
const password = 'randomPasswordCool1'

// Sign up
cy.visit('/signup')
cy.get('[data-cy="email"]').type(email)
cy.get('[data-cy="password"]').type(password)
cy.get('[data-cy="passwordConfirmation"]').type(password)
cy.get('[data-cy="submit"]').click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'login')

// Create submission box and submit video
const videoTitle = 'Test Video Title ' + uuidv4()
cy.task('getUserId', email).then((userId) => {
cy.task('createRequestSubmissionForUser', { userId }).then((submissionBoxId) => {
cy.task('createOneVideoAndRetrieveVideoId', { ownerId: userId, title: videoTitle }).then((videoId) => {
cy.task('submitVideoToSubmissionBox', { requestedSubmissionId: submissionBoxId, videoId })
})
})
})

// Login
cy.get('[data-cy=email]').type(email)
cy.get('[data-cy=password]').type(password)
cy.get('[data-cy=submit]').click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('not.contain', 'login')

cy.visit('/dashboard')

cy.get('[data-cy="video-list"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.children()
.should('have.length', 1)

cy.get('[data-cy="video-list"]').children().first().should('contain', videoTitle)

cy.get('[data-cy="Submitted Videos"]').click()
cy.get('[data-cy="Submitted Videos"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.should('have.css', 'background-color', 'rgb(225, 240, 255)') // Check if the tab is focused


cy.get('[data-cy="video-list"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.children()
.should('have.length', 1)

cy.get('[data-cy="video-list"]').children().first().should('contain', videoTitle)

})

it('should display received videos when a user has received videos', () => {
const email = 'user' + uuidv4() + '@example.com'
const password = 'randomPasswordCool1'

// Sign up
cy.visit('/signup')
cy.get('[data-cy="email"]').type(email)
cy.get('[data-cy="password"]').type(password)
cy.get('[data-cy="passwordConfirmation"]').type(password)
cy.get('[data-cy="submit"]').click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'login')

// Create submission box and submit video
const videoTitle = 'Test Video Title ' + uuidv4()
const submissionBoxTitle = 'Test Submission Box ' + uuidv4()
cy.task('getUserId', email).then((userId) => {
cy.task('createSubmissionBoxWithEmail', { userId, submissionBoxTitle }).then((submissionBoxId) => {
cy.task('createOneVideoAndRetrieveVideoId', { title: videoTitle }).then((videoId) => {
cy.task('submitVideoToSubmissionBox', { requestedSubmissionId: submissionBoxId, videoId })
})
})
})

// Login
cy.get('[data-cy=email]').type(email)
cy.get('[data-cy=password]').type(password)
cy.get('[data-cy=submit]').click()
cy.url({ timeout: TIMEOUT.EXTRA_LONG }).should('not.contain', 'login')

cy.visit('/dashboard')

cy.get('[data-cy="video-list"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.children()
.should('have.length', 1)

cy.get('[data-cy="video-list"]').children().first().should('contain', videoTitle)

cy.get('[data-cy="Submitted Videos"]').click()
cy.get('[data-cy="Submitted Videos"]', { timeout: TIMEOUT.EXTRA_LONG })
.should('be.visible')
.should('have.css', 'background-color', 'rgb(225, 240, 255)') // Check if the tab is focused

cy.get('[data-cy="no-video-text"]', { timeout: TIMEOUT.EXTRA_LONG }).should('contain', 'You Do Not Have Any Videos')
})
})
4 changes: 2 additions & 2 deletions cypress/e2e/app/signup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('Sign up tests', () => {

cy.url().should('include', '/signup')

cy.get('.Toastify__toast-container').should('be.visible').and('contain', 'The input email is not valid')
cy.contains('.Toastify__toast-container', 'The input email is not valid').should('be.visible')
})

it('Should navigate to login when clicking on Already have an account?', () => {
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('Sign up tests', () => {
const email = 'red@is.sus'
const password = 'Password1'

cy.task('createSubmissionBoxWithEmail', email)
cy.task('createSubmissionBoxWithEmail', { email })

cy.visit('/signup')

Expand Down
Loading

0 comments on commit a92c9c8

Please sign in to comment.