Skip to content

Prettier and black setup for code formatting #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ secret.story.*
*.secret.*
.idea
.idea/*
server/uploads/*
server/uploads/*

server/tests/__pycache__/
3 changes: 1 addition & 2 deletions client/.babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
"presets": ["@babel/preset-env", "@babel/preset-react"]
}

23 changes: 14 additions & 9 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet">
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap"
rel="stylesheet"
/>
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
Expand All @@ -21,10 +27,9 @@
<title>Annotate Lab</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="app" style="height: 100vh;"></div> <!-- Changed the height from 80vh to 100vh to make it cover the entire page -->
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="app" style="height: 100vh"></div>
<!-- Changed the height from 80vh to 100vh to make it cover the entire page -->
<!-- <script>window.global = window;</script> -->
<script type="module" src="src/index.jsx"></script>
<!--
Expand Down
3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"scripts": {
"start": "vite --force",
"build": "vite build",
"test": "jest"
"test": "jest",
"format": "prettier --write ."
},
"eslintConfig": {
"extends": "react-app"
Expand Down
59 changes: 31 additions & 28 deletions client/src/AlertDialog/AlertDialog.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import AlertDialog from './index';
import React from "react"
import { render, fireEvent, screen } from "@testing-library/react"
import "@testing-library/jest-dom"
import AlertDialog from "./index"

describe('AlertDialog Component', () => {
const handleClose = jest.fn();
const handleExit = jest.fn();
const title = "Are you sure you want to exit?";
const description = "Do you really want to exit? This action will clear the storage and all data will be lost.";
const exitConfirm = "Agree";
const exitCancel = "Cancel";
describe("AlertDialog Component", () => {
const handleClose = jest.fn()
const handleExit = jest.fn()
const title = "Are you sure you want to exit?"
const description =
"Do you really want to exit? This action will clear the storage and all data will be lost."
const exitConfirm = "Agree"
const exitCancel = "Cancel"

beforeEach(() => {
render(
Expand All @@ -21,23 +22,25 @@ describe('AlertDialog Component', () => {
description={description}
exitConfirm={exitConfirm}
exitCancel={exitCancel}
/>
);
});
/>,
)
})

test('renders the alert dialog with correct title and description', () => {
expect(screen.getByTestId('alert-dialog')).toBeInTheDocument();
expect(screen.getByTestId('alert-dialog-title')).toHaveTextContent(title);
expect(screen.getByTestId('alert-dialog-description')).toHaveTextContent(description);
});
test("renders the alert dialog with correct title and description", () => {
expect(screen.getByTestId("alert-dialog")).toBeInTheDocument()
expect(screen.getByTestId("alert-dialog-title")).toHaveTextContent(title)
expect(screen.getByTestId("alert-dialog-description")).toHaveTextContent(
description,
)
})

test('calls handleClose when cancel button is clicked', () => {
fireEvent.click(screen.getByTestId('disagree-button'));
expect(handleClose).toHaveBeenCalledTimes(1);
});
test("calls handleClose when cancel button is clicked", () => {
fireEvent.click(screen.getByTestId("disagree-button"))
expect(handleClose).toHaveBeenCalledTimes(1)
})

test('calls handleExit when agree button is clicked', () => {
fireEvent.click(screen.getByTestId('agree-button'));
expect(handleExit).toHaveBeenCalledTimes(1);
});
});
test("calls handleExit when agree button is clicked", () => {
fireEvent.click(screen.getByTestId("agree-button"))
expect(handleExit).toHaveBeenCalledTimes(1)
})
})
37 changes: 25 additions & 12 deletions client/src/AlertDialog/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import * as React from 'react';
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import * as React from "react"
import Button from "@mui/material/Button"
import Dialog from "@mui/material/Dialog"
import DialogActions from "@mui/material/DialogActions"
import DialogContent from "@mui/material/DialogContent"
import DialogContentText from "@mui/material/DialogContentText"
import DialogTitle from "@mui/material/DialogTitle"

export const AlertDialog = (props) => {
const { open, handleClose, handleExit, title, description, exitConfirm, exitCancel } = props;
const {
open,
handleClose,
handleExit,
title,
description,
exitConfirm,
exitCancel,
} = props

return (
<Dialog
Expand All @@ -21,18 +29,23 @@ export const AlertDialog = (props) => {
{title}
</DialogTitle>
<DialogContent data-testid="alert-dialog-content">
<DialogContentText id="alert-dialog-description" data-testid="alert-dialog-description">
<DialogContentText
id="alert-dialog-description"
data-testid="alert-dialog-description"
>
{description}
</DialogContentText>
</DialogContent>
<DialogActions data-testid="alert-dialog-actions">
<Button onClick={handleClose} data-testid="disagree-button">{exitCancel}</Button>
<Button onClick={handleClose} data-testid="disagree-button">
{exitCancel}
</Button>
<Button onClick={handleExit} autoFocus data-testid="agree-button">
{exitConfirm}
</Button>
</DialogActions>
</Dialog>
);
)
}

export default AlertDialog;
export default AlertDialog
Loading
Loading