Commit fdb12d7a authored by Angelina Filippova's avatar Angelina Filippova

Add tests for adding and removing sensitive flag to a status

parent 7bf7f4ef
...@@ -3,7 +3,10 @@ const reports = [ ...@@ -3,7 +3,10 @@ const reports = [
{ created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool' }, actor: { acct: 'admin2' }, state: 'resolved', id: '1', content: 'Please block this user', statuses: [] }, { created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool' }, actor: { acct: 'admin2' }, state: 'resolved', id: '1', content: 'Please block this user', statuses: [] },
{ created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '3', content: '', statuses: [] }, { created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '3', content: '', statuses: [] },
{ created_at: '2019-05-21T21:35:33.000Z', account: { acct: 'benj', display_name: 'Benjamin Fame' }, actor: { acct: 'admin' }, state: 'open', id: '5', content: 'This is a report', statuses: [] }, { created_at: '2019-05-21T21:35:33.000Z', account: { acct: 'benj', display_name: 'Benjamin Fame' }, actor: { acct: 'admin' }, state: 'open', id: '5', content: 'This is a report', statuses: [] },
{ created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool' }, actor: { acct: 'admin2' }, state: 'resolved', id: '7', content: 'Please block this user', statuses: [] }, { created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool' }, actor: { acct: 'admin2' }, state: 'resolved', id: '7', content: 'Please block this user', statuses: [
{ account: { display_name: 'Alice Pool', avatar: '' }, visibility: 'public', sensitive: false, id: 11, content: 'Hey!', url: '', created_at: '2019-05-10T21:35:33.000Z' },
{ account: { display_name: 'Alice Pool', avatar: '' }, visibility: 'unlisted', sensitive: true, id: 10, content: 'Bye!', url: '', created_at: '2019-05-10T21:00:33.000Z' }
] },
{ created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '6', content: '', statuses: [] }, { created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '6', content: '', statuses: [] },
{ created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '4', content: '', statuses: [] } { created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '4', content: '', statuses: [] }
] ]
...@@ -23,3 +26,8 @@ export async function changeState(state, id, authHost, token) { ...@@ -23,3 +26,8 @@ export async function changeState(state, id, authHost, token) {
const report = reports.find(report => report.id === id) const report = reports.find(report => report.id === id)
return Promise.resolve({ data: { ...report, state }}) return Promise.resolve({ data: { ...report, state }})
} }
export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
const status = reports[4].statuses[0]
return Promise.resolve({ data: { ...status, sensitive, visibility }})
}
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
</template> </template>
<script> <script>
import * as moment from 'moment' import moment from 'moment'
export default { export default {
name: 'Statuses', name: 'Statuses',
......
...@@ -23,7 +23,7 @@ describe('Report in a timeline', () => { ...@@ -23,7 +23,7 @@ describe('Report in a timeline', () => {
await flushPromises() await flushPromises()
}) })
it('changes report stsatus from open to resolved', async (done) => { it('changes report state from open to resolved', async (done) => {
const report = store.state.reports.fetchedReports[0] const report = store.state.reports.fetchedReports[0]
const wrapper = mount(TimelineItem, { const wrapper = mount(TimelineItem, {
store, store,
...@@ -41,7 +41,7 @@ describe('Report in a timeline', () => { ...@@ -41,7 +41,7 @@ describe('Report in a timeline', () => {
done() done()
}) })
it('changes report stsatus from open to closed', async (done) => { it('changes report state from open to closed', async (done) => {
const report = store.state.reports.fetchedReports[3] const report = store.state.reports.fetchedReports[3]
const wrapper = mount(TimelineItem, { const wrapper = mount(TimelineItem, {
store, store,
...@@ -58,4 +58,54 @@ describe('Report in a timeline', () => { ...@@ -58,4 +58,54 @@ describe('Report in a timeline', () => {
expect(store.state.reports.fetchedReports[3].state).toBe('closed') expect(store.state.reports.fetchedReports[3].state).toBe('closed')
done() done()
}) })
it('shows statuses', () => {
const report = store.state.reports.fetchedReports[4]
const wrapper = mount(TimelineItem, {
store,
localVue,
propsData: {
report: report
}
})
const statuses = wrapper.findAll(`.el-card .status-card`)
expect(statuses.length).toEqual(2)
})
it('adds sensitive flag to a status', async (done) => {
const report = store.state.reports.fetchedReports[4]
const wrapper = mount(TimelineItem, {
store,
localVue,
propsData: {
report: report
}
})
expect(report.statuses[0].sensitive).toBe(false)
const button = wrapper.find(`.el-card .status-card li.el-dropdown-menu__item`)
button.trigger('click')
await flushPromises()
expect(store.state.reports.fetchedReports[4].statuses[0].sensitive).toEqual(true)
done()
})
it('removes sensitive flag to a status', async (done) => {
const report = store.state.reports.fetchedReports[4]
const wrapper = mount(TimelineItem, {
store,
localVue,
propsData: {
report: report
}
})
expect(report.statuses[1].sensitive).toBe(true)
const button = wrapper.find(`.status-card:nth-child(${2}) li.el-dropdown-menu__item`)
button.trigger('click')
await flushPromises()
expect(store.state.reports.fetchedReports[4].statuses[1].sensitive).toEqual(false)
done()
})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment