-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from yello-xyz/v0.22
V0.22
- Loading branch information
Showing
71 changed files
with
1,771 additions
and
1,124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,12 @@ Or just **Open with GitHub Desktop** and clone to a local directory (recommended | |
## Configure environment | ||
`cd ~/[LOCAL_DIRECTORY]/playfetch` | ||
|
||
In order to access the Google Cloud Datastore from your local machine, you will need to install the Google Cloud CLI initialize it as explained [here](https://cloud.google.com/sdk/docs/install-sdk) (you can skip the other steps). Run the following commands to log in with your individual Google account (which should be added to the [email protected] group). | ||
|
||
`gcloud auth login` | ||
|
||
`gcloud init` | ||
|
||
In order to run the app locally, you will need to add some additional variables to your local `.env.local` file (this file is ignored by source control to avoid leaking keys). For most of these you should avoid using the same values as used in the production environment (e.g. generate your own API free keys so you don't risk messing up analytics or rate limits while testing locally): | ||
|
||
`API_URL=http://localhost:3000` | ||
|
@@ -95,12 +101,6 @@ In order to run the app locally, you will need to add some additional variables | |
|
||
`NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID=GTM-NCN8W45M` | ||
|
||
In order to access the Google Cloud Datastore from your local machine, you will need to install the Google Cloud CLI initialize it as explained [here](https://cloud.google.com/sdk/docs/install-sdk) (you can skip the other steps). Run the following commands to log in with your individual Google account (which should be added to the [email protected] group). | ||
|
||
`gcloud auth login` | ||
|
||
`gcloud init` | ||
|
||
## Build and run | ||
`npm install` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,61 @@ | ||
import { SelectInputRows } from '@/src/client/inputRows' | ||
import { InputValues, TestConfig } from '@/types' | ||
|
||
const config = (mode: TestConfig['mode'], rowIndices = [] as number[]): TestConfig => ({ mode, rowIndices }) | ||
|
||
test('No inputs yields single empty prompt input', () => | ||
expect(SelectInputRows({}, [], config('first'))[0]).toStrictEqual([{}])) | ||
expect(SelectInputRows({}, [], { rowIndices: [] })[0]).toStrictEqual([{}])) | ||
|
||
test('Inputs without values yield single empty prompt input', () => | ||
expect(SelectInputRows({}, ['a', 'b'], config('first'))[0]).toStrictEqual([{}])) | ||
expect(SelectInputRows({}, ['a', 'b'], { rowIndices: [] })[0]).toStrictEqual([{}])) | ||
|
||
const testRowSelection = ( | ||
testDescription: string, | ||
inputValues: InputValues, | ||
variables: string[], | ||
config: TestConfig, | ||
count: number, | ||
start: number, | ||
config: TestConfig | undefined, | ||
expectedIndices: number[] | ||
) => | ||
test(testDescription, () => | ||
expect(SelectInputRows(inputValues, variables, config, count, start)[1]).toStrictEqual(expectedIndices) | ||
) | ||
test(testDescription, () => expect(SelectInputRows(inputValues, variables, config)[1]).toStrictEqual(expectedIndices)) | ||
|
||
const testAllDefaultModes = ( | ||
const testDefaultSelection = ( | ||
testDescription: string, | ||
inputValues: InputValues, | ||
variables: string[], | ||
expectedIndices: number[] | ||
) => { | ||
for (const mode of ['first', 'last', 'random', 'all'] as TestConfig['mode'][]) { | ||
testRowSelection( | ||
`${testDescription} (${mode})`, | ||
inputValues, | ||
variables, | ||
config(mode), | ||
expectedIndices.length, | ||
0, | ||
expectedIndices | ||
) | ||
} | ||
testRowSelection(testDescription, inputValues, variables, { rowIndices: [] }, expectedIndices) | ||
testRowSelection(`${testDescription} (all)`, inputValues, variables, undefined, expectedIndices) | ||
} | ||
|
||
testAllDefaultModes('Test empty input', {}, [], []) | ||
testAllDefaultModes('Test empty input with variables', {}, ['a', 'b', 'c'], []) | ||
testAllDefaultModes('Test single input without values', { var1: [] }, ['var1'], []) | ||
testAllDefaultModes('Test single input without variables', { var1: ['value1'] }, [], []) | ||
testAllDefaultModes('Test single input with different variables', { var1: ['value1'] }, ['var2'], []) | ||
testAllDefaultModes('Test single input with single variable', { var1: ['value1'] }, ['var1'], [0]) | ||
testAllDefaultModes('Test single input with additional variables', { var1: ['value1'] }, ['var1', 'var2'], [0]) | ||
testDefaultSelection('Test empty input', {}, [], []) | ||
testDefaultSelection('Test empty input with variables', {}, ['a', 'b', 'c'], []) | ||
testDefaultSelection('Test single input without values', { var1: [] }, ['var1'], []) | ||
testDefaultSelection('Test single input without variables', { var1: ['value1'] }, [], []) | ||
testDefaultSelection('Test single input with different variables', { var1: ['value1'] }, ['var2'], []) | ||
testDefaultSelection('Test single input with single variable', { var1: ['value1'] }, ['var1'], [0]) | ||
testDefaultSelection('Test single input with additional variables', { var1: ['value1'] }, ['var1', 'var2'], [0]) | ||
|
||
const sparseValues = { | ||
var1: ['', 'value1', '', '', '', '', ''], | ||
var2: ['', '', '', 'value2', '', '', ''], | ||
var3: ['', '', '', '', '', 'value3', ''], | ||
} | ||
|
||
const testSparseValues = (config: TestConfig, expectedIndices: number[], count = 1, start = 0) => { | ||
const testSparseValues = (config: TestConfig | undefined, expectedIndices: number[], count = 1, start = 0) => { | ||
testRowSelection( | ||
`Test sparse values (${config.mode} [${config.rowIndices}]) [${count}, ${start}]`, | ||
`Test sparse values (${config ? 'custom' : 'all'} [${config?.rowIndices ?? []}]) [${count}, ${start}]`, | ||
sparseValues, | ||
Object.keys(sparseValues), | ||
config, | ||
count, | ||
start, | ||
expectedIndices | ||
) | ||
} | ||
|
||
testSparseValues(config('first'), [1]) | ||
testSparseValues(config('last'), [5]) | ||
testSparseValues(config('all'), [1, 3, 5]) | ||
|
||
testSparseValues(config('custom'), []) | ||
testSparseValues(config('custom', [0]), []) | ||
testSparseValues(config('custom', [1, 2]), [1]) | ||
testSparseValues(config('custom', [1, 2, 3]), [1, 3]) | ||
testSparseValues(config('custom', [3, 2, 1]), [1, 3]) | ||
testSparseValues(config('custom', [1, 3, 5]), [1, 3, 5]) | ||
testSparseValues(config('custom', [0, 1, 2, 3, 4, 5, 6, 7, 8]), [1, 3, 5]) | ||
testSparseValues({ rowIndices: [] }, [1]) | ||
testSparseValues(undefined, [1, 3, 5]) | ||
|
||
testSparseValues(config('range'), [1]) | ||
testSparseValues(config('range'), [1], 1, 1) | ||
testSparseValues(config('range'), [3], 1, 2) | ||
testSparseValues(config('range'), [1, 3], 2, 0) | ||
testSparseValues(config('range'), [3, 5], 2, 2) | ||
testSparseValues(config('range'), [3, 5], 2, 3) | ||
testSparseValues(config('range'), [1, 3, 5], 3, 0) | ||
testSparseValues(config('range'), [1, 3, 5], 3, 1) | ||
testSparseValues(config('range'), [3, 5], 3, 2) | ||
testSparseValues(config('range'), [5], 1, 5) | ||
testSparseValues(config('range'), [5], 2, 5) | ||
testSparseValues(config('range'), [1, 3, 5], 10, 0) | ||
testSparseValues({ rowIndices: [0] }, [1]) | ||
testSparseValues({ rowIndices: [1, 2] }, [1]) | ||
testSparseValues({ rowIndices: [1, 2, 3] }, [1, 3]) | ||
testSparseValues({ rowIndices: [3, 2, 1] }, [1, 3]) | ||
testSparseValues({ rowIndices: [1, 3, 5] }, [1, 3, 5]) | ||
testSparseValues({ rowIndices: [0, 1, 2, 3, 4, 5, 6, 7, 8] }, [1, 3, 5]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.