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

Git Branch Checkout & Redux Thunk #111

Merged
merged 35 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
06002b2
Code style fix for DiffPickerDialog
nelsonni Apr 16, 2020
d3bd8c0
Branch dropdown on Card back-face
nelsonni Apr 16, 2020
6bf485d
CardComponent.BranchList lists refs instead of repos
nelsonni Apr 16, 2020
5f056e9
extractRepo adds all branches to new Repository refs field
nelsonni Apr 16, 2020
9cf7b7c
CSS styling for Card back-face content
nelsonni Apr 17, 2020
e26a965
io.readFileAsync flag for returning Buffer objects instead of strings
nelsonni Apr 28, 2020
9120e3e
io.readFileAsync wraps flag and encoding options and infers Buffer or…
nelsonni Apr 29, 2020
2d7422d
Bugfix for Git repos being matched but duplicated in metafile processing
nelsonni Apr 29, 2020
1de15a5
Removed unnecessary type guards from String.split().pop() results
nelsonni May 8, 2020
a5e48fe
Expanded test coverage for io.extractDirname to include malformed paths
nelsonni May 8, 2020
df64074
Data type utilities split from IO into format.ts
nelsonni May 8, 2020
f5e2212
writeFileAsync expanded to accept Buffer and file options
nelsonni May 8, 2020
435bd4a
io.filterReadArray fn to separate dirs or files
nelsonni May 19, 2020
1790918
Actions renamed to Action
nelsonni Jun 15, 2020
534d7fc
Added Error type, ErrorDialog, and reducers
nelsonni Jun 15, 2020
2d15e6d
Pako and Git Encoding functions
nelsonni Jun 15, 2020
669fc7a
Expanded Repository type def and Error type
nelsonni Jun 15, 2020
2e2e7a6
Redux Thunk added, refactoring IO-intensive actions to be thunk actio…
nelsonni Jun 15, 2020
4672609
In-progress development of git branch checkout in Cards
nelsonni Jun 15, 2020
eeb6660
Error reporting to user via Dialog and Redux state
nelsonni Jun 17, 2020
9c2b0d9
Card git ref checkout triggers Redux updates
nelsonni Jun 17, 2020
ee160c2
isomorphic-git updated v1.3.0 to v1.5.0
nelsonni Jun 17, 2020
063aa62
Fix for Action rename in Browser component
nelsonni Jun 17, 2020
8b91767
checkoutRef prints progress to console
nelsonni Jun 17, 2020
0a5146c
Checkout now resets to the original git branch on FS afterwards
nelsonni Jun 18, 2020
286efc0
Updated jsdocs for handlers.loadCard()
nelsonni Jun 18, 2020
e362f0a
FilePicker comments about React component lifecycle caveats no longer…
nelsonni Jun 18, 2020
72aee28
FileExplorerComponent updated to use handler.loadCard() with filepath…
nelsonni Jun 18, 2020
1a9e6c5
Removed unused git.checkout test cases
nelsonni Jun 19, 2020
21c11ee
Removed unused handlers.loadCard test cases
nelsonni Jun 19, 2020
4d2f1a9
Deprecated git.ts in favor of git2.ts
nelsonni Jun 19, 2020
7ed3b7f
Removed commented lines and async tag
nelsonni Jun 19, 2020
89f0f8a
Simplified BrowserButton.handleClick to use Thunked loadCard function
nelsonni Jun 19, 2020
5e2b398
Removed unused imports in Browser
nelsonni Jun 19, 2020
43e601c
Migrated test cases for git2.currentBranch, git2.getRepoRoot, and git…
nelsonni Jun 19, 2020
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 __test__/__mocks__/reduxStoreMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const initialState: initStateT = {
13: {
id: '13',
name: 'test/repo',
root: '/',
corsProxy: new URL('http://www.random_proxy.edu'),
url: parsePath('http://www.random_proxy.edu'),
refs: ['master'],
Expand Down
29 changes: 29 additions & 0 deletions __test__/__snapshots__/errorReducer.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`errorReducer errorReducer appends a new error to state on action ADD_ERROR 1`] = `
Object {
"92": Object {
"id": "92",
"message": "Repository missing for metafile 'sampleUser/myRepo'",
"target": "23",
"type": "RepositoryMissingError",
},
"94": Object {
"id": "94",
"message": "Metafile 'sampleUser/myRepo' missing handler to resolve filetype: 'TypeScript'",
"target": "19",
"type": "HandlerMissingError",
},
}
`;

exports[`errorReducer errorReducer returns default state when current state is blank 1`] = `
Object {
"94": Object {
"id": "94",
"message": "Metafile 'sampleUser/myRepo' missing handler to resolve filetype: 'TypeScript'",
"target": "19",
"type": "HandlerMissingError",
},
}
`;
8 changes: 8 additions & 0 deletions __test__/__snapshots__/format.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`format.deserialize deserialize to parse a JSON string into a TypeScript object 1`] = `
Object {
"count": 42,
"result": true,
}
`;
59 changes: 0 additions & 59 deletions __test__/__snapshots__/git.spec.ts.snap

This file was deleted.

8 changes: 0 additions & 8 deletions __test__/__snapshots__/io.spec.ts.snap

This file was deleted.

4 changes: 4 additions & 0 deletions __test__/__snapshots__/repoReducer.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Object {
"601421",
"843449",
],
"root": "/",
"token": "a78bw2591q592s0996q1498c1284",
"url": Object {
"hash": "",
Expand Down Expand Up @@ -40,6 +41,7 @@ Object {
"234412",
"194724",
],
"root": "sampleUser/",
"token": "584n29dkj1683a67f302x009q164",
"url": Object {
"hash": "",
Expand Down Expand Up @@ -72,6 +74,7 @@ Object {
"601421",
"843449",
],
"root": "/",
"token": "a78bw2591q592s0996q1498c1284",
"url": Object {
"hash": "",
Expand Down Expand Up @@ -105,6 +108,7 @@ Object {
"234412",
"194724",
],
"root": "sampleUser/",
"token": "584n29dkj1683a67f302x009q164",
"url": Object {
"hash": "",
Expand Down
1 change: 1 addition & 0 deletions __test__/canvasReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('canvasReducer', () => {
const newRepo: Repository = {
id: '17',
name: 'sampleUser/forkedRepo',
root: '/',
corsProxy: new URL('http://www.oregonstate.edu'),
url: parsePath('https://github.com/sampleUser/forkedRepo'),
refs: ['601421', '843449'],
Expand Down
44 changes: 44 additions & 0 deletions __test__/errorReducer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Error } from '../src/types';
import { errorReducer } from '../src/store/reducers/errors';
import { ActionKeys } from '../src/store/actions';

describe('errorReducer', () => {
const errors: { [id: string]: Error } = {
'92': {
id: '92',
type: 'RepositoryMissingError',
target: '23',
message: `Repository missing for metafile 'sampleUser/myRepo'`
}
}

const newError: Error = {
id: '94',
type: 'HandlerMissingError',
target: '19',
message: `Metafile 'sampleUser/myRepo' missing handler to resolve filetype: 'TypeScript'`
}

it('errorReducer returns default state when current state is blank', () => {
const newErrors = errorReducer(undefined, { type: ActionKeys.ADD_ERROR, id: newError.id, error: newError });
expect(Object.keys(newErrors)).toHaveLength(1);
expect(newErrors).toMatchSnapshot();
});

it('errorReducer appends a new error to state on action ADD_ERROR', () => {
const addedErrors = errorReducer(errors, { type: ActionKeys.ADD_ERROR, id: newError.id, error: newError });
expect(Object.keys(addedErrors)).toHaveLength(2);
expect(addedErrors).toMatchSnapshot();
});

it('errorReducer removes an error from state on action REMOVE_ERROR', () => {
const matchedErrors = errorReducer(errors, { type: ActionKeys.REMOVE_ERROR, id: '92' });
expect(Object.keys(matchedErrors)).toHaveLength(0);
});

it('errorReducer resolves non-matching error in state on action REMOVE_ERROR', () => {
const nonMatchedErrors = errorReducer(errors, { type: ActionKeys.REMOVE_ERROR, id: newError.id });
expect(Object.keys(nonMatchedErrors)).toHaveLength(Object.keys(errors).length);
});

});
76 changes: 76 additions & 0 deletions __test__/format.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import * as format from '../src/containers/format';

describe('format.deserialize', () => {
it('deserialize to parse a JSON string into a TypeScript object', () => {
const json = '{"result":true, "count":42}';
type typedJson = { result: boolean; count: number };
const deserializedJson = format.deserialize<typedJson>(json);
expect(typeof deserializedJson.result).toBe('boolean');
expect(deserializedJson.result).toBe(true);
expect(deserializedJson).toMatchSnapshot();
});

it('deserialize fails with an error on malformed JSON', () => {
// eslint-disable-next-line no-useless-escape
const malformedJson = '{ "key": "Something \\\\"Name\\\\" something\", "anotherkey": "value" }';
expect(() => format.deserialize(malformedJson)).toThrow(SyntaxError);
});
});

describe('format.equalArrayBuffers', () => {
it('equalArrayBuffers identifies equal and non-equal Buffers containing UTF-8 string data', () => {
const buf1 = Buffer.from('test content');
const buf2 = Buffer.from('test content');
const buf3 = Buffer.from('other content');
expect(format.equalArrayBuffers(buf1, buf2)).toBe(true);
expect(format.equalArrayBuffers(buf2, buf3)).toBe(false);
});

it('equalArrayBuffers identifies equal and non-equal Buffers containing binary data', () => {
const buf1 = Buffer.from([23, 13, 99]);
const buf2 = Buffer.from([23, 13, 99]);
const buf3 = Buffer.from([14, 54, 116, 34, 28]);
expect(format.equalArrayBuffers(buf1, buf2)).toBe(true);
expect(format.equalArrayBuffers(buf3, buf2)).toBe(false);
});

it('equalArrayBuffers identifies equal and non-equal Uint8Arrays containing binary data', () => {
const arr1 = new Uint8Array([23, 13, 99]);
const arr2 = new Uint8Array([23, 13, 99]);
const arr3 = new Uint8Array([14, 54, 116, 34, 28]);
const arr4 = new Uint8Array([14, 53, 116, 34, 28]);
expect(format.equalArrayBuffers(arr1, arr2)).toBe(true);
expect(format.equalArrayBuffers(arr3, arr2)).toBe(false);
expect(format.equalArrayBuffers(arr3, arr4)).toBe(false);
});

it('equalArrayBuffers identifies equal and non-equal ArrayBufferLike objects of different types', () => {
const buf1 = Buffer.from([23, 13, 99]);
const buf2 = Buffer.from([14, 54, 116, 34, 28]);
const arr1 = new Uint8Array([23, 13, 99]);
const arr2 = new Uint8Array([14, 53, 116, 34, 28]);
expect(format.equalArrayBuffers(buf1, arr1)).toBe(true);
expect(format.equalArrayBuffers(buf2, arr2)).toBe(false);
});
});

describe('format.toArrayBuffer', () => {
it('toArrayBuffer converts Buffer containing UTF-8 string data', () => {
const buf1 = Buffer.from('test content');
const arr1 = format.toArrayBuffer(buf1);
expect(format.equalArrayBuffers(buf1, arr1)).toBe(true);
});

it('toArrayBuffer converts Buffer containing binary data', () => {
const buf1 = Buffer.from([14, 54, 116, 34, 28]);
const arr1 = format.toArrayBuffer(buf1);
expect(format.equalArrayBuffers(buf1, arr1)).toBe(true);
});

it('toArrayBuffer converts Uint8Array containing binary data', () => {
const arr1 = new Uint8Array([14, 54, 116, 34, 28]);
const buf1 = Buffer.from(arr1);
const arr2 = format.toArrayBuffer(buf1);
expect(format.equalArrayBuffers(arr1, arr2)).toBe(true);
});
});
Loading