Skip to content

Commit c971eb7

Browse files
Merge pull request #287 from CivicDataLab/test/analytics
test: added tests for analytics components
2 parents 6ff893d + 44cc2fb commit c971eb7

34 files changed

+12795
-3149
lines changed

.github/workflows/pre-merge.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ on:
55
branches: ['dev']
66
pull_request:
77
branches: ['dev']
8-
env:
9-
BACKEND_URL: ${{secrets.BACKEND_URL}}
10-
DATA_MANAGEMENT_LAYER_URL: ${{secrets.DATA_MANAGEMENT_LAYER_URL}}
11-
NEXT_PUBLIC_BACKEND_URL: ${{secrets.NEXT_PUBLIC_BACKEND_URL}}
12-
NEXT_PUBLIC_DATA_MANAGEMENT_LAYER_URL: ${{secrets.NEXT_PUBLIC_DATA_MANAGEMENT_LAYER_URL}}
8+
env:
9+
BACKEND_URL: ${{secrets.BACKEND_URL}}
10+
DATA_MANAGEMENT_LAYER_URL: ${{secrets.DATA_MANAGEMENT_LAYER_URL}}
11+
NEXT_PUBLIC_BACKEND_URL: ${{secrets.NEXT_PUBLIC_BACKEND_URL}}
12+
NEXT_PUBLIC_DATA_MANAGEMENT_LAYER_URL: ${{secrets.NEXT_PUBLIC_DATA_MANAGEMENT_LAYER_URL}}
1313

1414
jobs:
1515
build:
@@ -27,4 +27,15 @@ jobs:
2727
cache: 'npm'
2828

2929
- run: npm ci --force
30-
- run: npm run build --if-present
30+
31+
# - name: Run linting
32+
# run: npm run lint --if-present
33+
34+
# - name: Run type checking
35+
# run: npm run type-check --if-present
36+
37+
- name: Run tests
38+
run: npm test --if-present
39+
40+
- name: Run build
41+
run: npm run build --if-present

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,38 @@
33
This is a frontend repository of IDS-DRR built using React and Next.js , GraphQl as the backend
44

55
## Dependencies
6+
67
The following dependencies must be available globally on your system:
8+
79
- Download and install [https://nodejs.org/en/](NodeJS LTS v18+) and npm
810

911
## Installation
10-
1. Clone the repository
1112

12-
`git clone https://github.com/glific/glific`
13+
1. Clone the repository
14+
15+
`git clone https://github.com/CivicDataLab/IDS-DRR-Frontend.git`
1316

1417
2. Navigate to the project directory.
1518

16-
`cd ids-drr`
19+
`cd IDS-DRR-Frontend`
1720

1821
3. Install the dependencies.
1922

20-
21-
`npm run install`
23+
`npm install`
2224

2325
## Usage
26+
2427
After completing the installation steps, you can run the project locally by executing:
2528

2629
`npm run dev`
2730

31+
## Running Tests
32+
33+
`npm run test`
34+
35+
![Coverage](https://img.shields.io/badge/Tests_Coverage-60%25-yellow)
36+
2837
## Get Involved
38+
2939
- Start by reading our Code of conduct
3040
- Get familiar with our contributor guidelines explaining the different ways in which you can support this project! We need your help!
31-
32-

app/[locale]/[state]/analytics/components/analytics-sidebar-layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function IndicatorListWrapper({ statesList, currentState }: any) {
8989
<Select
9090
name={'State'}
9191
label={''}
92-
value={currentState.slug}
92+
value={currentState?.slug}
9393
options={statesList.map((state: any) => {
9494
return {
9595
label: state.name,

app/[locale]/[state]/analytics/components/factor-list.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ export function FactorList({ currentState }: any) {
209209
]}
210210
/>
211211
{downloadReportLoading ? (
212-
<Icon source={Icons.loader} className="animate-spin" />
212+
<Icon
213+
source={Icons.loader}
214+
data-testid="loader-icon"
215+
className="animate-spin"
216+
/>
213217
) : (
214218
<Button
215219
className="self-start"
@@ -375,7 +379,7 @@ const NestedSidebarItem: React.FC<{
375379
const NestedSidebar: React.FC<NestedSidebarProps> = ({ data, indicator }) => {
376380
return (
377381
<div>
378-
{data.map((node) => (
382+
{data?.map((node) => (
379383
<NestedSidebarItem
380384
key={node.slug}
381385
node={node}

app/[locale]/[state]/analytics/components/filter-component.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export function FilterComp({
170170
className="m-0 ml-auto border-1 border-solid border-[#8C9196]"
171171
kind="tertiary"
172172
onClick={toggleDrawer}
173+
aria-label="filter"
173174
>
174175
<Icon source={Icons.filter} />
175176
</Button>

app/[locale]/[state]/analytics/components/revenue-circle-accordion.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ export const RevenueCircle = ({
4242
const FactorVariables = Object.keys(clonedRevenueCircleData);
4343

4444
return (
45-
<Accordion type="single" defaultValue={`revenue-circle-0`} collapsible>
45+
<Accordion
46+
type="single"
47+
data-testid="accordion"
48+
defaultValue={`revenue-circle-0`}
49+
collapsible
50+
>
4651
{revenueCircleData.map((item: any, index: number) => (
4752
<AccordionItem
4853
key={`revenue-circle-${index}`}

app/[locale]/[state]/analytics/components/table-component.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ export function TableComponent({ data, isLoading }: any) {
2727

2828
// Dynamically transform other properties
2929
Object.entries(data).forEach(([key, item]) => {
30-
if (typeof item === 'object' && 'value' in item && 'title' in item) {
30+
if (
31+
typeof item === 'object' &&
32+
item !== null &&
33+
'value' in item &&
34+
'title' in item
35+
) {
3136
transformed.push({
3237
accessorKey: key,
3338
id: key,

gql/generated/datasets/gql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
1414
*/
1515
const documents = {
1616
"\n query datasets($filters: DatasetFilter) {\n datasets(filters: $filters) {\n tags {\n id\n value\n }\n id\n title\n description\n created\n modified\n metadata {\n metadataItem {\n id\n label\n }\n value\n }\n resources {\n id\n created\n modified\n type\n name\n description\n }\n categories {\n name\n }\n formats\n }\n }\n": types.DatasetsDocument,
17-
"\n query chartsData($datasetId: UUID!) {\n chartsDetails(datasetId: $datasetId) {\n aggregateType\n chartType\n description\n id\n name\n showLegend\n xAxisLabel\n yAxisLabel\n chart\n }\n }\n": types.ChartsDataDocument,
17+
"\n query chartsData($datasetId: UUID!) {\n chartsDetails(datasetId: $datasetId) {\n chartType\n description\n id\n name\n options {\n aggregateType\n xAxisColumn {\n id\n fieldName\n }\n yAxisColumn {\n field {\n id\n fieldName\n }\n }\n showLegend\n xAxisLabel\n yAxisLabel\n regionColumn {\n id\n fieldName\n }\n valueColumn {\n id\n fieldName\n }\n }\n chart\n }\n }\n": types.ChartsDataDocument,
1818
"\n query datasetResources($datasetId: UUID!) {\n datasetResources(datasetId: $datasetId) {\n id\n created\n modified\n type\n name\n description\n accessModels {\n name\n description\n type\n modelResources {\n fields {\n format\n fieldName\n description\n }\n }\n }\n schema {\n fieldName\n id\n format\n description\n }\n fileDetails {\n format\n }\n }\n }\n": types.DatasetResourcesDocument,
1919
};
2020

@@ -39,7 +39,7 @@ export function graphql(source: "\n query datasets($filters: DatasetFilter) {\n
3939
/**
4040
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
4141
*/
42-
export function graphql(source: "\n query chartsData($datasetId: UUID!) {\n chartsDetails(datasetId: $datasetId) {\n aggregateType\n chartType\n description\n id\n name\n showLegend\n xAxisLabel\n yAxisLabel\n chart\n }\n }\n"): (typeof documents)["\n query chartsData($datasetId: UUID!) {\n chartsDetails(datasetId: $datasetId) {\n aggregateType\n chartType\n description\n id\n name\n showLegend\n xAxisLabel\n yAxisLabel\n chart\n }\n }\n"];
42+
export function graphql(source: "\n query chartsData($datasetId: UUID!) {\n chartsDetails(datasetId: $datasetId) {\n chartType\n description\n id\n name\n options {\n aggregateType\n xAxisColumn {\n id\n fieldName\n }\n yAxisColumn {\n field {\n id\n fieldName\n }\n }\n showLegend\n xAxisLabel\n yAxisLabel\n regionColumn {\n id\n fieldName\n }\n valueColumn {\n id\n fieldName\n }\n }\n chart\n }\n }\n"): (typeof documents)["\n query chartsData($datasetId: UUID!) {\n chartsDetails(datasetId: $datasetId) {\n chartType\n description\n id\n name\n options {\n aggregateType\n xAxisColumn {\n id\n fieldName\n }\n yAxisColumn {\n field {\n id\n fieldName\n }\n }\n showLegend\n xAxisLabel\n yAxisLabel\n regionColumn {\n id\n fieldName\n }\n valueColumn {\n id\n fieldName\n }\n }\n chart\n }\n }\n"];
4343
/**
4444
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
4545
*/

0 commit comments

Comments
 (0)