-
Notifications
You must be signed in to change notification settings - Fork 0
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 #7 from seroanalytics/scale
add lineplot tests and choosescale component
- Loading branch information
Showing
20 changed files
with
1,081 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: 🚢 Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
docker: | ||
name: 🚢 Docker | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: ⬇️ Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: ⎔ Setup node | ||
uses: actions/setup-node@v4 | ||
|
||
- name: 📥 Install deps | ||
run: npm install --frozen-lockfile | ||
|
||
- name: 🔨 Build image | ||
run: ./scripts/build | ||
|
||
- name: 🔥 Smoke test | ||
run: ./scripts/smoke-test | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: 🚢 Push image | ||
run: ./scripts/push |
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
HERE=$(realpath "$(dirname $0)") | ||
. $HERE/common | ||
|
||
wait_for() | ||
{ | ||
echo "waiting up to $TIMEOUT seconds for app" | ||
start_ts=$(date +%s) | ||
for i in $(seq $TIMEOUT); do | ||
result="$(curl --write-out %{http_code} --silent --output /dev/null --insecure https://localhost 2>/dev/null)" | ||
if [[ $result -eq "200" ]]; then | ||
end_ts=$(date +%s) | ||
echo "App available after $((end_ts - start_ts)) seconds" | ||
exit 0 | ||
fi | ||
sleep 1 | ||
echo "...still waiting" | ||
done | ||
return $result | ||
} | ||
|
||
$HERE/run | ||
|
||
# The variable expansion below is 60s by default, or the argument provided | ||
# to this script | ||
TIMEOUT="${1:-60}" | ||
sleep 2 # Wait for SSL to be ready | ||
wait_for | ||
RESULT=$? | ||
if [[ $RESULT -ne 200 ]]; then | ||
echo "App did not become available in time" | ||
exit 1 | ||
fi | ||
exit 0 |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, {useContext} from "react"; | ||
import {ActionType, RootContext, RootDispatchContext} from "../RootContext"; | ||
import Form from "react-bootstrap/Form"; | ||
|
||
export default function ChooseScale() { | ||
|
||
const state = useContext(RootContext); | ||
const dispatch = useContext(RootDispatchContext); | ||
|
||
const onSelect = (event: any) => { | ||
dispatch({ | ||
type: ActionType.SELECT_SCALE, | ||
payload: event.target.value | ||
}); | ||
} | ||
|
||
return <Form.Group key="choose-scale" className="mb-3"> | ||
<Form.Label htmlFor="scale">Transform data by</Form.Label> | ||
<Form.Select id="scale" onChange={onSelect} | ||
value={state.datasetSettings[state.selectedDataset].scale}> | ||
<option value={"natural"}>none</option> | ||
<option value={"log"}>log (log base 10)</option> | ||
<option value={"log2"}>log2 (log base 2)</option> | ||
</Form.Select> | ||
</Form.Group> | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react"; | ||
import {render, screen} from "@testing-library/react"; | ||
import { | ||
mockAppState, | ||
mockDatasetSettings | ||
} from "../mocks"; | ||
import { | ||
RootDispatchContext, | ||
RootContext, | ||
ActionType | ||
} from "../../src/RootContext"; | ||
import ChooseScale from "../../src/components/ChooseScale"; | ||
import {userEvent} from "@testing-library/user-event"; | ||
|
||
describe("<ChooseScale />", () => { | ||
|
||
test("can change scale", async () => { | ||
const dispatch = jest.fn(); | ||
const state = mockAppState({ | ||
selectedDataset: "d1", | ||
datasetSettings: { | ||
"d1": mockDatasetSettings() | ||
} | ||
}); | ||
render( | ||
<RootContext.Provider value={state}> | ||
<RootDispatchContext.Provider value={dispatch}> | ||
<ChooseScale/> | ||
</RootDispatchContext.Provider> | ||
</RootContext.Provider>); | ||
|
||
const select = screen.getByRole("combobox") as HTMLSelectElement; | ||
expect(select.value).toBe("natural"); | ||
expect(select.item(1)!!.value).toBe("log"); | ||
expect(select.item(2)!!.value).toBe("log2"); | ||
await userEvent.selectOptions(select, "log"); | ||
|
||
expect(dispatch.mock.calls[0][0]).toEqual({ | ||
type: ActionType.SELECT_SCALE, | ||
payload: "log" | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.