Skip to content

Commit c3404a5

Browse files
authored
Merge pull request #25 from LibreCodeCoop/chore/use-placeholder-to-star
chore: use placeholder to star
2 parents f98de17 + df1b55e commit c3404a5

2 files changed

Lines changed: 86 additions & 59 deletions

File tree

src/components/AdminSupportBanner.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ SPDX-License-Identifier: AGPL-3.0-or-later
2323

2424
<div class="profile-fields-admin-support-banner__links">
2525
<a href="https://github.com/LibreCodeCoop/profile_fields" target="_blank" rel="noopener noreferrer nofollow">
26-
{{ t('profile_fields', 'Give Profile Fields a ⭐ on GitHub') }}
27-
</a>
28-
<a href="mailto:contact@librecode.coop">
29-
{{ t('profile_fields', 'Contact us for support or custom development') }}
26+
{{ t('profile_fields', 'Give Profile Fields a {star} on GitHub', {star: '⭐'}) }}
3027
</a>
28+
<a href="mailto:contact@librecode.coop">{{ t('profile_fields', 'Contact us for support or custom development') }}</a>
3129
</div>
3230
</div>
3331
</div>
Lines changed: 84 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,102 @@
11
// SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
22
// SPDX-License-Identifier: AGPL-3.0-or-later
33

4-
import { afterEach, describe, expect, it, vi } from 'vitest'
5-
import { mount } from '@vue/test-utils'
6-
import { defineComponent, nextTick } from 'vue'
7-
import AdminSupportBanner from '../../../components/AdminSupportBanner.vue'
4+
import { afterEach, describe, expect, it, vi } from "vitest";
5+
import { mount } from "@vue/test-utils";
6+
import { defineComponent, nextTick } from "vue";
7+
import AdminSupportBanner from "../../../components/AdminSupportBanner.vue";
88

9-
vi.mock('@nextcloud/l10n', () => ({
10-
t: (_app: string, text: string, parameters?: Record<string, string>) => {
11-
if (parameters === undefined) {
12-
return `tr:${text}`
13-
}
9+
vi.mock("@nextcloud/l10n", () => ({
10+
t: (_app: string, text: string, parameters?: Record<string, string>) => {
11+
if (parameters === undefined) {
12+
return `tr:${text}`;
13+
}
1414

15-
return Object.entries(parameters).reduce((translated, [key, value]) => translated.replace(`{${key}}`, value), `tr:${text}`)
16-
},
17-
}))
15+
return Object.entries(parameters).reduce(
16+
(translated, [key, value]) => translated.replace(`{${key}}`, value),
17+
`tr:${text}`,
18+
);
19+
},
20+
}));
1821

19-
vi.mock('@nextcloud/vue', () => ({
20-
NcButton: defineComponent({
21-
name: 'NcButton',
22-
emits: ['click'],
23-
template: '<button type="button" v-bind="$attrs" @click="$emit(\'click\', $event)"><slot /></button>',
24-
}),
25-
NcNoteCard: defineComponent({
26-
name: 'NcNoteCard',
27-
template: '<div><slot /></div>',
28-
}),
29-
}))
22+
vi.mock("@nextcloud/vue", () => ({
23+
NcButton: defineComponent({
24+
name: "NcButton",
25+
emits: ["click"],
26+
template:
27+
'<button type="button" v-bind="$attrs" @click="$emit(\'click\', $event)"><slot /></button>',
28+
}),
29+
NcNoteCard: defineComponent({
30+
name: "NcNoteCard",
31+
template: "<div><slot /></div>",
32+
}),
33+
}));
3034

3135
afterEach(() => {
32-
window.localStorage.clear()
33-
vi.restoreAllMocks()
34-
})
36+
window.localStorage.clear();
37+
vi.restoreAllMocks();
38+
});
3539

36-
describe('AdminSupportBanner', () => {
37-
it('renders translated copy and actions', () => {
38-
const wrapper = mount(AdminSupportBanner)
40+
describe("AdminSupportBanner", () => {
41+
it("renders translated banner copy", () => {
42+
const wrapper = mount(AdminSupportBanner);
3943

40-
expect(wrapper.text()).toContain('tr:Help keep Profile Fields sustainable.')
41-
expect(wrapper.text()).toContain('tr:Sponsor LibreSign')
42-
expect(wrapper.text()).toContain('tr:Maybe later')
43-
expect(wrapper.text()).toContain('tr:Give Profile Fields a star on GitHub')
44-
})
44+
expect(wrapper.text()).toContain(
45+
"tr:Help keep Profile Fields sustainable.",
46+
);
47+
expect(wrapper.text()).toContain(
48+
"tr:Profile Fields is open source under the AGPL license and maintained by the LibreCode team, creators of LibreSign.",
49+
);
50+
expect(wrapper.text()).toContain(
51+
"tr:If your organization depends on it, please help us sustain its development and maintenance.",
52+
);
53+
expect(wrapper.text()).toContain("tr:Sponsor LibreSign");
54+
expect(wrapper.text()).toContain("tr:Maybe later");
55+
expect(wrapper.text()).toContain("tr:Give Profile Fields a ⭐ on GitHub");
56+
expect(wrapper.text()).toContain(
57+
"tr:Contact us for support or custom development",
58+
);
59+
});
4560

46-
it('opens sponsor page when sponsor button is clicked', async() => {
47-
const openSpy = vi.spyOn(window, 'open').mockImplementation(() => null)
48-
const wrapper = mount(AdminSupportBanner)
61+
it("opens sponsor page when sponsor button is clicked", async () => {
62+
const openSpy = vi.spyOn(window, "open").mockImplementation(() => null);
63+
const wrapper = mount(AdminSupportBanner);
4964

50-
await wrapper.get('button').trigger('click')
65+
await wrapper.get("button").trigger("click");
5166

52-
expect(openSpy).toHaveBeenCalledWith('https://github.com/sponsors/LibreCodeCoop', '_blank', 'noopener,noreferrer')
53-
})
67+
expect(openSpy).toHaveBeenCalledWith(
68+
"https://github.com/sponsors/LibreCodeCoop",
69+
"_blank",
70+
"noopener,noreferrer",
71+
);
72+
});
5473

55-
it('hides itself after dismiss and persists state', async() => {
56-
const wrapper = mount(AdminSupportBanner)
74+
it("hides itself after dismiss and persists state", async () => {
75+
const wrapper = mount(AdminSupportBanner);
5776

58-
const buttons = wrapper.findAll('button')
59-
await buttons[1].trigger('click')
77+
const buttons = wrapper.findAll("button");
78+
await buttons[1].trigger("click");
6079

61-
expect(wrapper.find('[data-testid="profile-fields-admin-support-banner"]').exists()).toBe(false)
62-
expect(window.localStorage.getItem('profile_fields_support_banner_dismissed')).toBe('1')
63-
})
80+
expect(
81+
wrapper
82+
.find('[data-testid="profile-fields-admin-support-banner"]')
83+
.exists(),
84+
).toBe(false);
85+
expect(
86+
window.localStorage.getItem("profile_fields_support_banner_dismissed"),
87+
).toBe("1");
88+
});
6489

65-
it('starts hidden when dismissal key is already persisted', () => {
66-
window.localStorage.setItem('profile_fields_support_banner_dismissed', '1')
90+
it("starts hidden when dismissal key is already persisted", () => {
91+
window.localStorage.setItem("profile_fields_support_banner_dismissed", "1");
6792

68-
const wrapper = mount(AdminSupportBanner)
69-
return nextTick().then(() => {
70-
expect(wrapper.find('[data-testid="profile-fields-admin-support-banner"]').exists()).toBe(false)
71-
})
72-
})
73-
})
93+
const wrapper = mount(AdminSupportBanner);
94+
return nextTick().then(() => {
95+
expect(
96+
wrapper
97+
.find('[data-testid="profile-fields-admin-support-banner"]')
98+
.exists(),
99+
).toBe(false);
100+
});
101+
});
102+
});

0 commit comments

Comments
 (0)