-
Notifications
You must be signed in to change notification settings - Fork 2
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 #549 from inab/participant-metrics
Participant metrics
- Loading branch information
Showing
13 changed files
with
851 additions
and
36 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
components/Challenges/ChallengeParticipantMetricsTable.vue
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,63 @@ | ||
<template> | ||
<div> | ||
<v-data-table | ||
dense | ||
:headers="headers" | ||
:items="items" | ||
:items-per-page="15" | ||
:search="search" | ||
item-key="_id" | ||
:loading=" | ||
$store.state.challenge.loading.participants || | ||
$store.state.challenge.loading.metrics | ||
" | ||
> | ||
<template #top> | ||
<v-text-field | ||
v-model="search" | ||
label="Search" | ||
class="mx-4" | ||
></v-text-field> | ||
</template> | ||
</v-data-table> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
components: {}, | ||
props: { | ||
metricsTable: { type: Object, required: true }, | ||
}, | ||
data() { | ||
const headers = this.metricsTable.metrics.map((metric, metricsI) => { | ||
return { | ||
text: metric.metrics_label, | ||
align: 'start', | ||
value: `metricsValues[${metricsI}].value`, | ||
}; | ||
}); | ||
headers.unshift({ | ||
text: 'Participant', | ||
align: 'start', | ||
value: 'participant.participant_label', | ||
}); | ||
const items = this.metricsTable.participants.map( | ||
(participant, participantI) => { | ||
return { | ||
_id: participant._id, | ||
participant, | ||
metricsValues: this.metricsTable.dataMatrix[participantI], | ||
}; | ||
} | ||
); | ||
return { | ||
search: '', | ||
headers, | ||
items, | ||
}; | ||
}, | ||
}; | ||
</script> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
pages/benchmarking/_community/_id.spec.js → ...benchmarking/_community/_id/index.spec.js
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,142 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Challenge from './index.vue'; | ||
import MockCommunity from '~/test/unit/mockData/Community'; | ||
import MockEvent from '~/test/unit/mockData/Event'; | ||
import MockEvents from '~/test/unit/mockData/Events'; | ||
import MockChallenge from '~/test/unit/mockData/Challenge'; | ||
/* | ||
import ChartBarplotVisualizerWrapper from '~/components/Widgets/ChartBarplotVisualizerWrapper'; | ||
import ChartScatterVisualizerWrapper from '~/components/Widgets/ChartScatterVisualizerWrapper'; | ||
*/ | ||
|
||
const factory = (mockStore) => { | ||
return mount(Challenge, { | ||
...createComponentMocks({ store: mockStore }), | ||
mocks: { | ||
$route: { params: { community: 'TESTCOMMUNITY', id: 'TESTID' } }, | ||
$config: { OEB_LEGACY_ANGULAR_URI: 'https://jest-openebench.bsc.es/' }, | ||
}, | ||
}); | ||
}; | ||
|
||
describe('Community Participant', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
const mockStore = { | ||
community: { | ||
getters: { | ||
events: () => { | ||
return MockEvents; | ||
}, | ||
currentEvent: () => { | ||
return MockEvent; | ||
}, | ||
participants: () => { | ||
return []; | ||
}, | ||
tools: () => { | ||
return []; | ||
}, | ||
community: () => { | ||
return MockCommunity; | ||
}, | ||
getEventById: () => { | ||
return () => MockEvent; | ||
}, | ||
}, | ||
actions: { | ||
setCurrentEvent: jest.fn(), | ||
getCommunity: jest.fn(), | ||
}, | ||
mutations: { | ||
setCommunity: jest.fn(), | ||
setEvents: jest.fn(), | ||
setCurrentEvent: jest.fn(), | ||
setParticipants: jest.fn(), | ||
setTools: jest.fn(), | ||
setLoading: jest.fn(), | ||
}, | ||
state: () => { | ||
return { | ||
loading: { | ||
events: false, | ||
tools: false, | ||
participants: false, | ||
community: false, | ||
}, | ||
community: MockCommunity, | ||
}; | ||
}, | ||
}, | ||
challenge: { | ||
getters: { | ||
participantsList: () => { | ||
return []; | ||
}, | ||
challenge: () => { | ||
return {}; | ||
}, | ||
}, | ||
actions: { | ||
getChallenge: jest.fn(), | ||
getParticipants: jest.fn(), | ||
}, | ||
mutations: { | ||
setParticipants: jest.fn(), | ||
setChallenge: jest.fn(), | ||
setLoading: jest.fn(), | ||
}, | ||
state: () => { | ||
return { | ||
loading: { | ||
challenge: false, | ||
participants: false, | ||
}, | ||
challenge: MockChallenge, | ||
}; | ||
}, | ||
}, | ||
}; | ||
|
||
it('is instantiated', async () => { | ||
const wrapper = factory(mockStore); | ||
expect(wrapper).toBeTruthy(); | ||
await wrapper.vm.$nextTick(); | ||
}); | ||
|
||
it('calls store actions on mount', () => { | ||
const wrapper = factory(mockStore); | ||
expect(wrapper).toBeTruthy(); | ||
|
||
expect(mockStore.challenge.actions.getChallenge).toHaveBeenCalled(); | ||
}); | ||
|
||
/* | ||
it('renders the bar-plot component with the right ID and JSON data structure for rendering', () => { | ||
mockStore.challenge.getters.datasetsList = () => { | ||
return MockChallengeDatasetsBarplot; | ||
}; | ||
const wrapper = factory(mockStore); | ||
expect(wrapper).toBeTruthy(); | ||
const barplot = wrapper.findComponent(ChartBarplotVisualizerWrapper); // => finds Bar by `name` | ||
expect(barplot.exists()).toBe(true); | ||
expect(barplot.props().id).toBe(MockChallengeDatasetsBarplot[0]._id); | ||
expect(barplot.props().data).toBe( | ||
MockChallengeDatasetsBarplot[0].graphData | ||
); | ||
}); | ||
it('renders the scatter-plot component with the right ID', () => { | ||
mockStore.challenge.getters.datasetsList = () => { | ||
return MockChallengeDatasetsScatter; | ||
}; | ||
const wrapper = factory(mockStore); | ||
expect(wrapper).toBeTruthy(); | ||
const scatter = wrapper.findComponent(ChartScatterVisualizerWrapper); // => finds Bar by `name` | ||
expect(scatter.exists()).toBe(true); | ||
expect(scatter.props().id).toBe(MockChallengeDatasetsScatter[0]._id); | ||
}); | ||
*/ | ||
}); |
Oops, something went wrong.