Skip to content

Commit

Permalink
cleaned up file comments, fixed test, deleted console.logs, removed u…
Browse files Browse the repository at this point in the history
…nused folders, fixed package.json
  • Loading branch information
JakeGillan committed May 16, 2023
1 parent f14db0a commit 3cdeb2b
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 1,735 deletions.
6 changes: 3 additions & 3 deletions __tests__/client/components/pages/testCreator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('TestCreator Test', () => {
a: true,
href: '/',
})}`).toBe(`cy.xpath('//a[@data-test="sidenav-home"]/div[2]/span[1]').click();
cy.location('pathname').should('eq','/');`);
cy.location('pathname').should("contains",'/');`);
});
it('should generate Cypress test for assertion', () => {
expect(`${switchCase({
Expand All @@ -50,7 +50,7 @@ describe('TestCreator Test', () => {
},
URL: 'http://localhost:3000/signin',
a: false,
})}`).toBe(`cy.xpath(\'//a[@data-test="sidenav-user-settings"]/div[2]/span[1]\').should(\'exist\');cy.xpath(\'//a[@data-test="sidenav-user-settings"]/div[2]/span[1]\').should(\'have.html\',"My Account").and(\'be.visible\');cy.xpath(\'//a[@data-test="sidenav-user-settings"]/div[2]/span[1]\').should(\'have.attr\', \'MuiTypography-root MuiListItemText-primary MuiTypography-body1 MuiTypography-displayBlock\');`);
})}`).toBe(`cy.xpath('//a[@data-test="sidenav-user-settings"]/div[2]/span[1]').should('exist');cy.xpath('//a[@data-test="sidenav-user-settings"]/div[2]/span[1]').should('have.html',"My Account").and('be.visible');cy.xpath('//a[@data-test="sidenav-user-settings"]/div[2]/span[1]').should('have.class', 'MuiTypography-root MuiListItemText-primary MuiTypography-body1 MuiTypography-displayBlock');`);
});
});
describe('Integration test for describeCreator', () => {
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('TestCreator Test', () => {
],
};
it('This will take our describe obj from panel.js and return the final cypress code. It will pass through describeCreator -> itCreator -> actionCreator -> switchCase', () => {
expect(`${describeCreator(describeObj)}`).toContain(`//Trydent is cool
expect(`${describeCreator(describeObj)}`).toContain(` //Trydent is cool
describe('', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/')
Expand Down
3 changes: 0 additions & 3 deletions client/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import CodeBlock from './pages/CodeBlock';

// MASTER REPO-IMPORTS LIST
// repo-imports necessary to prevent bundling errors.
// ###TODO - remove imports that are not used in any other file
// --- --- --- --- --- --- --- --- ---
import { describeCreator } from '../utils/testCreator';
// ./client/utils/types folder
import { Describe, itObject, EventObj } from '../utils/types/types';

/**
Expand Down
4 changes: 2 additions & 2 deletions client/components/pages/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react'; // ###TODO: useEffect is never used. Remove it?
import React, { useState, useEffect } from 'react';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
import prettier from 'prettier/standalone';
Expand Down Expand Up @@ -55,7 +55,7 @@ const CodeBlock: React.FC = () => {
const handleMessageEvent = (event: MessageEvent) => {
if (event.data.type === 'GENERATED_CODE') {
const inputText = event.data.code;
console.log(inputText);
// console.log(inputText);
const formatted = prettierFormat(inputText);
setFormattedText(formatted);
}
Expand Down
3 changes: 0 additions & 3 deletions client/components/pages/WelcomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ const WelcomePage: React.FC = () => {
<li>Once you are ready, "Start Test"</li>
<li>Trydent won't start recording until you ask, so click 'Start Recording' on the next page when you're ready</li>
</ol>
{/* <p>Remember, `describe` breaks your test suite into components. </p>
<p>`it` statements further break down `describe` tests into smaller individual tests</p> */}

</details>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "vite",
"build": "vite build && tsc",
"build:watch": "vite build --watch",
"serve": "vite preview",
"serve": "vite preview"
},
"dependencies": {
"prettier": "^2.8.8",
Expand Down
1 change: 0 additions & 1 deletion client/utils/inputLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function inputEventListener(event: Event, callback: any): void {
console.log(`User interaction with element: ${xPath}, Event type: click`);
callback({ xPath, eventType });
break;
// case 'input':
case 'change':
inputValue = (event.target as HTMLInputElement).value;
console.log(`User interaction with element: ${xPath}, Event type: input, Input value: ${inputValue}`);
Expand Down
7 changes: 1 addition & 6 deletions client/utils/testCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ function switchCase(event: EventObj): string {
* @returns {string} Full cypress test suite to be sent to user
*/
export function describeCreator(obj: Describe): string {
// destructuring the 'describe' object
const { URL, description, writeUp, itStatements } = obj;
let resultStr;
//create line for 'describe' statement in which we call the itCreator?
// ###TO-DO: push 'it' statement down to itCreator
return (resultStr = `
//${writeUp}
describe('${description}', () => {
Expand All @@ -70,7 +67,6 @@ export function describeCreator(obj: Describe): string {
* @param {string} URL - URL of the page to be tested.
* @returns {string} - Concatenated string of 'it' statements.
*/
// ###TO-DO: Fully convert to TypeScript
function itCreator(itStatementsArr: itObject[], URL: string): string {
// Initialize empty array to push formatted 'it' statements into
const formattedItStatments = [];
Expand Down Expand Up @@ -111,5 +107,4 @@ function actionCreator(eObj: itObject, URL: string): string {
return resultText;
}

export default {switchCase, describeCreator};

export default {switchCase, describeCreator};
Empty file removed cypress/e2e/tydent.cy.js
Empty file.
Empty file removed cypress/support/commands.js
Empty file.
Empty file removed cypress/support/e2e.js
Empty file.
24 changes: 0 additions & 24 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ chrome.runtime.onConnect.addListener((connection) => {
* @param {Object} message - The message object
*/
const devToolsListener = function (message) {
// console.log('we are in background.js');

chrome.scripting.executeScript({
target: { tabId: message.tabId },
Expand All @@ -40,7 +39,6 @@ chrome.runtime.onConnect.addListener((connection) => {
* @listens chrome.tab.onActivated
*/
chrome.tabs.onActivated.addListener(() => {
// console.log('changed to tab: ', tabId);
chrome.scripting.executeScript({
target: { tabId: message.tabId },
files: [message.scriptToInject],
Expand All @@ -64,30 +62,8 @@ chrome.runtime.onConnect.addListener((connection) => {
* @param {Object} message - The message object
*/
chrome.runtime.onMessage.addListener((message) => {
// Check event and proceed message accordingly
switch (message.action) {
case 'click':
// console.log('Clicked, message: ', message);
break;
case 'focus':
// console.log('Focused, message: ', message);
break;
case 'blur':
// console.log('Blurred, message: ', message);
break;
case 'change':
// console.log('Changed, message: ', message);
break;
case 'keydown':
// console.log('keydown, message: ', message);
break;
default:
// console.log('Unknown event, message: ', message);
}
if (devToolsConnection) {
devToolsConnection.postMessage(message);
} else {
// console.error('devToolsConnection is not established yet');
}
});

Expand Down
2 changes: 1 addition & 1 deletion extension/bundles/components/pages/CodeBlock.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState, useEffect } from 'react'; // ###TODO: useEffect is never used. Remove it?
import { useState, useEffect } from 'react';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
import prettier from 'prettier/standalone';
Expand Down
4 changes: 0 additions & 4 deletions extension/bundles/utils/testCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ function switchCase(event) {
* @returns {string} Full cypress test suite to be sent to user
*/
export function describeCreator(obj) {
// destructuring the 'describe' object
const { URL, description, writeUp, itStatements } = obj;
let resultStr;
//create line for 'describe' statement in which we call the itCreator?
// ###TO-DO: push 'it' statement down to itCreator
return (resultStr = `
//${writeUp}
describe('${description}', () => {
Expand All @@ -67,7 +64,6 @@ export function describeCreator(obj) {
* @param {string} URL - URL of the page to be tested.
* @returns {string} - Concatenated string of 'it' statements.
*/
// ###TO-DO: Fully convert to TypeScript
function itCreator(itStatementsArr, URL) {
// Initialize empty array to push formatted 'it' statements into
const formattedItStatments = [];
Expand Down
6 changes: 0 additions & 6 deletions extension/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ function inputEventListener(event, callback) {
//
case 'readystatechange':
initialValue = 'N/A';
console.log('RSC');
callback({ XPath: '', eventType });
break;
case 'focus':
Expand Down Expand Up @@ -142,15 +141,10 @@ function inputEventListener(event, callback) {
// Store the current window's URL
const URL = window.location.href;

// console.log('DOM fully loaded and parsed');

// Add event listeners for 'click', 'focus', 'blur', and 'change' events
['click', 'focus', 'blur', 'change', 'keydown', 'keyup', 'mouseover', 'readystatechange'].forEach((action) => {
document.addEventListener(action, (event) => {
// Call the inputEventListener for each event
// console.log('action: ', action);
// console.log('event: ', event);
// setTimeout(console.log('action: ', action), 1000);
inputEventListener(event, (recordedEvent) => {
const { xPath, eventType, inputValue } = recordedEvent;
// Send the xPath as a message to the window
Expand Down
4 changes: 0 additions & 4 deletions extension/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ chrome.runtime.onMessage.addListener((message) => {
if (message.a === true) message.action = 'navigate';
if (isRecording === true) {
// Add the message to the event array
console.log(message)
eventArr.push(message);
console.log('This is our updated events array: ', eventArr);

// Input history querys the DOM for the classname and returns an HTMLCollection which is type array
// In order to append to the DOM from here, we have to treat it as an array and appropriate methods against it
Expand Down Expand Up @@ -68,7 +66,6 @@ window.addEventListener('stopRecording', (e) => {
// This allows CodeBlock.tsx to easily catch the message
(async function() {
let generatedCode = await describeCreatorImport();
// console.log("Generated code: ", generatedCode);
window.postMessage({ type: 'GENERATED_CODE', code: generatedCode })
})();
});
Expand All @@ -80,7 +77,6 @@ window.addEventListener('stopRecording', (e) => {
*/
async function describeCreatorImport() {
const { describeCreator } = await import("./bundles/utils/testCreator.js");
console.log(describeObj)
return describeCreator(describeObj);
}

Expand Down
5 changes: 0 additions & 5 deletions server/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion server/index.ts

This file was deleted.

Loading

0 comments on commit 3cdeb2b

Please sign in to comment.