diff --git a/webapp/components/_new/features/Admin/Badges/BadgesSection.spec.js b/webapp/components/_new/features/Admin/Badges/BadgesSection.spec.js index 8baddc692..8abf8d679 100644 --- a/webapp/components/_new/features/Admin/Badges/BadgesSection.spec.js +++ b/webapp/components/_new/features/Admin/Badges/BadgesSection.spec.js @@ -21,26 +21,41 @@ const badge2 = { describe('Admin/BadgesSection', () => { let wrapper - const Wrapper = () => { + const Wrapper = (withBadges = true) => { return render(BadgesSection, { localVue, propsData: { - badges: [badge1, badge2], + badges: withBadges ? [badge1, badge2] : [], + }, + mocks: { + $t: jest.fn((t) => t), }, }) } - beforeEach(() => { - wrapper = Wrapper() + describe('without badges', () => { + beforeEach(() => { + wrapper = Wrapper(false) + }) + + it('renders', () => { + expect(wrapper.baseElement).toMatchSnapshot() + }) }) - it('renders', () => { - expect(wrapper.baseElement).toMatchSnapshot() - }) + describe('with badges', () => { + beforeEach(() => { + wrapper = Wrapper(true) + }) - it('emits toggleButton', async () => { - const button = screen.getByAltText(badge1.description) - await fireEvent.click(button) - expect(wrapper.emitted().toggleBadge[0][0]).toEqual(badge1) + it('renders', () => { + expect(wrapper.baseElement).toMatchSnapshot() + }) + + it('emits toggleButton', async () => { + const button = screen.getByAltText(badge1.description) + await fireEvent.click(button) + expect(wrapper.emitted().toggleBadge[0][0]).toEqual(badge1) + }) }) }) diff --git a/webapp/components/_new/features/Admin/Badges/BadgesSection.vue b/webapp/components/_new/features/Admin/Badges/BadgesSection.vue index 8ff9da7ed..fc89d2a50 100644 --- a/webapp/components/_new/features/Admin/Badges/BadgesSection.vue +++ b/webapp/components/_new/features/Admin/Badges/BadgesSection.vue @@ -1,16 +1,19 @@ diff --git a/webapp/components/_new/features/Admin/Badges/__snapshots__/BadgesSection.spec.js.snap b/webapp/components/_new/features/Admin/Badges/__snapshots__/BadgesSection.spec.js.snap index c09a50725..a78f44edc 100644 --- a/webapp/components/_new/features/Admin/Badges/__snapshots__/BadgesSection.spec.js.snap +++ b/webapp/components/_new/features/Admin/Badges/__snapshots__/BadgesSection.spec.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Admin/BadgesSection renders 1`] = ` +exports[`Admin/BadgesSection with badges renders 1`] = `
`; + +exports[`Admin/BadgesSection without badges renders 1`] = ` + +
+
+

+ +

+ +
+ + admin.badges.noBadges + +
+
+
+ +`; diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 4fe39ce24..6b588f746 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": "Stelle die verfügbaren Auszeichnungen für diesen Nutzer ein.", + "noBadges": "Keine Auszeichnungen vorhanden.", "revokeTrophy": { "error": "Trophäe konnte nicht widerrufen werden!", "success": "Trophäe erfolgreich widerrufen" diff --git a/webapp/locales/en.json b/webapp/locales/en.json index bdd9cdefb..24fd16440 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": "Configure the available badges for this user", + "noBadges": "There are no badges available", "revokeTrophy": { "error": "Trophy could not be revoked!", "success": "Trophy successfully revoked!" diff --git a/webapp/locales/es.json b/webapp/locales/es.json index 60e65ca20..5bc6b1b6d 100644 --- a/webapp/locales/es.json +++ b/webapp/locales/es.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/locales/fr.json b/webapp/locales/fr.json index e7b4fcd4a..90164c47a 100644 --- a/webapp/locales/fr.json +++ b/webapp/locales/fr.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/locales/it.json b/webapp/locales/it.json index 703b27fff..1674a9cb3 100644 --- a/webapp/locales/it.json +++ b/webapp/locales/it.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/locales/nl.json b/webapp/locales/nl.json index f6a53d0c8..0944dc472 100644 --- a/webapp/locales/nl.json +++ b/webapp/locales/nl.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/locales/pl.json b/webapp/locales/pl.json index 4e928f417..ba5a61bca 100644 --- a/webapp/locales/pl.json +++ b/webapp/locales/pl.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/locales/pt.json b/webapp/locales/pt.json index 005eb77f4..6b6f07132 100644 --- a/webapp/locales/pt.json +++ b/webapp/locales/pt.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/locales/ru.json b/webapp/locales/ru.json index bc862bcc2..7bc33e628 100644 --- a/webapp/locales/ru.json +++ b/webapp/locales/ru.json @@ -12,6 +12,7 @@ "admin": { "badges": { "description": null, + "noBadges": null, "revokeTrophy": { "error": null, "success": null diff --git a/webapp/nuxt.config.js b/webapp/nuxt.config.js index 07cfa6bc4..263c3f149 100644 --- a/webapp/nuxt.config.js +++ b/webapp/nuxt.config.js @@ -207,15 +207,6 @@ export default { 'X-API-TOKEN': CONFIG.BACKEND_TOKEN, }, }, - '/img': { - // make this configurable (nuxt-dotenv) - target: CONFIG.GRAPHQL_URI, - toProxy: true, // cloudflare needs that - headers: { - 'X-UI-Request': true, - 'X-API-TOKEN': CONFIG.BACKEND_TOKEN, - }, - }, }, // Give apollo module options diff --git a/webapp/pages/admin/users/_id.spec.js b/webapp/pages/admin/users/_id.spec.js index 933de58de..d38b13022 100644 --- a/webapp/pages/admin/users/_id.spec.js +++ b/webapp/pages/admin/users/_id.spec.js @@ -58,6 +58,11 @@ describe('.vue', () => { query: jest.fn(), }, mutate: jest.fn(), + queries: { + Badge: { + loading: false, + }, + }, }, $toast: { success: jest.fn(), diff --git a/webapp/pages/admin/users/_id.vue b/webapp/pages/admin/users/_id.vue index 808e1653a..a6c4dafaa 100644 --- a/webapp/pages/admin/users/_id.vue +++ b/webapp/pages/admin/users/_id.vue @@ -8,7 +8,7 @@ {{ $t('admin.badges.description') }} - + userBadge.id === badge.id), })) }, + isLoadingBadges() { + return this.$apollo.queries.Badge.loading + }, }, methods: { toggleBadge(badge) {