test: use mocks for commits e2e test

This commit is contained in:
Evan You 2018-12-11 17:44:25 -05:00
parent 80fb6b8da1
commit 4e975485a4
3 changed files with 592 additions and 7 deletions

View File

@ -1,10 +1,12 @@
/* global Vue */
var apiURL = 'https://api.github.com/repos/vuejs/vue/commits?per_page=3&sha='
/**
* Actual demo
*/
var demo = new Vue({
new Vue({
el: '#demo',
@ -34,14 +36,21 @@ var demo = new Vue({
methods: {
fetchData: function () {
var xhr = new XMLHttpRequest()
var self = this
xhr.open('GET', apiURL + self.currentBranch)
xhr.onload = function () {
self.commits = JSON.parse(xhr.responseText)
console.log(self.commits[0].html_url)
if (navigator.userAgent.indexOf('PhantomJS') > -1) {
// use mocks in e2e to avoid dependency on network / authentication
setTimeout(function () {
self.commits = window.MOCKS[self.currentBranch]
}, 0)
} else {
var xhr = new XMLHttpRequest()
xhr.open('GET', apiURL + self.currentBranch)
xhr.onload = function () {
self.commits = JSON.parse(xhr.responseText)
console.log(self.commits[0].html_url)
}
xhr.send()
}
xhr.send()
}
}
})

View File

@ -42,6 +42,7 @@
</li>
</ul>
</div>
<script src="mock.js"></script>
<script src="app.js"></script>
</body>
</html>

575
examples/commits/mock.js Normal file
View File

@ -0,0 +1,575 @@
window.MOCKS = {
master: [
{
sha: "0948d999f2fddf9f90991956493f976273c5da1f",
node_id:
"MDY6Q29tbWl0MTE3MzAzNDI6MDk0OGQ5OTlmMmZkZGY5ZjkwOTkxOTU2NDkzZjk3NjI3M2M1ZGExZg==",
commit: {
author: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2017-10-13T03:07:14Z"
},
committer: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2017-10-13T03:07:14Z"
},
message: "build: release 2.5.0",
tree: {
sha: "7846816b875eb664ddf718fad04a720efeac72d0",
url:
"https://api.github.com/repos/vuejs/vue/git/trees/7846816b875eb664ddf718fad04a720efeac72d0"
},
url:
"https://api.github.com/repos/vuejs/vue/git/commits/0948d999f2fddf9f90991956493f976273c5da1f",
comment_count: 0,
verification: {
verified: false,
reason: "unsigned",
signature: null,
payload: null
}
},
url:
"https://api.github.com/repos/vuejs/vue/commits/0948d999f2fddf9f90991956493f976273c5da1f",
html_url:
"https://github.com/vuejs/vue/commit/0948d999f2fddf9f90991956493f976273c5da1f",
comments_url:
"https://api.github.com/repos/vuejs/vue/commits/0948d999f2fddf9f90991956493f976273c5da1f/comments",
author: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
committer: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
parents: [
{
sha: "bc2918f0e596d0e133a25606cbb66075402ce6c3",
url:
"https://api.github.com/repos/vuejs/vue/commits/bc2918f0e596d0e133a25606cbb66075402ce6c3",
html_url:
"https://github.com/vuejs/vue/commit/bc2918f0e596d0e133a25606cbb66075402ce6c3"
}
]
},
{
sha: "bc2918f0e596d0e133a25606cbb66075402ce6c3",
node_id:
"MDY6Q29tbWl0MTE3MzAzNDI6YmMyOTE4ZjBlNTk2ZDBlMTMzYTI1NjA2Y2JiNjYwNzU0MDJjZTZjMw==",
commit: {
author: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2017-10-13T03:04:35Z"
},
committer: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2017-10-13T03:04:35Z"
},
message: "build: build 2.5.0",
tree: {
sha: "5c57af855d76df68ec0782a2d2f4cd0a54e80125",
url:
"https://api.github.com/repos/vuejs/vue/git/trees/5c57af855d76df68ec0782a2d2f4cd0a54e80125"
},
url:
"https://api.github.com/repos/vuejs/vue/git/commits/bc2918f0e596d0e133a25606cbb66075402ce6c3",
comment_count: 0,
verification: {
verified: false,
reason: "unsigned",
signature: null,
payload: null
}
},
url:
"https://api.github.com/repos/vuejs/vue/commits/bc2918f0e596d0e133a25606cbb66075402ce6c3",
html_url:
"https://github.com/vuejs/vue/commit/bc2918f0e596d0e133a25606cbb66075402ce6c3",
comments_url:
"https://api.github.com/repos/vuejs/vue/commits/bc2918f0e596d0e133a25606cbb66075402ce6c3/comments",
author: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
committer: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
parents: [
{
sha: "df8f179cfc3b98d6e0f48502cc5071b993d9cdb5",
url:
"https://api.github.com/repos/vuejs/vue/commits/df8f179cfc3b98d6e0f48502cc5071b993d9cdb5",
html_url:
"https://github.com/vuejs/vue/commit/df8f179cfc3b98d6e0f48502cc5071b993d9cdb5"
}
]
},
{
sha: "df8f179cfc3b98d6e0f48502cc5071b993d9cdb5",
node_id:
"MDY6Q29tbWl0MTE3MzAzNDI6ZGY4ZjE3OWNmYzNiOThkNmUwZjQ4NTAyY2M1MDcxYjk5M2Q5Y2RiNQ==",
commit: {
author: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2017-10-13T00:41:36Z"
},
committer: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2017-10-13T00:41:36Z"
},
message: "test: make hydration spec more stable for Edge",
tree: {
sha: "b399dba6180378d6a04715a5624599b49b3e6454",
url:
"https://api.github.com/repos/vuejs/vue/git/trees/b399dba6180378d6a04715a5624599b49b3e6454"
},
url:
"https://api.github.com/repos/vuejs/vue/git/commits/df8f179cfc3b98d6e0f48502cc5071b993d9cdb5",
comment_count: 0,
verification: {
verified: false,
reason: "unsigned",
signature: null,
payload: null
}
},
url:
"https://api.github.com/repos/vuejs/vue/commits/df8f179cfc3b98d6e0f48502cc5071b993d9cdb5",
html_url:
"https://github.com/vuejs/vue/commit/df8f179cfc3b98d6e0f48502cc5071b993d9cdb5",
comments_url:
"https://api.github.com/repos/vuejs/vue/commits/df8f179cfc3b98d6e0f48502cc5071b993d9cdb5/comments",
author: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
committer: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
parents: [
{
sha: "a85f95c422e0bde6ce4068f5e44e761d4e00ca08",
url:
"https://api.github.com/repos/vuejs/vue/commits/a85f95c422e0bde6ce4068f5e44e761d4e00ca08",
html_url:
"https://github.com/vuejs/vue/commit/a85f95c422e0bde6ce4068f5e44e761d4e00ca08"
}
]
}
],
dev: [
{
sha: "4074104fac219e61e542f4da3a4800975a8063f2",
node_id:
"MDY6Q29tbWl0MTE3MzAzNDI6NDA3NDEwNGZhYzIxOWU2MWU1NDJmNGRhM2E0ODAwOTc1YTgwNjNmMg==",
commit: {
author: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2018-12-11T21:51:40Z"
},
committer: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2018-12-11T21:51:40Z"
},
message: "perf: skip normalization on single child element v-for",
tree: {
sha: "75b999a0562d64a38eb322973c982edfa8d84fda",
url:
"https://api.github.com/repos/vuejs/vue/git/trees/75b999a0562d64a38eb322973c982edfa8d84fda"
},
url:
"https://api.github.com/repos/vuejs/vue/git/commits/4074104fac219e61e542f4da3a4800975a8063f2",
comment_count: 0,
verification: {
verified: false,
reason: "unsigned",
signature: null,
payload: null
}
},
url:
"https://api.github.com/repos/vuejs/vue/commits/4074104fac219e61e542f4da3a4800975a8063f2",
html_url:
"https://github.com/vuejs/vue/commit/4074104fac219e61e542f4da3a4800975a8063f2",
comments_url:
"https://api.github.com/repos/vuejs/vue/commits/4074104fac219e61e542f4da3a4800975a8063f2/comments",
author: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
committer: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
parents: [
{
sha: "47487607fbb99339038cf84990ba341c25b5e20d",
url:
"https://api.github.com/repos/vuejs/vue/commits/47487607fbb99339038cf84990ba341c25b5e20d",
html_url:
"https://github.com/vuejs/vue/commit/47487607fbb99339038cf84990ba341c25b5e20d"
}
]
},
{
sha: "47487607fbb99339038cf84990ba341c25b5e20d",
node_id:
"MDY6Q29tbWl0MTE3MzAzNDI6NDc0ODc2MDdmYmI5OTMzOTAzOGNmODQ5OTBiYTM0MWMyNWI1ZTIwZA==",
commit: {
author: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2018-12-11T21:51:03Z"
},
committer: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2018-12-11T21:51:03Z"
},
message: "fix: fix v-for component with undefined value\n\nfix #9181",
tree: {
sha: "cc30183c2663cd88a35a4a18f758ad0ca872805a",
url:
"https://api.github.com/repos/vuejs/vue/git/trees/cc30183c2663cd88a35a4a18f758ad0ca872805a"
},
url:
"https://api.github.com/repos/vuejs/vue/git/commits/47487607fbb99339038cf84990ba341c25b5e20d",
comment_count: 0,
verification: {
verified: false,
reason: "unsigned",
signature: null,
payload: null
}
},
url:
"https://api.github.com/repos/vuejs/vue/commits/47487607fbb99339038cf84990ba341c25b5e20d",
html_url:
"https://github.com/vuejs/vue/commit/47487607fbb99339038cf84990ba341c25b5e20d",
comments_url:
"https://api.github.com/repos/vuejs/vue/commits/47487607fbb99339038cf84990ba341c25b5e20d/comments",
author: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
committer: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
parents: [
{
sha: "984393fed981c58ad79ed50424f023dcfa6829d0",
url:
"https://api.github.com/repos/vuejs/vue/commits/984393fed981c58ad79ed50424f023dcfa6829d0",
html_url:
"https://github.com/vuejs/vue/commit/984393fed981c58ad79ed50424f023dcfa6829d0"
}
]
},
{
sha: "984393fed981c58ad79ed50424f023dcfa6829d0",
node_id:
"MDY6Q29tbWl0MTE3MzAzNDI6OTg0MzkzZmVkOTgxYzU4YWQ3OWVkNTA0MjRmMDIzZGNmYTY4MjlkMA==",
commit: {
author: {
name: "krystal",
email: "krystalnumber@gmail.com",
date: "2018-12-11T16:37:39Z"
},
committer: {
name: "Evan You",
email: "yyx990803@gmail.com",
date: "2018-12-11T16:37:39Z"
},
message: "test: change model text's priority case (#9170)",
tree: {
sha: "9af5d03838b964ea98c3173c92c3e6e5263ee9ec",
url:
"https://api.github.com/repos/vuejs/vue/git/trees/9af5d03838b964ea98c3173c92c3e6e5263ee9ec"
},
url:
"https://api.github.com/repos/vuejs/vue/git/commits/984393fed981c58ad79ed50424f023dcfa6829d0",
comment_count: 0,
verification: {
verified: false,
reason: "unsigned",
signature: null,
payload: null
}
},
url:
"https://api.github.com/repos/vuejs/vue/commits/984393fed981c58ad79ed50424f023dcfa6829d0",
html_url:
"https://github.com/vuejs/vue/commit/984393fed981c58ad79ed50424f023dcfa6829d0",
comments_url:
"https://api.github.com/repos/vuejs/vue/commits/984393fed981c58ad79ed50424f023dcfa6829d0/comments",
author: {
login: "dejour",
id: 7224044,
node_id: "MDQ6VXNlcjcyMjQwNDQ=",
avatar_url: "https://avatars3.githubusercontent.com/u/7224044?v=4",
gravatar_id: "",
url: "https://api.github.com/users/dejour",
html_url: "https://github.com/dejour",
followers_url: "https://api.github.com/users/dejour/followers",
following_url:
"https://api.github.com/users/dejour/following{/other_user}",
gists_url: "https://api.github.com/users/dejour/gists{/gist_id}",
starred_url:
"https://api.github.com/users/dejour/starred{/owner}{/repo}",
subscriptions_url: "https://api.github.com/users/dejour/subscriptions",
organizations_url: "https://api.github.com/users/dejour/orgs",
repos_url: "https://api.github.com/users/dejour/repos",
events_url: "https://api.github.com/users/dejour/events{/privacy}",
received_events_url:
"https://api.github.com/users/dejour/received_events",
type: "User",
site_admin: false
},
committer: {
login: "yyx990803",
id: 499550,
node_id: "MDQ6VXNlcjQ5OTU1MA==",
avatar_url: "https://avatars1.githubusercontent.com/u/499550?v=4",
gravatar_id: "",
url: "https://api.github.com/users/yyx990803",
html_url: "https://github.com/yyx990803",
followers_url: "https://api.github.com/users/yyx990803/followers",
following_url:
"https://api.github.com/users/yyx990803/following{/other_user}",
gists_url: "https://api.github.com/users/yyx990803/gists{/gist_id}",
starred_url:
"https://api.github.com/users/yyx990803/starred{/owner}{/repo}",
subscriptions_url:
"https://api.github.com/users/yyx990803/subscriptions",
organizations_url: "https://api.github.com/users/yyx990803/orgs",
repos_url: "https://api.github.com/users/yyx990803/repos",
events_url: "https://api.github.com/users/yyx990803/events{/privacy}",
received_events_url:
"https://api.github.com/users/yyx990803/received_events",
type: "User",
site_admin: false
},
parents: [
{
sha: "6980035a86cfb79368af77a5040e468177d6b14a",
url:
"https://api.github.com/repos/vuejs/vue/commits/6980035a86cfb79368af77a5040e468177d6b14a",
html_url:
"https://github.com/vuejs/vue/commit/6980035a86cfb79368af77a5040e468177d6b14a"
}
]
}
]
};