From b4ab63907c66e10703f12f50635e7644d548fe2b Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Sat, 18 May 2019 20:40:28 +0800 Subject: [PATCH 1/4] Test cases for #61 --- .../assets/tests/views/skinlib/Show.test.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/resources/assets/tests/views/skinlib/Show.test.ts b/resources/assets/tests/views/skinlib/Show.test.ts index f3eb8387..79bebe2e 100644 --- a/resources/assets/tests/views/skinlib/Show.test.ts +++ b/resources/assets/tests/views/skinlib/Show.test.ts @@ -38,7 +38,7 @@ test('button for adding to closet should be disabled if not auth', () => { expect(wrapper.find(Button).attributes('disabled')).toBe('disabled') }) -test('button for adding to closet should be disabled if auth', () => { +test('button for adding to closet should be enabled if auth', () => { Vue.prototype.$http.get.mockResolvedValue({ data: {} }) Object.assign(window.blessing.extra, { inCloset: true, currentUid: 1 }) const wrapper = mount(Show, { @@ -132,6 +132,28 @@ test('operation panel should not be rendered if not auth', () => { expect(wrapper.find('.box-warning').exists()).toBeFalse() }) +test('operation panel should not be rendered if not privileged', () => { + Object.assign(window.blessing.extra, { currentUid: 2 }) + Vue.prototype.$http.get.mockResolvedValue({ data: { uploader: 1 } }) + const wrapper = mount(Show, { + mocks: { + $route: ['/skinlib/show/1', '1'], + }, + }) + expect(wrapper.find('.box-warning').exists()).toBeFalse() +}) + +test('operation panel should be rendered if privileged', () => { + Object.assign(window.blessing.extra, { currentUid: 1 }) + Vue.prototype.$http.get.mockResolvedValue({ data: { uploader: 1 } }) + const wrapper = mount(Show, { + mocks: { + $route: ['/skinlib/show/1', '1'], + }, + }) + expect(wrapper.find('.box-warning').exists()).toBeTrue() +}) + test('download texture', async () => { Object.assign(window.blessing.extra, { currentUid: 1 }) Vue.prototype.$http.get.mockResolvedValue({ data: { tid: 1, name: 'abc' } }) From 4012cfc46fb099b6d7af49206b308d83044f6184 Mon Sep 17 00:00:00 2001 From: yushijinhun Date: Sat, 18 May 2019 20:41:59 +0800 Subject: [PATCH 2/4] Fix #61 --- resources/assets/src/views/skinlib/Show.vue | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/assets/src/views/skinlib/Show.vue b/resources/assets/src/views/skinlib/Show.vue index d18328cb..d0443fe1 100644 --- a/resources/assets/src/views/skinlib/Show.vue +++ b/resources/assets/src/views/skinlib/Show.vue @@ -8,7 +8,7 @@ :init-position-z="60" >