Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Add UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbody committed Apr 27, 2019
1 parent 9c4c473 commit ecd74fb
Show file tree
Hide file tree
Showing 16 changed files with 9,227 additions and 26 deletions.
5 changes: 3 additions & 2 deletions src/App.vue
Expand Up @@ -63,8 +63,9 @@ export default class App extends Vue {
this.$store.dispatch('setRange', {router: this.$router, start, end});
const self = this;
users.forEach((user) => {
self.$store.dispatch('getGithubData', {username: user, router: this.$router});
users.forEach(async (user) => {
self.$store.dispatch('getGithubData', {username: user, router: this.$router, firstRun: true});
this.$store.commit('setValidUser', '');
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/DateSelection.vue
Expand Up @@ -5,13 +5,13 @@
</v-toolbar>
<v-list two-line>
<v-list-tile>
<v-list-tile-content>
<v-list-tile-content id="startDate">
<v-list-tile-title>{{getRange.start}}</v-list-tile-title>
<v-list-tile-sub-title>From</v-list-tile-sub-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile>
<v-list-tile-content>
<v-list-tile-content id="endDate">
<v-list-tile-title>{{getRange.end}}</v-list-tile-title>
<v-list-tile-sub-title>Until</v-list-tile-sub-title>
</v-list-tile-content>
Expand Down
5 changes: 5 additions & 0 deletions src/components/UserTable.vue
Expand Up @@ -36,30 +36,35 @@ export default class UserTable extends Vue {
align: 'center',
sortable: true,
value: 'commits',
class: 'commits',
},
{
text: 'Days with commits',
align: 'center',
sortable: true,
value: 'daysWithCommits',
class: 'daysWithCommits',
},
{
text: 'Commits per day',
align: 'center',
sortable: true,
value: 'commitsPerDay',
class: 'commitsPerDay',
},
{
text: '% of days',
align: 'center',
sortable: true,
value: 'percentageOfDays',
class: 'percentageOfDays',
},
{
text: 'Longest streak',
align: 'center',
sortable: true,
value: 'streak',
class: 'streak',
},
];
}
Expand Down
15 changes: 13 additions & 2 deletions src/components/Users.vue
@@ -1,30 +1,41 @@
<template>
<v-card>
<v-card id="user-card">
<v-toolbar color="light-blue lighten-1" dark>
<v-toolbar-title>Github Users</v-toolbar-title>
</v-toolbar>

<v-alert
id="invalidUser"
:value="invalidUser"
type="error"
>
{{invalidUser}} is not a valid Github user.
</v-alert>

<v-alert
id="usernameBlank"
:value="usernameBlank"
type="error"
>
Username not entered
</v-alert>

<v-alert
id="usernameDuplicate"
:value="usernameDuplicate"
type="error"
>
{{username}} already exists in the list
</v-alert>

<v-alert
id="validUser"
:value="validUser"
type="success"
>
{{validUser}} was successfully added
</v-alert>

<v-list two-line>
<template v-for="(user) in getUsers">
<v-subheader :key="user">
Expand Down Expand Up @@ -87,7 +98,7 @@ export default class Users extends Vue {
this.username = '';
this.$store.dispatch('getGithubData', {username, router: this.$router});
this.$store.dispatch('getGithubData', {username, router: this.$router, firstRun: false});
}
}
</script>
9 changes: 7 additions & 2 deletions src/store/actions.ts
Expand Up @@ -16,12 +16,17 @@ export default {
commit('updateQueryString', router);
},
getGithubData: ({commit}: any,
{username, router}: {username: string, router: Route}) => {
{username, router, firstRun}:
{username: string, router: Route, firstRun: boolean}) => {
return axios.get(`https://api.github.com/users/${username}`)
.then(() => {
// Username is valid
commit('addUser', username);
commit('setValidUser', username);

if (!firstRun) {
commit('setValidUser', username);
}

commit('updateQueryString', router);

return axios.get(`https://github-contributions-api.now.sh/v1/${username}?format=nested`)
Expand Down
4 changes: 2 additions & 2 deletions src/store/mutations.ts
Expand Up @@ -21,13 +21,13 @@ export default {
store.invalidUser = username;
setTimeout(() => {
store.invalidUser = '';
}, 1_500);
}, 2_000);
},
setValidUser: (store: State, username: string) => {
store.validUser = username;
setTimeout(() => {
store.validUser = '';
}, 1_500);
}, 2_000);
},
updateQueryString: (store: State, router: VueRouter) => {
const query = {
Expand Down
1 change: 1 addition & 0 deletions src/views/Home.vue
Expand Up @@ -7,6 +7,7 @@
<v-container grid-list-md text-xs-center>
<h1>Commit Competition</h1>
<v-alert
id="apiError"
:value="hasAPIError"
type="error">
API does not appear to be working, please try again later
Expand Down

0 comments on commit ecd74fb

Please sign in to comment.