Skip to content
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

TRI-29994 Add and fix lint testing #125

Merged
merged 3 commits into from
Nov 1, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/tests.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ jobs:
cache: 'npm'
cache-dependency-path: ui/package-lock.json
- run: npm ci
- run: npm run lint
- run: npm run build --if-present
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "vite",
"build": "tsc --noEmit && vite build",
"build-stage": "tsc --noEmit && vite build --mode staging",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives",
"preview": "vite preview"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Provider as JotaiProvider } from 'jotai';
import { ThemeProvider, createTheme } from '@mui/material';
import AboutUs from './pages/AboutUs/AboutUs';
import { customTheme } from './theme';
import FAQ from './pages/FAQ/FAQ';
import { FAQ } from './pages/FAQ/FAQ';
import Tutorial from './pages/Tutorial/Tutorial';

const queryClient = new QueryClient();
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Footer/Footer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import Footer from './Footer';
import { MemoryRouter } from 'react-router-dom';

test('renders Header correctly', async () => {
test('renders Header correctly', () => {
render(<Footer />, { wrapper: MemoryRouter });

const faq = screen.getByText('FAQ');
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import Header from './Header';
import { MemoryRouter } from 'react-router-dom';

test('renders Header correctly', async () => {
test('renders Header correctly', () => {
render(<Header />, { wrapper: MemoryRouter });

const faq = screen.getByText('FAQ');
Expand Down
1 change: 0 additions & 1 deletion ui/src/contexts/README.md

This file was deleted.

38 changes: 0 additions & 38 deletions ui/src/contexts/countContext.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const formatOxidationState = ({ counts, oxidationStates, symbols }: Table
finalString += symbol + oxidationState + ' ';
} else if (counts[index] % 1 === 0) {
finalArr.push(formatOxidationStateWithWholeNumberCount(index, symbol, counts[index], oxidationState));
finalString += ~~counts[index] + symbol + oxidationState + ' ';
finalString += `${~~counts[index]}${symbol}${oxidationState} `;
} else {
finalArr.push(formatOxidationStateWithDecimalCount(index, symbol, counts[index], oxidationState));
finalString += counts[index].toFixed(2) + symbol + oxidationState + ' ';
Expand Down
16 changes: 6 additions & 10 deletions ui/src/pages/FAQ/FAQ.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ import PageWrapper from '@/components/PageWrapper/PageWrapper';
import styles from './FAQ.module.css';
import { Accordion, AccordionDetails, AccordionSummary, Breadcrumbs, Button, Link, Typography } from '@mui/material';
import { useEffect, useState } from 'react';
import { FAQs } from '@/pages/FAQ/FAQUtil/FAQText';
import { FAQ_ITEMS, URL_FAQ_STRING_MATCH } from './faq-util/faq-text';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import ExpandLessIcon from '@mui/icons-material/ExpandLess';

const URL_FAQ_STRING_MATCH = 'faq-';

const FAQ = () => {
export function FAQ() {
const [expanded, setExpanded] = useState<string[]>([]);
const [expandAll, setExpandAll] = useState<boolean>(false);

const allAccordians = FAQs.map((_value, index) => `panel${index}`);
const allAccordians = FAQ_ITEMS.map((_value, index) => `panel${index}`);

useEffect(() => {
document.title = 'Oxidation State Analyzer - FAQ';
Expand All @@ -23,7 +21,7 @@ const FAQ = () => {
if (indexOfNumber !== -1) {
const panelNumberString = currentUrl.slice(indexOfNumber);
const panelNumber = Number.parseInt(panelNumberString);
if (!Number.isNaN(panelNumber) && panelNumber >= 0 && panelNumber < FAQs.length) {
if (!Number.isNaN(panelNumber) && panelNumber >= 0 && panelNumber < FAQ_ITEMS.length) {
if (panelNumber > 5) document.getElementById(`faq-${panelNumber}`)?.scrollIntoView();
setExpanded([`panel${panelNumber}`]);
}
Expand Down Expand Up @@ -78,7 +76,7 @@ const FAQ = () => {
</Button>
</div>
<div className={styles.accordiansContainer}>
{FAQs.map((value, index) => {
{FAQ_ITEMS.map((value, index) => {
const panelName = `panel${index}`;
return (
<Accordion
Expand Down Expand Up @@ -111,6 +109,4 @@ const FAQ = () => {
</div>
</PageWrapper>
);
};

export default FAQ;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export interface FAQText {
answer: string;
}

export const FAQs: FAQText[] = [
export const URL_FAQ_STRING_MATCH = 'faq-';

export const FAQ_ITEMS: FAQText[] = [
{
question: 'How can I cite the Oxidation State Analyzer?',
//answer: 'If you would like to cite the oxidation state analyzer, please reference the following manuscript: PLACEHOLDER. You can directly export this reference to a citation manager by clicking on one of the following links: PLACEHOLDER'
Expand Down
9 changes: 8 additions & 1 deletion ui/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/// <reference types="vite/client" />
declare const AWS_CONFIG: any;
declare const AWS_CONFIG: {
Auth: {
region: string;
userPoolId: string;
userPoolWebClientId: string;
mandatorySignIn: boolean;
};
};
declare const API_BASE_URL: string;
declare const AMPLIFY_ENABLED: boolean;
declare const dataLayer: Record<string, string>[];
Loading