Skip to content

Commit

Permalink
made adjustments according to shashi comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaineng committed Jul 18, 2024
2 parents 38a0fa3 + 53d0681 commit 4abbda0
Show file tree
Hide file tree
Showing 50 changed files with 161 additions and 51 deletions.
38 changes: 5 additions & 33 deletions .github/workflows/ci.yml → .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,10 @@
name: LGT Jest & Playwright Tests
name: E2E Tests

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
jest-test:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_APPWRITE_API_URL: ${{ secrets.NEXT_PUBLIC_APPWRITE_API_URL }}
NEXT_PUBLIC_APPWRITE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_APPWRITE_PROJECT_ID }}
NEXT_PUBLIC_APPWRITE_DATABASE_ID: ${{ secrets.NEXT_PUBLIC_APPWRITE_DATABASE_ID }}
APPWRITE_API_KEY: ${{ secrets.APPWRITE_API_KEY }}
strategy:
matrix:
node-version: ['20.x']

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install
- name: tests
run: pnpm test

test-e2e-setup:
name: Setup E2E Tests
runs-on: ubuntu-latest
Expand All @@ -49,9 +21,9 @@ jobs:
- name: Get URL
run: echo "https://${{ steps.vercel_preview_url.outputs.preview_url }}"

test_e2e:
test-e2e:
needs: test-e2e-setup
name: Playwright Tests
name: E2E Tests
timeout-minutes: 5
runs-on: ubuntu-latest
env:
Expand All @@ -64,8 +36,8 @@ jobs:
with:
node-version: lts/*
- run: npm install -g pnpm && pnpm install
- run: pnpm exec playwright install --with-deps
- run: pnpm exec playwright test
- run: pnpm exec playwright install --with-deps
- run: pnpm exec playwright test
- name: Upload Artifacts
uses: actions/upload-artifact@v4
if: always()
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Jest Unit Tests

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
jest-test:
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_APPWRITE_API_URL: ${{ secrets.NEXT_PUBLIC_APPWRITE_API_URL }}
NEXT_PUBLIC_APPWRITE_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_APPWRITE_PROJECT_ID }}
NEXT_PUBLIC_APPWRITE_DATABASE_ID: ${{ secrets.NEXT_PUBLIC_APPWRITE_DATABASE_ID }}
APPWRITE_API_KEY: ${{ secrets.APPWRITE_API_KEY }}
strategy:
matrix:
node-version: ['20.x']

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Install dependencies
run: pnpm install
- name: tests
run: pnpm test
2 changes: 1 addition & 1 deletion api/apiFunctions.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { IEntry } from '@/app/league/[leagueId]/entry/Entries.interface';
import { IEntry } from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

export interface IAccountData {
email: string;
Expand Down
2 changes: 1 addition & 1 deletion api/apiFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Query } from 'appwrite';
import {
IEntry,
IEntryProps,
} from '@/app/league/[leagueId]/entry/Entries.interface';
} from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

/**
* Register a new account
Expand Down
14 changes: 14 additions & 0 deletions app/(admin)/admin/leagues/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminLeagues = (): JSX.Element => {
return <div>Admin Leagues</div>;
};

export default AdminLeagues;
14 changes: 14 additions & 0 deletions app/(admin)/admin/notifications/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminNotifications = (): JSX.Element => {
return <div>Admin Notifications</div>;
};

export default AdminNotifications;
14 changes: 14 additions & 0 deletions app/(admin)/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminHome = (): JSX.Element => {
return <div>Admin Home</div>;
};

export default AdminHome;
14 changes: 14 additions & 0 deletions app/(admin)/admin/players/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import { JSX } from 'react';

/**
* Renders the admin page.
* @returns {JSX.Element} - The rendered login page.
*/
const AdminPlayers = (): JSX.Element => {
return <div>Admin Players</div>;
};

export default AdminPlayers;
46 changes: 46 additions & 0 deletions app/(admin)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Gridiron Survivor.
// Licensed under the MIT License.

import React, { JSX } from 'react';
import { GeistSans } from 'geist/font/sans';
import '../globals.css';
import { AuthContextProvider } from '@/context/AuthContextProvider';
import ErrorBoundary from '../error';
import { Toaster } from 'react-hot-toast';

const defaultUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: 'http://localhost:3000';

export const metadata = {
metadataBase: new URL(defaultUrl),
title: 'GridIron Survivor',
description: 'Fantasy Football Survivor Pool',
};

/**
* The root layout for the application.
* @param props - The props
* @param props.children - The children
* @returns The rendered root layout.
*/
const RootLayout = ({
children,
}: {
children: React.ReactNode;
}): JSX.Element => {
return (
<html lang="en" className={GeistSans.className}>
<body className="dark:dark bg-background pb-8 px-4 text-foreground xl:pb-0">
<ErrorBoundary>
<AuthContextProvider>
<main>{children}</main>
<Toaster />
</AuthContextProvider>
</ErrorBoundary>
</body>
</html>
);
};

export default RootLayout;
4 changes: 2 additions & 2 deletions app/layout.tsx → app/(main)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import React, { JSX } from 'react';
import { GeistSans } from 'geist/font/sans';
import './globals.css';
import '../globals.css';
import Nav from '@/components/Nav/Nav';
import { AuthContextProvider } from '@/context/AuthContextProvider';
import ErrorBoundary from './error';
import ErrorBoundary from '../error';
import { Toaster } from 'react-hot-toast';

const defaultUrl = process.env.VERCEL_URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const Entry = ({
<LeagueEntries
key={entry.$id}
entryName={entry.name}
isPickSet={isPickSet}
isPickSet
linkUrl={linkUrl}
teamLogo={teamLogo}
/>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/login/page.test.tsx → app/(main)/login/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jest.mock('next/navigation', () => ({
},
}));

jest.mock('../../context/AuthContextProvider', () => ({
jest.mock('../../../context/AuthContextProvider', () => ({
useAuthContext() {
return {
...mockUseAuthContext,
Expand Down
2 changes: 1 addition & 1 deletion app/login/page.tsx → app/(main)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
FormField,
FormItem,
FormMessage,
} from '../../components/Form/Form';
} from '../../../components/Form/Form';

const LoginUserSchema = z.object({
email: z
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { toast } from 'react-hot-toast';
const mockLogin = jest.fn();
const mockPush = jest.fn();

jest.mock('../../api/apiFunctions', () => ({
jest.mock('../../../api/apiFunctions', () => ({
registerAccount: jest.fn(),
}));

Expand Down Expand Up @@ -37,7 +37,7 @@ jest.mock('next/navigation', () => ({
},
}));

jest.mock('../../context/AuthContextProvider', () => ({
jest.mock('../../../context/AuthContextProvider', () => ({
useAuthContext() {
return mockUseAuthContext;
},
Expand Down
2 changes: 1 addition & 1 deletion app/register/page.tsx → app/(main)/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
FormField,
FormItem,
FormMessage,
} from '../../components/Form/Form';
} from '../../../components/Form/Form';
import { toast } from 'react-hot-toast';
import Alert from '@/components/AlertNotification/AlertNotification';
import { AlertVariants } from '@/components/AlertNotification/Alerts.enum';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ const alertVariants = cva(
const Alert = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
>(({ variant, children }) => (
>(({ variant, children }, ref) => (
<div
role="alert"
className={alertVariants({ variant })}
ref={ref}
>{children}</div>
));
Alert.displayName = 'Alert';
Expand Down
3 changes: 2 additions & 1 deletion components/LeagueCard/LeagueCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ const LeagueCard = React.forwardRef<HTMLAnchorElement, ILeagueCardProps>(
survivors,
title,
totalPlayers,
}) => (
}, ref) => (
<Link
data-testid="LeagueCard"
href={href}
className={cn(
'LeagueCard flex max-h-32 place-items-center gap-6 rounded-lg border bg-card p-4 text-card-foreground shadow-sm dark:border-zinc-800 hover:bg-zinc-800 transition',
)}
ref={ref}
>
<Image
alt="League Logo"
Expand Down
2 changes: 1 addition & 1 deletion components/LeagueEntries/LeagueEntries.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export interface ILeagueEntriesProps {
linkUrl: string;
isEliminated?: boolean;
isPickSet?: boolean;
teamLogo?: string;
teamLogo: string;
}
2 changes: 1 addition & 1 deletion components/LeagueEntries/LeagueEntries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const LeagueEntries = ({
linkUrl,
isEliminated = false,
isPickSet = false,
teamLogo = '',
teamLogo,
}: ILeagueEntriesProps): JSX.Element => (
<div
data-testid="league-entry-container-card"
Expand Down
2 changes: 1 addition & 1 deletion components/Nav/Nav.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import Nav from './Nav';
import Login from '@/app/login/page';
import Login from '@/app/(main)/login/page';

const mockPush = jest.fn();
const mockUsePathname = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion utils/utils.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IUser,
IWeeklyPicks,
} from '@/api/apiFunctions.interface';
import { IEntry } from '@/app/league/[leagueId]/entry/Entries.interface';
import { IEntry } from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

export interface IGetGameData {
userId: IUser['id'];
Expand Down
4 changes: 2 additions & 2 deletions utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
IGetUserPick,
} from './utils.interface';
import { ILeague } from '@/api/apiFunctions.interface';
import { IEntry } from '@/app/league/[leagueId]/entry/Entries.interface';
import { IEntry } from '@/app/(main)/league/[leagueId]/entry/Entries.interface';

/**
* Combine class names
Expand Down Expand Up @@ -143,4 +143,4 @@ export const getUserLeagues = async (
*/
export const getUserEntries = async (userId: IUser['id'], leagueId: ILeague['leagueId']): Promise<IEntry[]> => {
return await getCurrentUserEntries(userId, leagueId);
}
}

0 comments on commit 4abbda0

Please sign in to comment.