From 7860784d0eb36b337c018a5bf18e75cfc2368175 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Sat, 30 Mar 2024 21:21:32 -0700 Subject: [PATCH 01/10] UI for badge and api --- .../require-submission/route.ts | 40 +++++++++++++++++++ .../DashboardSidePanelOption/index.tsx | 1 + .../DashboardSidebarSubmissionBoxes/index.tsx | 20 +++++----- 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 src/app/api/submission-box/requestedsubmissions/require-submission/route.ts diff --git a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts new file mode 100644 index 00000000..811b2379 --- /dev/null +++ b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts @@ -0,0 +1,40 @@ +import { type NextRequest, NextResponse } from 'next/server' +import { getServerSession } from 'next-auth' +import logger from '@/utils/logger' +import prisma from '@/lib/prisma' + +export async function GET() { + try { + const session = await getServerSession() + if (!session || !session.user?.email) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) + } + + const userId: string = ( + await prisma.user.findUniqueOrThrow({ + where: { + email: session.user.email, + }, + select: { + id: true, + }, + }) + ).id + + const requiredCount = await prisma.requestedSubmission.aggregate({ + where: { + userId: userId, + videoVersions: { none: {}, }, + }, + _count: { + id: true, + }, + }) + + + return NextResponse.json({ requiredCount: requiredCount }, { status: 200 }) + } catch (error) { + logger.error(error) + return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }) + } +} diff --git a/src/components/DashboardSidePanelOption/index.tsx b/src/components/DashboardSidePanelOption/index.tsx index da24e943..d73f5d83 100644 --- a/src/components/DashboardSidePanelOption/index.tsx +++ b/src/components/DashboardSidePanelOption/index.tsx @@ -98,6 +98,7 @@ export default function DashboardSidePanelOption(props: DashboardSidePanelOption color: hoverTitleColor, }, }, + width: '100%', }} onClick={props.isDisabled ? () => {} : props.onClick} > diff --git a/src/components/DashboardSidebarSubmissionBoxes/index.tsx b/src/components/DashboardSidebarSubmissionBoxes/index.tsx index c9fe16f7..512da7c9 100644 --- a/src/components/DashboardSidebarSubmissionBoxes/index.tsx +++ b/src/components/DashboardSidebarSubmissionBoxes/index.tsx @@ -7,6 +7,7 @@ import Box from '@mui/material/Box' import React from 'react' import EditIcon from '@mui/icons-material/Edit' import { SidebarOption } from '@/types/dashboard/sidebar' +import { Badge } from "@mui/material"; export type DashboardSidebarSubmissionBoxesProps = { onCreateNewClick: () => void @@ -47,15 +48,16 @@ export default function DashboardSidebarSubmissionBoxes(props: DashboardSidebarS Submission Invitations - } - onClick={handleMyInvitationsClick} - isSelected={sidebarSelectedOption === 'submission_boxes_my_invitations'} - isDisabled={false} - isAddButton={false} - data-cy='My Requests' - /> + + } + onClick={handleMyInvitationsClick} + isSelected={sidebarSelectedOption === 'submission_boxes_my_invitations'} + isDisabled={false} + isAddButton={false} + data-cy='My Requests' + /> ) From c1d772bcc2c86a564a2e8fd82c911940cb351448 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Sat, 30 Mar 2024 21:23:04 -0700 Subject: [PATCH 02/10] lint --- .../require-submission/route.ts | 4 ++-- .../DashboardSidebarSubmissionBoxes/index.tsx | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts index 811b2379..9d21dd1c 100644 --- a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts +++ b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts @@ -1,4 +1,4 @@ -import { type NextRequest, NextResponse } from 'next/server' +import { NextResponse } from 'next/server' import { getServerSession } from 'next-auth' import logger from '@/utils/logger' import prisma from '@/lib/prisma' @@ -24,7 +24,7 @@ export async function GET() { const requiredCount = await prisma.requestedSubmission.aggregate({ where: { userId: userId, - videoVersions: { none: {}, }, + videoVersions: { none: {} }, }, _count: { id: true, diff --git a/src/components/DashboardSidebarSubmissionBoxes/index.tsx b/src/components/DashboardSidebarSubmissionBoxes/index.tsx index 512da7c9..c542aad4 100644 --- a/src/components/DashboardSidebarSubmissionBoxes/index.tsx +++ b/src/components/DashboardSidebarSubmissionBoxes/index.tsx @@ -7,7 +7,7 @@ import Box from '@mui/material/Box' import React from 'react' import EditIcon from '@mui/icons-material/Edit' import { SidebarOption } from '@/types/dashboard/sidebar' -import { Badge } from "@mui/material"; +import { Badge } from '@mui/material' export type DashboardSidebarSubmissionBoxesProps = { onCreateNewClick: () => void @@ -49,15 +49,15 @@ export default function DashboardSidebarSubmissionBoxes(props: DashboardSidebarS Submission Invitations - } - onClick={handleMyInvitationsClick} - isSelected={sidebarSelectedOption === 'submission_boxes_my_invitations'} - isDisabled={false} - isAddButton={false} - data-cy='My Requests' - /> + } + onClick={handleMyInvitationsClick} + isSelected={sidebarSelectedOption === 'submission_boxes_my_invitations'} + isDisabled={false} + isAddButton={false} + data-cy='My Requests' + /> ) From f56b9bc5efa1f092d5c4461f828db59e85bef002 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Sat, 30 Mar 2024 22:37:53 -0700 Subject: [PATCH 03/10] got api call from frontend working --- .../require-submission/route.ts | 2 +- .../DashboardSidebarSubmissionBoxes/index.tsx | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts index 9d21dd1c..ed74424c 100644 --- a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts +++ b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts @@ -32,7 +32,7 @@ export async function GET() { }) - return NextResponse.json({ requiredCount: requiredCount }, { status: 200 }) + return NextResponse.json({ requiredCount: requiredCount._count.id }, { status: 200 }) } catch (error) { logger.error(error) return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 }) diff --git a/src/components/DashboardSidebarSubmissionBoxes/index.tsx b/src/components/DashboardSidebarSubmissionBoxes/index.tsx index c542aad4..2b0af5b6 100644 --- a/src/components/DashboardSidebarSubmissionBoxes/index.tsx +++ b/src/components/DashboardSidebarSubmissionBoxes/index.tsx @@ -4,10 +4,11 @@ import DashboardSidePanelOption from '@/components/DashboardSidePanelOption' import AddCircleIcon from '@mui/icons-material/AddCircle' import SendIcon from '@mui/icons-material/Send' import Box from '@mui/material/Box' -import React from 'react' +import { useEffect, useState } from 'react' import EditIcon from '@mui/icons-material/Edit' import { SidebarOption } from '@/types/dashboard/sidebar' import { Badge } from '@mui/material' +import { toast } from 'react-toastify' export type DashboardSidebarSubmissionBoxesProps = { onCreateNewClick: () => void @@ -19,6 +20,17 @@ export type DashboardSidebarSubmissionBoxesProps = { export default function DashboardSidebarSubmissionBoxes(props: DashboardSidebarSubmissionBoxesProps) { const { sidebarSelectedOption } = props + const [count, setCount] = useState() + useEffect(() => { + fetch('/api/submission-box/requestedsubmissions/require-submission') + .then(async (res) => { + const { requiredCount } = await res.json() + setCount(requiredCount) + }) + .catch(() => { + toast.error('An error occurred trying to access requested submission count') + }) + }) return ( <> @@ -48,7 +60,7 @@ export default function DashboardSidebarSubmissionBoxes(props: DashboardSidebarS Submission Invitations - + } From 337eb182ffcf55e54a408014b17ce4ebbcc9373f Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Sun, 31 Mar 2024 12:12:50 -0700 Subject: [PATCH 04/10] created frontend tests --- .../e2e/app/dashboard/requestedBadge.cy.ts | 48 +++++++++++++++++++ .../DashboardSidebarSubmissionBoxes/index.tsx | 9 +++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 cypress/e2e/app/dashboard/requestedBadge.cy.ts diff --git a/cypress/e2e/app/dashboard/requestedBadge.cy.ts b/cypress/e2e/app/dashboard/requestedBadge.cy.ts new file mode 100644 index 00000000..5f185c14 --- /dev/null +++ b/cypress/e2e/app/dashboard/requestedBadge.cy.ts @@ -0,0 +1,48 @@ +import { TIMEOUT } from '../../../utils/constants' + +describe('Dashboard requested submission badge count tests', () => { + // User information + const email = 'requested@badge.test' + const password = 'Pass1234' + beforeEach(() => { + cy.task('clearDB') + cy.task('createUser', { email, password }) + cy.visit('/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.reload() + cy.visit('/dashboard') + }) + + it('should not have any badge when the user has no requested submissions', () => { + // Wait for api fetch + cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('exist').should('contain', '') + }) + + it('should increment count when the user has a submission not yet submitted to and decrement it after submission', () => { + const submissionBoxTitle = 'Badge testing simulator' + const videoTitle = 'Get rid of the badge' + cy.task('getUserId', email).then((userId) => { + cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { + cy.reload() + // wait for api fetch + cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') + cy.task('createOneVideoAndRetrieveVideoId', { + title: videoTitle, + }).then((videoId) => { + cy.task('submitVideoToSubmissionBox', { + requestedSubmissionId, + videoId, + }).then(() => { + cy.reload() + cy.get('[data-cy=requested-badge]').should('exist').should('contain', '') + }) + }) + }) + }) + }) +}) \ No newline at end of file diff --git a/src/components/DashboardSidebarSubmissionBoxes/index.tsx b/src/components/DashboardSidebarSubmissionBoxes/index.tsx index 2b0af5b6..d7ec5c39 100644 --- a/src/components/DashboardSidebarSubmissionBoxes/index.tsx +++ b/src/components/DashboardSidebarSubmissionBoxes/index.tsx @@ -60,7 +60,14 @@ export default function DashboardSidebarSubmissionBoxes(props: DashboardSidebarS Submission Invitations - + } From e86ef5e0e4136cc6e357dd1e6c45223c7e142e6d Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Sun, 31 Mar 2024 12:44:51 -0700 Subject: [PATCH 05/10] created api tests --- .../app/api/dashboard/requestedbadge.cy.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 cypress/e2e/app/api/dashboard/requestedbadge.cy.ts diff --git a/cypress/e2e/app/api/dashboard/requestedbadge.cy.ts b/cypress/e2e/app/api/dashboard/requestedbadge.cy.ts new file mode 100644 index 00000000..8d015dc4 --- /dev/null +++ b/cypress/e2e/app/api/dashboard/requestedbadge.cy.ts @@ -0,0 +1,69 @@ +import { TIMEOUT } from '../../../../utils/constants' + +describe('test requested submission required API', () => { + + context('Logged out', () => { + it('should reject any request if not logged in', () => { + cy.request({ + url: '/api/submission-box/requestedsubmissions/require-submission', + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + failOnStatusCode: false, + }).then(async (response) => { + expect(response.status).to.eq(401) + expect(response.body.error).to.eq('Unauthorized') + }) + }) + }) + + context('Logged in', () => { + const email = 'noRequests@user.com' + beforeEach(() => { + cy.task('clearDB') + const password = 'Pass1234' + cy.task('createUser', { email, password }) + cy.visit('/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.reload() + }) + + it('should return nothing when user does not have any requests', () => { + cy.request({ + url: '/api/submission-box/requestedsubmissions/require-submission', + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }).then(async (response) => { + expect(response.status).to.eq(200) + expect(response.body.requiredCount).to.eq(0) + }) + }) + + it('should return the number of requested submissions needing to be submitted to', () => { + const submissionBoxTitle = 'multiple submissions' + cy.task('getUserId', email).then((userId) => { + cy.task('createRequestSubmissionForUser', { userId, submissionBoxTitle }) + cy.task('createRequestSubmissionForUser', { userId, submissionBoxTitle }) + cy.task('createRequestSubmissionForUser', { userId, submissionBoxTitle }) + cy.task('createRequestSubmissionForUser', { userId, submissionBoxTitle }) + }) + cy.reload() + cy.request({ + url: '/api/submission-box/requestedsubmissions/require-submission', + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + }).then(async (response) => { + expect(response.status).to.eq(200) + expect(response.body.requiredCount).to.eq(4) + }) + }) + }) +}) From e3c47ca9b15f293379649f2a1773b2435a6c56e0 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Sun, 31 Mar 2024 12:55:14 -0700 Subject: [PATCH 06/10] EOF line --- cypress/e2e/app/dashboard/requestedBadge.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/app/dashboard/requestedBadge.cy.ts b/cypress/e2e/app/dashboard/requestedBadge.cy.ts index 5f185c14..ef148170 100644 --- a/cypress/e2e/app/dashboard/requestedBadge.cy.ts +++ b/cypress/e2e/app/dashboard/requestedBadge.cy.ts @@ -45,4 +45,4 @@ describe('Dashboard requested submission badge count tests', () => { }) }) }) -}) \ No newline at end of file +}) From 93e305d8a1a6f82fbca898535a7536df26c406e0 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Mon, 1 Apr 2024 11:30:24 -0700 Subject: [PATCH 07/10] Addressed changes --- ...uestedbadge.cy.ts => requestedBadge.cy.ts} | 0 .../e2e/app/dashboard/requestedBadge.cy.ts | 70 +++++++++++++++++++ .../require-submission/route.ts | 7 +- 3 files changed, 74 insertions(+), 3 deletions(-) rename cypress/e2e/app/api/dashboard/{requestedbadge.cy.ts => requestedBadge.cy.ts} (100%) diff --git a/cypress/e2e/app/api/dashboard/requestedbadge.cy.ts b/cypress/e2e/app/api/dashboard/requestedBadge.cy.ts similarity index 100% rename from cypress/e2e/app/api/dashboard/requestedbadge.cy.ts rename to cypress/e2e/app/api/dashboard/requestedBadge.cy.ts diff --git a/cypress/e2e/app/dashboard/requestedBadge.cy.ts b/cypress/e2e/app/dashboard/requestedBadge.cy.ts index ef148170..1c88ecbb 100644 --- a/cypress/e2e/app/dashboard/requestedBadge.cy.ts +++ b/cypress/e2e/app/dashboard/requestedBadge.cy.ts @@ -45,4 +45,74 @@ describe('Dashboard requested submission badge count tests', () => { }) }) }) + + it('should increment the count after users remove the submission from a requested submission', () => { + const submissionBoxTitle = 'Badge testing simulator' + const videoTitle = 'Get rid of the badge' + cy.task('getUserId', email).then((userId) => { + cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { + cy.reload() + // wait for api fetch + cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') + cy.task('createOneVideoAndRetrieveVideoId', { + title: videoTitle, + ownerId: userId, + }).then((videoId) => { + cy.task('submitVideoToSubmissionBox', { + requestedSubmissionId, + videoId, + }).then(() => { + cy.reload() + cy.visit('/dashboard?tab=my-invitations') + cy.get('[data-cy="My Invitations"]') + cy.wait(1000) + cy.get('[data-cy="My Invitations"]').click() + cy.get(`[data-cy="${ submissionBoxTitle }"]`) + cy.wait(1000) + cy.get(`[data-cy="${ submissionBoxTitle }"]`).click() + cy.wait(1000) + cy.get('[data-cy="unsubmit-button"]').should('be.visible').click() + cy.get('button').last().should('be.visible').and('have.text', 'Yes').click() + + cy.visit('/dashboard') + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') + }) + }) + }) + }) + }) + + it('should increment the count after users deletes the video submission of a requested submission', () => { + const submissionBoxTitle = 'Badge testing simulator' + const videoTitle = 'Get rid of the badge' + cy.task('getUserId', email).then((userId) => { + cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { + cy.reload() + // wait for api fetch + cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') + cy.task('createOneVideoAndRetrieveVideoId', { + title: videoTitle, + ownerId: userId, + }).then((videoId) => { + cy.task('submitVideoToSubmissionBox', { + requestedSubmissionId, + videoId, + }).then(() => { + cy.reload() + cy.wait(1000) + cy.get('[data-cy="video-list"]').children().first().should('contain', videoTitle).click() + cy.wait(1000) + cy.get('[data-cy="edit-icon"]').click() + cy.get('[data-cy="detail-video-delete-button"]').click() + cy.get('[data-cy="detail-video-delete-confirm-button"]').click() + + cy.visit('/dashboard') + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') + }) + }) + }) + }) + }) }) diff --git a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts index ed74424c..ce756bcc 100644 --- a/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts +++ b/src/app/api/submission-box/requestedsubmissions/require-submission/route.ts @@ -4,12 +4,14 @@ import logger from '@/utils/logger' import prisma from '@/lib/prisma' export async function GET() { + // This API will return the count of requested submissions that the user has not yet submitted to, call with GET try { + // Check if a user is logged in const session = await getServerSession() if (!session || !session.user?.email) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) } - + // Get userId const userId: string = ( await prisma.user.findUniqueOrThrow({ where: { @@ -20,7 +22,7 @@ export async function GET() { }, }) ).id - + // This query returns the count of requested submissions with a videoVersions of none const requiredCount = await prisma.requestedSubmission.aggregate({ where: { userId: userId, @@ -31,7 +33,6 @@ export async function GET() { }, }) - return NextResponse.json({ requiredCount: requiredCount._count.id }, { status: 200 }) } catch (error) { logger.error(error) From 5926c4dc5b2c21179af0f72ec64dcb5da2310e35 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Mon, 1 Apr 2024 11:37:48 -0700 Subject: [PATCH 08/10] Get rid of width --- src/components/DashboardSidePanelOption/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/DashboardSidePanelOption/index.tsx b/src/components/DashboardSidePanelOption/index.tsx index d73f5d83..da24e943 100644 --- a/src/components/DashboardSidePanelOption/index.tsx +++ b/src/components/DashboardSidePanelOption/index.tsx @@ -98,7 +98,6 @@ export default function DashboardSidePanelOption(props: DashboardSidePanelOption color: hoverTitleColor, }, }, - width: '100%', }} onClick={props.isDisabled ? () => {} : props.onClick} > From 92634e5094377998a656a8194a6519a982b26410 Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Mon, 1 Apr 2024 12:28:57 -0700 Subject: [PATCH 09/10] Changed where to assert the badge icon --- cypress/e2e/app/dashboard/requestedBadge.cy.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/app/dashboard/requestedBadge.cy.ts b/cypress/e2e/app/dashboard/requestedBadge.cy.ts index 1c88ecbb..2482cd69 100644 --- a/cypress/e2e/app/dashboard/requestedBadge.cy.ts +++ b/cypress/e2e/app/dashboard/requestedBadge.cy.ts @@ -52,9 +52,6 @@ describe('Dashboard requested submission badge count tests', () => { cy.task('getUserId', email).then((userId) => { cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { cy.reload() - // wait for api fetch - cy.wait(1000) - cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') cy.task('createOneVideoAndRetrieveVideoId', { title: videoTitle, ownerId: userId, @@ -64,6 +61,7 @@ describe('Dashboard requested submission badge count tests', () => { videoId, }).then(() => { cy.reload() + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '') cy.visit('/dashboard?tab=my-invitations') cy.get('[data-cy="My Invitations"]') cy.wait(1000) @@ -89,9 +87,6 @@ describe('Dashboard requested submission badge count tests', () => { cy.task('getUserId', email).then((userId) => { cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { cy.reload() - // wait for api fetch - cy.wait(1000) - cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') cy.task('createOneVideoAndRetrieveVideoId', { title: videoTitle, ownerId: userId, @@ -101,6 +96,7 @@ describe('Dashboard requested submission badge count tests', () => { videoId, }).then(() => { cy.reload() + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '') cy.wait(1000) cy.get('[data-cy="video-list"]').children().first().should('contain', videoTitle).click() cy.wait(1000) From 88e5426589831dc0e2e8cedb4bcb32e2e868beca Mon Sep 17 00:00:00 2001 From: Erin Hiebert Date: Mon, 1 Apr 2024 13:18:46 -0700 Subject: [PATCH 10/10] readded previous assert statement --- cypress/e2e/app/dashboard/requestedBadge.cy.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/app/dashboard/requestedBadge.cy.ts b/cypress/e2e/app/dashboard/requestedBadge.cy.ts index 2482cd69..7c39adc7 100644 --- a/cypress/e2e/app/dashboard/requestedBadge.cy.ts +++ b/cypress/e2e/app/dashboard/requestedBadge.cy.ts @@ -52,6 +52,9 @@ describe('Dashboard requested submission badge count tests', () => { cy.task('getUserId', email).then((userId) => { cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { cy.reload() + // wait for api fetch + cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') cy.task('createOneVideoAndRetrieveVideoId', { title: videoTitle, ownerId: userId, @@ -61,6 +64,7 @@ describe('Dashboard requested submission badge count tests', () => { videoId, }).then(() => { cy.reload() + cy.wait(1000) cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '') cy.visit('/dashboard?tab=my-invitations') cy.get('[data-cy="My Invitations"]') @@ -87,6 +91,9 @@ describe('Dashboard requested submission badge count tests', () => { cy.task('getUserId', email).then((userId) => { cy.task('createRequestSubmissionForUser', {userId, submissionBoxTitle}).then((requestedSubmissionId) => { cy.reload() + // wait for api fetch + cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '1') cy.task('createOneVideoAndRetrieveVideoId', { title: videoTitle, ownerId: userId, @@ -96,8 +103,8 @@ describe('Dashboard requested submission badge count tests', () => { videoId, }).then(() => { cy.reload() - cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '') cy.wait(1000) + cy.get('[data-cy=requested-badge]').should('be.visible').should('contain', '') cy.get('[data-cy="video-list"]').children().first().should('contain', videoTitle).click() cy.wait(1000) cy.get('[data-cy="edit-icon"]').click()