#20 Run prettier on the whole redaktions-app source

This commit is contained in:
Christoph Lienhard 2021-05-29 00:00:10 +02:00
parent fbc9376575
commit fc7fc9f841
Signed by: christoph.lienhard
GPG key ID: 6B98870DDC270884
15 changed files with 11114 additions and 11152 deletions

View file

@ -1,7 +1,7 @@
# Redaktions App
The "Redaktions App" or editor's app is the main gateway for editors and candidates to alter the database,
e.g. adding new questions (editors) and answering them (candidates).
The "Redaktions App" or editor's app is the main gateway for editors and candidates to alter the database, e.g. adding
new questions (editors) and answering them (candidates).
## Development
@ -18,8 +18,8 @@ The app is written in typescript and react and uses apollo to query the backend
```shell script
docker-compose up
```
which will start the whole setup including this app in a dockerfile.
However, rebuilding and restarting this image can be cumbersome and is not necessary in the development setup.
which will start the whole setup including this app in a dockerfile. However, rebuilding and restarting this image can
be cumbersome and is not necessary in the development setup.
- Instead run
```shell script
npm start
@ -38,13 +38,14 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
You will also see any lint errors in the console.
Running the app without the backend server makes little sense.
Start it under [http://localhost:5000](http://localhost:5000) as specified in the Readme of the backend server (../backend)
Running the app without the backend server makes little sense. Start it
under [http://localhost:5000](http://localhost:5000) as specified in the Readme of the backend server (../backend)
##### `npm test`
Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more
information.
##### `npm run build`
@ -60,8 +61,13 @@ See the section about [deployment](https://facebook.github.io/create-react-app/d
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will
remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right
into your project so you have full control over them. All of the commands except `eject` will still work, but they will
point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you
shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt
customize it when you are ready for it.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

File diff suppressed because it is too large Load diff

View file

@ -32,7 +32,7 @@
"husky": "^4.3.6",
"jest-environment-jsdom-sixteen": "^1.0.3",
"lint-staged": "^10.5.3",
"prettier": "^2.2.1"
"prettier": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",

View file

@ -103,18 +103,17 @@ const getDeletedCategoryMock = (): DeleteCategoryPayload | null => {
: null;
};
export const deleteCategoryMock: Array<
MockedResponse<DeleteCategoryResponse>
> = [
{
request: {
query: DELETE_CATEGORY,
variables: deleteCategoryVariables,
},
result: {
data: {
deleteCategory: getDeletedCategoryMock(),
export const deleteCategoryMock: Array<MockedResponse<DeleteCategoryResponse>> =
[
{
request: {
query: DELETE_CATEGORY,
variables: deleteCategoryVariables,
},
result: {
data: {
deleteCategory: getDeletedCategoryMock(),
},
},
},
},
];
];

View file

@ -116,18 +116,17 @@ const getDeletedQuestionMock = (): DeleteQuestionPayload | null => {
: null;
};
export const deleteQuestionMock: Array<
MockedResponse<DeleteQuestionResponse>
> = [
{
request: {
query: DELETE_QUESTION,
variables: deleteQuestionVariables,
},
result: {
data: {
deleteQuestion: getDeletedQuestionMock(),
export const deleteQuestionMock: Array<MockedResponse<DeleteQuestionResponse>> =
[
{
request: {
query: DELETE_QUESTION,
variables: deleteQuestionVariables,
},
result: {
data: {
deleteQuestion: getDeletedQuestionMock(),
},
},
},
},
];
];

View file

@ -67,54 +67,55 @@ export const getPersonsSortedByRoleAllFilledMock: Array<
},
];
export const getPersonsByRoleNoCandidatesData: GetPersonsSortedByRoleResponse = {
editors: {
nodes: [
{
id: "WyJwZW9wbGUiLDFd",
rowId: 1,
firstName: "Erika",
lastName: "Mustermann",
role: "CANDYMAT_EDITOR",
__typename: "Person",
},
],
__typename: "PeopleConnection",
},
candidates: {
nodes: [],
__typename: "PeopleConnection",
},
users: {
nodes: [
{
id: "WyJwZW9wbGUiLDJd",
rowId: 2,
firstName: "Max",
lastName: "Mustermann",
role: "CANDYMAT_PERSON",
__typename: "Person",
},
{
id: "WyJwZW9wbGUiLDNd",
rowId: 3,
firstName: "Tricia",
lastName: "McMillan",
role: "CANDYMAT_PERSON",
__typename: "Person",
},
{
id: "WyJwZW9wbGUiLDRd",
rowId: 4,
firstName: "Happy",
lastName: "User",
role: "CANDYMAT_PERSON",
__typename: "Person",
},
],
__typename: "PeopleConnection",
},
};
export const getPersonsByRoleNoCandidatesData: GetPersonsSortedByRoleResponse =
{
editors: {
nodes: [
{
id: "WyJwZW9wbGUiLDFd",
rowId: 1,
firstName: "Erika",
lastName: "Mustermann",
role: "CANDYMAT_EDITOR",
__typename: "Person",
},
],
__typename: "PeopleConnection",
},
candidates: {
nodes: [],
__typename: "PeopleConnection",
},
users: {
nodes: [
{
id: "WyJwZW9wbGUiLDJd",
rowId: 2,
firstName: "Max",
lastName: "Mustermann",
role: "CANDYMAT_PERSON",
__typename: "Person",
},
{
id: "WyJwZW9wbGUiLDNd",
rowId: 3,
firstName: "Tricia",
lastName: "McMillan",
role: "CANDYMAT_PERSON",
__typename: "Person",
},
{
id: "WyJwZW9wbGUiLDRd",
rowId: 4,
firstName: "Happy",
lastName: "User",
role: "CANDYMAT_PERSON",
__typename: "Person",
},
],
__typename: "PeopleConnection",
},
};
export const getPersonsSortedByRoleNoCandidatesMock: Array<
MockedResponse<GetPersonsSortedByRoleResponse>

View file

@ -36,7 +36,9 @@ interface AccordionWithEditProps {
title: string;
description: string | null;
subTitle?: string | null;
onEditButtonClick?(): void;
onDeleteButtonClick?(): void;
}

View file

@ -28,9 +28,9 @@ const useStyles = makeStyles((theme) => ({
}));
export default function CategoryList(): React.ReactElement {
const categories = useQuery<GetAllCategoriesResponse, null>(
GET_ALL_CATEGORIES
).data?.allCategories.nodes;
const categories =
useQuery<GetAllCategoriesResponse, null>(GET_ALL_CATEGORIES).data
?.allCategories.nodes;
const classes = useStyles();
const handleAddClick = () => {

View file

@ -52,9 +52,9 @@ export default function DialogChangeQuestion(): React.ReactElement {
},
}
);
const categories = useQuery<GetAllCategoriesResponse, null>(
GET_ALL_CATEGORIES
).data?.allCategories.nodes;
const categories =
useQuery<GetAllCategoriesResponse, null>(GET_ALL_CATEGORIES).data
?.allCategories.nodes;
const [editQuestion, { loading: editLoading }] = useMutation<
EditQuestionResponse,

View file

@ -1,5 +1,4 @@
import { Avatar, Paper, Typography } from "@material-ui/core";
import EditIcon from "@material-ui/icons/Edit";
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import ChangeRole from "./ChangeRole";

View file

@ -28,8 +28,9 @@ const useStyles = makeStyles((theme) => ({
}));
export default function QuestionList(): React.ReactElement {
const questions = useQuery<GetAllQuestionsResponse, null>(GET_ALL_QUESTIONS)
.data?.allQuestions.nodes;
const questions =
useQuery<GetAllQuestionsResponse, null>(GET_ALL_QUESTIONS).data
?.allQuestions.nodes;
const classes = useStyles();
const handleAddButtonClick = () => {

View file

@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
monospace;
}

View file

@ -54,9 +54,10 @@ export const queryAllIconButtons = (
iconPath: string,
container?: HTMLElement
): HTMLElement[] => {
return (container
? queryAllByRole(container, "button")
: screen.queryAllByRole("button")
return (
container
? queryAllByRole(container, "button")
: screen.queryAllByRole("button")
).filter(
(button) =>
button.innerHTML.includes("svg") && button.innerHTML.includes(iconPath)

View file

@ -31,7 +31,8 @@ describe("The UserManagement page", () => {
expect(editor).not.toBeNull();
const candidatesSectionTitle = await screen.findByText(/KandidatInnen/);
const candidatesSection = candidatesSectionTitle.parentElement as HTMLElement;
const candidatesSection =
candidatesSectionTitle.parentElement as HTMLElement;
const candidate1 = await findByText(candidatesSection, /Max Mustermann/);
const candidate2 = await findByText(candidatesSection, /Tricia McMillan/);
expect(candidate1).not.toBeNull();
@ -52,11 +53,13 @@ describe("The UserManagement page", () => {
expect(editor).not.toBeNull();
const candidatesSectionTitle = await screen.findByText(/Kandidat/);
const candidatesSection = candidatesSectionTitle.parentElement as HTMLElement;
const candidatesSection =
candidatesSectionTitle.parentElement as HTMLElement;
expect(candidatesSection.childElementCount).toBe(1);
const otherUsersSectionTitle = await screen.findByText(/Andere/);
const otherUsersSection = otherUsersSectionTitle.parentElement as HTMLElement;
const otherUsersSection =
otherUsersSectionTitle.parentElement as HTMLElement;
const otherUser1 = await findByText(otherUsersSection, /Max Mustermann/);
const otherUser2 = await findByText(otherUsersSection, /Tricia McMillan/);
const otherUser3 = await findByText(otherUsersSection, /Happy User/);