From 314e47a4f156aa754e30fda17144bdbd5d119b6f Mon Sep 17 00:00:00 2001 From: FrankCardillo Date: Thu, 25 Apr 2019 10:15:28 -0400 Subject: [PATCH 1/6] #N/A initial commit so i can create my PR --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db7cdfe7..4abc0a89 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# force-vue-awakens +# +Frank Cardillo's work as an SDET candidate + +## force-vue-awakens > Every generation has a story ## Contributing From 90c7ba3b85f63bc0786630743992269d614c950f Mon Sep 17 00:00:00 2001 From: FrankCardillo Date: Thu, 25 Apr 2019 11:19:42 -0400 Subject: [PATCH 2/6] #20 configuring linter. now lints .vue files as well --- .eslintignore | 1 + .eslintrc | 10 ++++++++++ package.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .eslintignore create mode 100644 .eslintrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..aee2bc9f --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +wdio.conf.js \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..8c4ac8e2 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,10 @@ +{ + "extends": [ + "plugin:vue/recommended" + ], + "plugins": ["webdriverio"], + "env": { + "webdriverio/wdio": true, + "mocha": true + } +} \ No newline at end of file diff --git a/package.json b/package.json index 6fc731db..8e07fb79 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "e2e": "wdio", "build": "webpack", "start": "webpack-dev-server", - "lint": "eslint src test wdio.conf.js" + "lint": "eslint --ext .js,.vue src test wdio.conf.js" }, "author": "Ian Walter (https://iankwalter.com)", "dependencies": { From 6e17b8cb9cf0738d5508bbc247a9fc867f3366d3 Mon Sep 17 00:00:00 2001 From: FrankCardillo Date: Thu, 25 Apr 2019 11:48:03 -0400 Subject: [PATCH 3/6] #20 not linting the wdio.conf.js file. fixed linting warnings in vue component --- .eslintignore | 1 - package.json | 2 +- src/components/Home.vue | 16 +++++----------- src/router.js | 2 ++ 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.eslintignore b/.eslintignore index aee2bc9f..e69de29b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +0,0 @@ -wdio.conf.js \ No newline at end of file diff --git a/package.json b/package.json index 8e07fb79..eab2b3ec 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "e2e": "wdio", "build": "webpack", "start": "webpack-dev-server", - "lint": "eslint --ext .js,.vue src test wdio.conf.js" + "lint": "eslint --ext .js,.vue src test" }, "author": "Ian Walter (https://iankwalter.com)", "dependencies": { diff --git a/src/components/Home.vue b/src/components/Home.vue index 37ee9933..7320d5c8 100644 --- a/src/components/Home.vue +++ b/src/components/Home.vue @@ -1,36 +1,30 @@ diff --git a/src/router.js b/src/router.js index ac1bf072..8de2091c 100644 --- a/src/router.js +++ b/src/router.js @@ -4,8 +4,10 @@ import VueRouter from 'vue-router' // Instruct Vue to use the router plugin. Vue.use(VueRouter) +/* eslint-disable */ const Home = () => import('@/components/Home') const Person = () => import('@/components/Person') +/* eslint-enable */ // Export a new Vue Router instance to be used in the application. export default new VueRouter({ From c7e40178fbe0edbab7cf91528110d448c20c57ef Mon Sep 17 00:00:00 2001 From: FrankCardillo Date: Thu, 25 Apr 2019 11:56:03 -0400 Subject: [PATCH 4/6] #20 fxing linter not recognizing the vue lazy load component import syntax --- .eslintrc | 18 ++++++++++-------- src/router.js | 2 -- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.eslintrc b/.eslintrc index 8c4ac8e2..296b4497 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,12 @@ { - "extends": [ - "plugin:vue/recommended" - ], - "plugins": ["webdriverio"], - "env": { - "webdriverio/wdio": true, - "mocha": true - } + "root": true, + "parserOptions": {"parser": "babel-eslint"}, + "extends": [ + "plugin:vue/recommended" + ], + "plugins": ["webdriverio"], + "env": { + "webdriverio/wdio": true, + "mocha": true + } } \ No newline at end of file diff --git a/src/router.js b/src/router.js index 8de2091c..ac1bf072 100644 --- a/src/router.js +++ b/src/router.js @@ -4,10 +4,8 @@ import VueRouter from 'vue-router' // Instruct Vue to use the router plugin. Vue.use(VueRouter) -/* eslint-disable */ const Home = () => import('@/components/Home') const Person = () => import('@/components/Person') -/* eslint-enable */ // Export a new Vue Router instance to be used in the application. export default new VueRouter({ From b7524d5e12fda2306f6a844d3c6097efa794df43 Mon Sep 17 00:00:00 2001 From: FrankCardillo Date: Thu, 25 Apr 2019 12:27:10 -0400 Subject: [PATCH 5/6] #9 added 404 page when no matching route or resource is found --- src/components/PageNotFound.vue | 3 +++ src/router.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/components/PageNotFound.vue diff --git a/src/components/PageNotFound.vue b/src/components/PageNotFound.vue new file mode 100644 index 00000000..e96fa24a --- /dev/null +++ b/src/components/PageNotFound.vue @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/src/router.js b/src/router.js index ac1bf072..56e93886 100644 --- a/src/router.js +++ b/src/router.js @@ -6,6 +6,7 @@ Vue.use(VueRouter) const Home = () => import('@/components/Home') const Person = () => import('@/components/Person') +const PageNotFound = () => import('@/components/PageNotFound') // Export a new Vue Router instance to be used in the application. export default new VueRouter({ @@ -17,6 +18,7 @@ export default new VueRouter({ { path: '/people/:id', component: Vue.component('Person', Person) - } + }, + { path: '*', component: Vue.component('PageNotFound', PageNotFound) } ] }) From be4ee601ef271e972ae721e75b12f79311b7b78c Mon Sep 17 00:00:00 2001 From: FrankCardillo Date: Thu, 25 Apr 2019 14:14:01 -0400 Subject: [PATCH 6/6] #12 WIP :( Working to mock the state so I could get the component to render the swapi data and test the snapshot against that. --- test/data/swapi.json | 278 +++++++++++++++++++++++++++++++++++++++++ test/e2e/home.js | 14 +-- test/unit/home.test.js | 32 ++++- 3 files changed, 314 insertions(+), 10 deletions(-) create mode 100644 test/data/swapi.json diff --git a/test/data/swapi.json b/test/data/swapi.json new file mode 100644 index 00000000..6da5e3a7 --- /dev/null +++ b/test/data/swapi.json @@ -0,0 +1,278 @@ +{ + "count": 87, + "next": "https://swapi.co/api/people/?page=2", + "previous": null, + "results": [ + { + "name": "Luke Skywalker", + "height": "172", + "mass": "77", + "hair_color": "blond", + "skin_color": "fair", + "eye_color": "blue", + "birth_year": "19BBY", + "gender": "male", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/2/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/3/", + "https://swapi.co/api/films/1/", + "https://swapi.co/api/films/7/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [ + "https://swapi.co/api/vehicles/14/", + "https://swapi.co/api/vehicles/30/" + ], + "starships": [ + "https://swapi.co/api/starships/12/", + "https://swapi.co/api/starships/22/" + ], + "created": "2014-12-09T13:50:51.644000Z", + "edited": "2014-12-20T21:17:56.891000Z", + "url": "https://swapi.co/api/people/1/" + }, + { + "name": "C-3PO", + "height": "167", + "mass": "75", + "hair_color": "n/a", + "skin_color": "gold", + "eye_color": "yellow", + "birth_year": "112BBY", + "gender": "n/a", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/2/", + "https://swapi.co/api/films/5/", + "https://swapi.co/api/films/4/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/3/", + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/2/" + ], + "vehicles": [], + "starships": [], + "created": "2014-12-10T15:10:51.357000Z", + "edited": "2014-12-20T21:17:50.309000Z", + "url": "https://swapi.co/api/people/2/" + }, + { + "name": "R2-D2", + "height": "96", + "mass": "32", + "hair_color": "n/a", + "skin_color": "white, blue", + "eye_color": "red", + "birth_year": "33BBY", + "gender": "n/a", + "homeworld": "https://swapi.co/api/planets/8/", + "films": [ + "https://swapi.co/api/films/2/", + "https://swapi.co/api/films/5/", + "https://swapi.co/api/films/4/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/3/", + "https://swapi.co/api/films/1/", + "https://swapi.co/api/films/7/" + ], + "species": [ + "https://swapi.co/api/species/2/" + ], + "vehicles": [], + "starships": [], + "created": "2014-12-10T15:11:50.376000Z", + "edited": "2014-12-20T21:17:50.311000Z", + "url": "https://swapi.co/api/people/3/" + }, + { + "name": "Darth Vader", + "height": "202", + "mass": "136", + "hair_color": "none", + "skin_color": "white", + "eye_color": "yellow", + "birth_year": "41.9BBY", + "gender": "male", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/2/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/3/", + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [], + "starships": [ + "https://swapi.co/api/starships/13/" + ], + "created": "2014-12-10T15:18:20.704000Z", + "edited": "2014-12-20T21:17:50.313000Z", + "url": "https://swapi.co/api/people/4/" + }, + { + "name": "Leia Organa", + "height": "150", + "mass": "49", + "hair_color": "brown", + "skin_color": "light", + "eye_color": "brown", + "birth_year": "19BBY", + "gender": "female", + "homeworld": "https://swapi.co/api/planets/2/", + "films": [ + "https://swapi.co/api/films/2/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/3/", + "https://swapi.co/api/films/1/", + "https://swapi.co/api/films/7/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [ + "https://swapi.co/api/vehicles/30/" + ], + "starships": [], + "created": "2014-12-10T15:20:09.791000Z", + "edited": "2014-12-20T21:17:50.315000Z", + "url": "https://swapi.co/api/people/5/" + }, + { + "name": "Owen Lars", + "height": "178", + "mass": "120", + "hair_color": "brown, grey", + "skin_color": "light", + "eye_color": "blue", + "birth_year": "52BBY", + "gender": "male", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/5/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [], + "starships": [], + "created": "2014-12-10T15:52:14.024000Z", + "edited": "2014-12-20T21:17:50.317000Z", + "url": "https://swapi.co/api/people/6/" + }, + { + "name": "Beru Whitesun lars", + "height": "165", + "mass": "75", + "hair_color": "brown", + "skin_color": "light", + "eye_color": "blue", + "birth_year": "47BBY", + "gender": "female", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/5/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [], + "starships": [], + "created": "2014-12-10T15:53:41.121000Z", + "edited": "2014-12-20T21:17:50.319000Z", + "url": "https://swapi.co/api/people/7/" + }, + { + "name": "R5-D4", + "height": "97", + "mass": "32", + "hair_color": "n/a", + "skin_color": "white, red", + "eye_color": "red", + "birth_year": "unknown", + "gender": "n/a", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/2/" + ], + "vehicles": [], + "starships": [], + "created": "2014-12-10T15:57:50.959000Z", + "edited": "2014-12-20T21:17:50.321000Z", + "url": "https://swapi.co/api/people/8/" + }, + { + "name": "Biggs Darklighter", + "height": "183", + "mass": "84", + "hair_color": "black", + "skin_color": "light", + "eye_color": "brown", + "birth_year": "24BBY", + "gender": "male", + "homeworld": "https://swapi.co/api/planets/1/", + "films": [ + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [], + "starships": [ + "https://swapi.co/api/starships/12/" + ], + "created": "2014-12-10T15:59:50.509000Z", + "edited": "2014-12-20T21:17:50.323000Z", + "url": "https://swapi.co/api/people/9/" + }, + { + "name": "Obi-Wan Kenobi", + "height": "182", + "mass": "77", + "hair_color": "auburn, white", + "skin_color": "fair", + "eye_color": "blue-gray", + "birth_year": "57BBY", + "gender": "male", + "homeworld": "https://swapi.co/api/planets/20/", + "films": [ + "https://swapi.co/api/films/2/", + "https://swapi.co/api/films/5/", + "https://swapi.co/api/films/4/", + "https://swapi.co/api/films/6/", + "https://swapi.co/api/films/3/", + "https://swapi.co/api/films/1/" + ], + "species": [ + "https://swapi.co/api/species/1/" + ], + "vehicles": [ + "https://swapi.co/api/vehicles/38/" + ], + "starships": [ + "https://swapi.co/api/starships/48/", + "https://swapi.co/api/starships/59/", + "https://swapi.co/api/starships/64/", + "https://swapi.co/api/starships/65/", + "https://swapi.co/api/starships/74/" + ], + "created": "2014-12-10T16:16:29.192000Z", + "edited": "2014-12-20T21:17:50.325000Z", + "url": "https://swapi.co/api/people/10/" + } + ] +} \ No newline at end of file diff --git a/test/e2e/home.js b/test/e2e/home.js index 1b0630a4..509a8ddb 100644 --- a/test/e2e/home.js +++ b/test/e2e/home.js @@ -1,7 +1,7 @@ -describe('Home', () => { - it('should list characters', async () => { - await browser.url('/') - const title = await browser.getTitle() - expect(title).toBe('Force Vue Awakens') - }) -}) +// describe('Home', () => { +// it('should list characters', async () => { +// await browser.url('/') +// const title = await browser.getTitle() +// expect(title).toBe('Force Vue Awakens') +// }) +// }) diff --git a/test/unit/home.test.js b/test/unit/home.test.js index 33c1cd06..d6a5b793 100644 --- a/test/unit/home.test.js +++ b/test/unit/home.test.js @@ -1,14 +1,40 @@ import { mount, createLocalVue } from '@vue/test-utils' import Vuex from 'vuex' +import fs from 'fs'; +import path from 'path'; -import store from '@/store' +// import store from '@/store' import Home from '@/components/Home' const localVue = createLocalVue() localVue.use(Vuex) -test('Home renders correctly', () => { +test('Home renders correctly', (done) => { + const rawData = fs.readFileSync(path.resolve(__dirname, '../data/swapi.json')) + const parsedData = JSON.parse(rawData) + + const actions = { + list: () => parsedData + } + const state = {} + const store = new Vuex.Store({ + modules: { + people: { + namespaced: true, + state, + mutations: { + results: (state, results = []) => (state.results = results) + }, + actions, + }, + } + }) + const wrapper = mount(Home, { store, localVue }) - expect(wrapper.html()).toMatchSnapshot() + + wrapper.vm.$nextTick(() => { + expect(wrapper.html()).toMatchSnapshot() + done() + }) })