-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests if AttributionDetailsStep component is mounted correctly #133
Merged
akmadian
merged 6 commits into
creativecommons:master
from
JackieBinya:ft-attribution-unit
Mar 18, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2a636ee
Tests if AttributionDetailsStep component is mounted correctly
JackieBinya 97804f4
Update unit tests
JackieBinya ee210b5
Fix typos
JackieBinya 3db8b22
Removes console.log statements from codebase
JackieBinya 4075fd8
Tests if vuex mutation are called
JackieBinya 3db1c5e
Adds e2e tests for AttributionDetailsStepComponent
JackieBinya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,43 @@ | ||
module.exports = { | ||
'@tags': ['att'], | ||
'AttributionDetailsStep'(browser){ | ||
const knowLicenseSelector = '.b-radio' | ||
const nextButton = '.pagination-next' | ||
const select = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > div > div > span > select' | ||
const selectOpt = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > div > div > span > select > option:nth-child(4)' | ||
const stepTitle = '.step-title' | ||
const attributionDetailsInstructions = '.attribution-details-instructions' | ||
const workAuthorLabel ='#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(1) > label' | ||
const workAuthorInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(1) > div > input' | ||
const urlCreatorProfileLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(2) > label' | ||
const urlCreatorProfileInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(2) > div > input' | ||
const workUrlLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(3) > label' | ||
const workUrlInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(4) > div > input' | ||
const workTitleLabel = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(3) > label' | ||
const workTitleInput = '#site-container > div.columns > div.stepper-container.column > div.step-container.current.enabled > div.step-content > div > form > div:nth-child(3) > div > input' | ||
const backBtn = '.pagination-previous' | ||
const paginationFinish = '.pagination-finish' | ||
|
||
|
||
browser | ||
.init() | ||
.click(knowLicenseSelector) | ||
.click(nextButton) | ||
.click(select, () =>{ | ||
browser.click(selectOpt) | ||
}) | ||
.click(nextButton) | ||
.assert.visible(stepTitle, 'Title is visible') | ||
.assert.visible(attributionDetailsInstructions, 'Atrribution Details Instructions block is visible') | ||
.assert.visible(workAuthorLabel, 'Work Author Label is visible') | ||
.assert.visible(workAuthorInput, 'Work Author Input is visible') | ||
.assert.visible(urlCreatorProfileLabel, 'URL of Creator Profile Label is visible') | ||
.assert.visible(urlCreatorProfileInput, 'URL of Creator Profile Input is visible') | ||
.assert.visible(workUrlLabel, 'Work URL Label is visible') | ||
.assert.visible(workUrlInput, 'Work URL Input is visible') | ||
.assert.visible(workTitleLabel, 'Work Title Label is visible') | ||
.assert.visible(workTitleInput, 'Work Title Input is visible') | ||
.assert.visible(backBtn, 'Back button is visible') | ||
.assert.visible(paginationFinish, 'Pagination Finish Block is visible') | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
tests/unit/specs/components/AttributionDetailsStep.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils' | ||
import Buefy from 'buefy' | ||
import Vuex from 'vuex' | ||
import AttributionDetailsStep from '@/components/AttributionDetailsStep' | ||
|
||
const localVue = createLocalVue() | ||
|
||
localVue.use(Vuex) | ||
localVue.use(Buefy) | ||
|
||
describe('AttributionDetailsStep Component Rendering', () => { | ||
let wrapper | ||
|
||
beforeEach(() => { | ||
wrapper = mount(AttributionDetailsStep, { | ||
localVue, | ||
mocks: { | ||
$t: key => key, | ||
$store: { | ||
state: { | ||
attributionDetails: { | ||
creatorName: '', | ||
creatorProfileUrl: '', | ||
workTitle: '', | ||
workUrl: '' | ||
} | ||
} | ||
} | ||
} | ||
|
||
}) | ||
}) | ||
|
||
afterEach(()=> { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('Component not mounted if status is previous', () =>{ | ||
wrapper.setProps({status : 'previous'}) | ||
expect(wrapper.find('.step-actions').exists()).toBeFalsy() | ||
}) | ||
|
||
it('Component not mounted if status is inactive', () =>{ | ||
wrapper.setProps({status : 'inactive'}) | ||
expect(wrapper.find('.step-actions').exists()).toBeFalsy() | ||
}) | ||
|
||
it('Component mounted if status is current', () =>{ | ||
wrapper.setProps({status : 'current'}) | ||
expect(wrapper.element).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('Store is updated when a user provides input', () => { | ||
let mutations, state, wrapper,store | ||
|
||
beforeEach(() => { | ||
mutations = { | ||
setCreatorName: jest.fn(), | ||
setCreatorProfileUrl: jest.fn(), | ||
setWorkTitle: jest.fn(), | ||
setWorkUrl: jest.fn() | ||
}; | ||
|
||
state = { | ||
attributionDetails: { | ||
creatorName: '', | ||
creatorProfileUrl: '', | ||
workTitle: '', | ||
workUrl: '' | ||
} | ||
}; | ||
|
||
store = new Vuex.Store({ | ||
state, | ||
mutations, | ||
}); | ||
|
||
wrapper = mount(AttributionDetailsStep, { | ||
propsData: { | ||
status: 'current' | ||
}, | ||
mocks: { | ||
$t: key => key | ||
}, | ||
store, | ||
localVue, | ||
}); | ||
}) | ||
|
||
afterEach(()=> { | ||
wrapper.destroy() | ||
}) | ||
|
||
it('Creator Name is updated', async() => { | ||
const input = wrapper.find('input[placeholder="stepper.AD.form.creator-name.placeholder"]') | ||
await input.setValue("Jane Bar") | ||
expect(mutations.setCreatorName).toHaveBeenCalled() | ||
}) | ||
|
||
//CreatorProfile URL | ||
it('Profile Url is updated', async() => { | ||
const input = wrapper.find('input[placeholder="stepper.AD.form.creator-profile.placeholder"]') | ||
await input.setValue("jane@bar.com") | ||
expect(mutations.setCreatorProfileUrl).toHaveBeenCalled() | ||
}) | ||
|
||
//Work URL | ||
it('Work Url is updated', async() => { | ||
const input = wrapper.find('input[placeholder="stepper.AD.form.work-url.placeholder"]') | ||
await input.setValue("jane@bar.com/kitty.jpeg") | ||
expect(mutations.setWorkUrl).toHaveBeenCalled() | ||
}) | ||
|
||
//Work Title | ||
it('Work Title is updated', async() => { | ||
const input = wrapper.find('input[placeholder="stepper.AD.form.work-title.placeholder"]') | ||
await input.setValue("illustrator") | ||
expect(mutations.setWorkTitle).toHaveBeenCalled() | ||
}) | ||
|
||
}) |
139 changes: 139 additions & 0 deletions
139
tests/unit/specs/components/__snapshots__/AttributionDetailsStep.spec.js.snap
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,139 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`AttributionDetailsStep Component Rendering Component mounted if status is current 1`] = ` | ||
<div | ||
class="step-content" | ||
> | ||
<div | ||
class="step-actions" | ||
> | ||
<p | ||
class="attribution-details-instructions" | ||
> | ||
|
||
stepper.AD.instructions | ||
|
||
</p> | ||
|
||
<form | ||
class="attribution-details-form" | ||
> | ||
<div | ||
class="field" | ||
> | ||
<label | ||
class="label" | ||
> | ||
stepper.AD.form.creator-name.label | ||
</label> | ||
|
||
<div | ||
class="control is-clearfix" | ||
> | ||
<input | ||
autocomplete="on" | ||
class="input" | ||
placeholder="stepper.AD.form.creator-name.placeholder" | ||
type="text" | ||
/> | ||
|
||
<!----> | ||
|
||
<!----> | ||
|
||
<!----> | ||
</div> | ||
|
||
<!----> | ||
</div> | ||
|
||
<div | ||
class="field" | ||
> | ||
<label | ||
class="label" | ||
> | ||
stepper.AD.form.creator-profile.label | ||
</label> | ||
|
||
<div | ||
class="control is-clearfix" | ||
> | ||
<input | ||
autocomplete="on" | ||
class="input" | ||
placeholder="stepper.AD.form.creator-profile.placeholder" | ||
type="text" | ||
/> | ||
|
||
<!----> | ||
|
||
<!----> | ||
|
||
<!----> | ||
</div> | ||
|
||
<!----> | ||
</div> | ||
|
||
<div | ||
class="field" | ||
> | ||
<label | ||
class="label" | ||
> | ||
stepper.AD.form.work-title.label | ||
</label> | ||
|
||
<div | ||
class="control is-clearfix" | ||
> | ||
<input | ||
autocomplete="on" | ||
class="input" | ||
placeholder="stepper.AD.form.work-title.placeholder" | ||
type="text" | ||
/> | ||
|
||
<!----> | ||
|
||
<!----> | ||
|
||
<!----> | ||
</div> | ||
|
||
<!----> | ||
</div> | ||
|
||
<div | ||
class="field" | ||
> | ||
<label | ||
class="label" | ||
> | ||
stepper.AD.form.work-url.label | ||
</label> | ||
|
||
<div | ||
class="control is-clearfix" | ||
> | ||
<input | ||
autocomplete="on" | ||
class="input" | ||
placeholder="stepper.AD.form.work-url.placeholder" | ||
type="text" | ||
/> | ||
|
||
<!----> | ||
|
||
<!----> | ||
|
||
<!----> | ||
</div> | ||
|
||
<!----> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
`; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a bit much, a lot of things being checked are static and always rendered since they're right there in the markdown, but I think it's ok for now