Skip to content

Commit 2961deb

Browse files
authored
Merge pull request #31 from oslabs-beta/revert-29-acc-add-tests
Revert
2 parents 39760b4 + 265aac0 commit 2961deb

File tree

14 files changed

+118
-427
lines changed

14 files changed

+118
-427
lines changed

src/components/AccTestComponent/AccTestTypes/AccTestTypes.module.scss

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/components/AccTestComponent/AccTestTypes/AccTestTypes.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/components/AccTestComponent/PuppeteerUrl/PuppeteerUrl.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/components/Modals/Modal.jsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const Modal = ({
1515
dispatchToMockData,
1616
dispatchTestCase,
1717
createTest,
18-
testType = null,
19-
puppeteerUrl = 'sample.io',
2018
}) => {
2119
const { copySuccess, codeRef, handleCopy } = useCopy();
2220
const { handleNewTest } = useNewTest(
@@ -26,7 +24,7 @@ const Modal = ({
2624
closeModal,
2725
);
2826

29-
const script = useGenerateScript(title, testType, puppeteerUrl);
27+
const script = useGenerateScript(title);
3028

3129
const modalStyles = {
3230
overlay: {
@@ -63,15 +61,6 @@ const Modal = ({
6361
<code ref={codeRef}>
6462
{script}
6563
</code>
66-
67-
{testType === 'react'
68-
?
69-
<p id={styles.endpoint}>
70-
Requires React version 16 or less.
71-
</p>
72-
: null
73-
}
74-
7564
<p id={styles.endpoint}>
7665
Note if you are using Create React App do not install jest
7766
</p>

src/components/Modals/modalHooks.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,15 @@ export function useNewTest(dispatchToMockData, dispatchTestCase, createTest, clo
3535
return { handleNewTest };
3636
}
3737

38-
export function useGenerateScript(test, testType = null, puppeteerUrl = 'sample.io') {
38+
export function useGenerateScript(test) {
3939
const [{ projectFilePath }] = useContext(GlobalContext);
4040
switch (test) {
4141
case 'acc':
42-
if (testType === 'html') {
43-
return (
44-
`cd ${projectFilePath}
45-
npm i -D axe-core regenerator-runtime jest
46-
jest`
47-
);
48-
}
49-
if (testType === 'react') {
50-
return (
51-
`cd ${projectFilePath}
52-
npm i -D axe-core regenerator-runtime jest enzyme enzyme-adapter-react-16
53-
jest`
54-
);
55-
}
56-
if (testType === 'puppeteer') {
57-
return (
58-
`cd ${projectFilePath}
59-
npm i -D axe-core puppeteer
60-
node <YOUR_DIR_PATH/TEST_FILE.JS> ${puppeteerUrl}
61-
`
62-
);
63-
64-
}
65-
return 'error';
42+
return (
43+
`cd ${projectFilePath}\n` +
44+
'npm i -D axe-core regenerator-runtime jest\n' +
45+
'jest'
46+
);
6647
case 'react':
6748
return (
6849
`cd ${projectFilePath}\n` +

src/components/SearchInput/SearchInput.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ul.react-test-options li.option-active {
4848
}
4949

5050
.flex-item {
51-
width: 200px;
51+
width: 50%;
5252
margin-right: 7%;
5353
input {
5454
margin-top: 6px;

src/components/TestCase/AccTestCase.tsx

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
import React, { useContext, ChangeEvent } from 'react';
22
import cn from 'classnames';
33
import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd';
4+
import styles from './TestCase.module.scss';
45
import {
56
updateDescribeText,
67
updateItStatementText,
78
updateDescribeOrder,
89
updateItStatementOrder,
9-
updateFilePath,
10-
updateTestType,
11-
createPuppeteerUrl,
1210
} from '../../context/actions/accTestCaseActions';
13-
import {
14-
AccTestCaseContext,
15-
} from '../../context/reducers/accTestCaseReducer';
1611
import { GlobalContext } from '../../context/reducers/globalReducer';
12+
import SearchInput from '../SearchInput/SearchInput';
1713

18-
import styles from './TestCase.module.scss';
1914
import AccTestMenu from '../TestMenu/AccTestMenu';
20-
import AccTestTypes from '../AccTestComponent/AccTestTypes/AccTestTypes';
21-
import PuppeteerUrl from '../AccTestComponent/PuppeteerUrl/PuppeteerUrl';
22-
import SearchInput from '../SearchInput/SearchInput';
15+
2316
import DecribeRenderer from '../AccTestComponent/DescribeRenderer/DescribeRenderer';
17+
import { updateImportFilePath } from '../../context/actions/accTestCaseActions';
18+
import {
19+
AccTestCaseContext,
20+
} from '../../context/reducers/accTestCaseReducer';
2421

2522
const AccTestCase = () => {
26-
const [accTestCase, dispatchToAccTestCase] = useContext(AccTestCaseContext);
23+
const [accTestCase, dispatchToAccTestCase] = useContext(
24+
AccTestCaseContext,
25+
);
2726

28-
const { describeBlocks, itStatements, testType } = accTestCase;
27+
const { describeBlocks, itStatements } = accTestCase;
2928

3029
const [{ filePathMap }] = useContext<any>(GlobalContext);
3130

@@ -63,33 +62,20 @@ const AccTestCase = () => {
6362

6463
return (
6564
<div id={styles.AccTestCase}>
65+
6666
<div id="head">
6767
<AccTestMenu />
6868
</div>
6969

7070
<section id={styles.testCaseHeader}>
71-
<div id={styles.accTestDiv}>
72-
<AccTestTypes
71+
<label htmlFor="fileImport">Import File From</label>
72+
<div id={styles.labelInput} style={{ width: '80%' }}>
73+
<SearchInput
74+
options={Object.keys(filePathMap)}
7375
dispatch={dispatchToAccTestCase}
74-
action={updateTestType}
75-
currType={testType}
76+
action={updateImportFilePath}
77+
filePathMap={filePathMap}
7678
/>
77-
78-
{testType === 'puppeteer' ? (
79-
<PuppeteerUrl dispatch={dispatchToAccTestCase} action={createPuppeteerUrl} />
80-
) : (
81-
<div>
82-
<label htmlFor="fileImport">Import File From</label>
83-
<div id={styles.labelInput} style={{ width: '80%' }}>
84-
<SearchInput
85-
options={Object.keys(filePathMap)}
86-
dispatch={dispatchToAccTestCase}
87-
action={updateFilePath}
88-
filePathMap={filePathMap}
89-
/>
90-
</div>
91-
</div>
92-
)}
9379
</div>
9480

9581
<DragDropContext onDragEnd={onDragEnd}>
@@ -116,6 +102,7 @@ const AccTestCase = () => {
116102
</Droppable>
117103
</DragDropContext>
118104
</section>
105+
119106
</div>
120107
);
121108
};

src/components/TestCase/TestCase.module.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,3 @@ div {
149149
align-items: center;
150150
margin-top: 6px;
151151
}
152-
153-
#accTestDiv {
154-
display: flex;
155-
justify-content: flex-start;
156-
}

src/components/TestMenu/AccTestMenu.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { AccTestCaseContext } from '../../context/reducers/accTestCaseReducer';
1515
import { useToggleModal } from './testMenuHooks';
1616

17+
1718
const AccTestMenu = () => {
1819
// link to accessibility testing docs url
1920
const accUrl = 'https://www.deque.com/axe/core-documentation/api-documentation/';
@@ -24,7 +25,7 @@ const AccTestMenu = () => {
2425
const [{ projectFilePath, file, exportBool }, dispatchToGlobal] = useContext<any>(GlobalContext);
2526
const generateTest = useGenerateTest('acc', projectFilePath);
2627

27-
// setValidCode to true on load.
28+
// setValidCode to true on load.
2829
useEffect(() => {
2930
dispatchToGlobal(setValidCode(true));
3031
}, []);
@@ -67,8 +68,6 @@ const AccTestMenu = () => {
6768
dispatchToMockData={null}
6869
dispatchTestCase={dispatchToAccTestCase}
6970
createTest={createNewTest}
70-
testType={accTestCase.testType}
71-
puppeteerUrl={accTestCase.puppeteerUrl}
7271
/>
7372
{/* Just send user to docs on button click */}
7473
</div>
@@ -82,7 +81,8 @@ const AccTestMenu = () => {
8281
</button>
8382
</div>
8483
</div>
85-
</div>
84+
</div>
85+
8686
);
8787
}
8888

src/context/actions/accTestCaseActions.ts

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,37 @@ export const actionTypes = {
1616
CLOSE_INFO_MODAL: 'CLOSE_INFO_MODAL',
1717

1818
UPDATE_FILE_PATH: 'UPDATE_FILE_PATH',
19-
UPDATE_TEST_TYPE: 'UPDATE_TEST_TYPE',
20-
CREATE_PUPPETEER_URL: 'CREATE_PUPPETEER_URL',
2119

2220
TOGGLE_ACC: 'TOGGLE_ACC',
2321
};
2422

2523
/* --------------------------------- Actions -------------------------------- */
2624

27-
export const addDescribeBlock = () => ({
28-
type: actionTypes.ADD_DESCRIBE_BLOCK,
29-
});
25+
export const addDescribeBlock = () => {
26+
return {
27+
type: actionTypes.ADD_DESCRIBE_BLOCK,
28+
};
29+
};
3030

31-
export const deleteDescribeBlock = (describeId: string) => ({
32-
type: actionTypes.DELETE_DESCRIBE_BLOCK,
33-
describeId,
34-
});
31+
export const deleteDescribeBlock = (describeId: string) => {
32+
return {
33+
type: actionTypes.DELETE_DESCRIBE_BLOCK,
34+
describeId,
35+
};
36+
};
3537

3638
export const updateDescribeText = (text: string, describeId: string) => ({
3739
type: actionTypes.UPDATE_DESCRIBE_TEXT,
3840
text,
3941
describeId,
4042
});
4143

42-
export const updateDescribeOrder = (reorderedDescribe: Array<string>) => ({
43-
type: actionTypes.UPDATE_DESCRIBE_ORDER,
44-
reorderedDescribe,
45-
});
44+
export const updateDescribeOrder = (reorderedDescribe: Array<string>) => {
45+
return {
46+
type: actionTypes.UPDATE_DESCRIBE_ORDER,
47+
reorderedDescribe,
48+
};
49+
};
4650

4751
export const addItStatement = (describeId: string) => ({
4852
type: actionTypes.ADD_ITSTATEMENT,
@@ -61,36 +65,28 @@ export const updateItStatementText = (text: string, itId: string) => ({
6165
text,
6266
});
6367

64-
export const updateItStatementOrder = (reorderedIt: Array<string>, describeId: string) => ({
65-
type: actionTypes.UPDATE_ITSTATEMENT_ORDER,
66-
reorderedIt,
67-
describeId,
68-
});
68+
export const updateItStatementOrder = (reorderedIt: Array<string>, describeId: string) => {
69+
return {
70+
type: actionTypes.UPDATE_ITSTATEMENT_ORDER,
71+
reorderedIt,
72+
describeId,
73+
};
74+
};
6975

7076
export const createNewTest = () => ({
7177
type: actionTypes.CREATE_NEW_TEST,
7278
});
7379

74-
export const openInfoModal = () => ({
75-
type: actionTypes.OPEN_INFO_MODAL,
76-
});
80+
export const openInfoModal = () => {
81+
return { type: actionTypes.OPEN_INFO_MODAL };
82+
};
7783

78-
export const closeInfoModal = () => ({
79-
type: actionTypes.CLOSE_INFO_MODAL,
80-
});
84+
export const closeInfoModal = () => {
85+
return { type: actionTypes.CLOSE_INFO_MODAL };
86+
};
8187

82-
export const updateFilePath = (fileName: string, filePath: string) => ({
88+
export const updateImportFilePath = (fileName: string, filePath: string) => ({
8389
type: actionTypes.UPDATE_FILE_PATH,
8490
fileName,
8591
filePath,
8692
});
87-
88-
export const updateTestType = (testType: string) => ({
89-
type: actionTypes.UPDATE_TEST_TYPE,
90-
testType,
91-
});
92-
93-
export const createPuppeteerUrl = (puppeteerUrl: string) => ({
94-
type: actionTypes.CREATE_PUPPETEER_URL,
95-
puppeteerUrl,
96-
});

0 commit comments

Comments
 (0)