From d2fabe7a3cda5211e34d79367760616d78f6db3a Mon Sep 17 00:00:00 2001 From: Red-Asuka Date: Wed, 11 Dec 2024 17:17:23 +0800 Subject: [PATCH] feat(useLinks): update unit tests --- packages/ui/components.d.ts | 2 ++ .../src/composables/__test__/useLinks.test.ts | 28 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/ui/components.d.ts b/packages/ui/components.d.ts index 34cd40865..9d3f59138 100644 --- a/packages/ui/components.d.ts +++ b/packages/ui/components.d.ts @@ -25,12 +25,14 @@ declare module 'vue' { ElIconDelete: typeof import('@element-plus/icons-vue')['Delete'] ElIconDownload: typeof import('@element-plus/icons-vue')['Download'] ElIconPrinter: typeof import('@element-plus/icons-vue')['Printer'] + ElIconRight: typeof import('@element-plus/icons-vue')['Right'] ElIconUpload: typeof import('@element-plus/icons-vue')['Upload'] ElIconWarning: typeof import('@element-plus/icons-vue')['Warning'] ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElMain: typeof import('element-plus/es')['ElMain'] ElOption: typeof import('element-plus/es')['ElOption'] + ElPopover: typeof import('element-plus/es')['ElPopover'] ElRow: typeof import('element-plus/es')['ElRow'] ElSelect: typeof import('element-plus/es')['ElSelect'] ElSwitch: typeof import('element-plus/es')['ElSwitch'] diff --git a/packages/ui/src/composables/__test__/useLinks.test.ts b/packages/ui/src/composables/__test__/useLinks.test.ts index 5425e2715..08c934993 100644 --- a/packages/ui/src/composables/__test__/useLinks.test.ts +++ b/packages/ui/src/composables/__test__/useLinks.test.ts @@ -99,7 +99,7 @@ describe('useLinks', () => { faq: 'https://mqttx.app/zh/docs/faq?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-faq', MQTTX: 'https://mqttx.app/zh?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-mqttx', EMQ: 'https://emqx.com/zh?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-homepage', - EMQXCloud: 'https://emqx.com/zh/cloud?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud', + EMQXCloud: 'https://accounts-zh.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew', }) await setupI18n('en') @@ -108,7 +108,7 @@ describe('useLinks', () => { faq: 'https://mqttx.app/docs/faq?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-faq', MQTTX: 'https://mqttx.app?utm_source=mqttx&utm_medium=referral&utm_campaign=about-to-mqttx', EMQ: 'https://emqx.com/en?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-homepage', - EMQXCloud: 'https://emqx.com/en/cloud?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud', + EMQXCloud: 'https://accounts.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew', }) }) @@ -135,4 +135,28 @@ describe('useLinks', () => { blogUtm: '?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-help-to-blog', }) }) + + it('should return correct authSite based on locale', async () => { + await setupI18n('zh') + const wrapper = mount(createTestComponent(), { global: { plugins: [i18n] } }) + expect(wrapper.vm.authSite).toBe('https://accounts-zh.emqx.com') + + await setupI18n('ja') + expect(wrapper.vm.authSite).toBe('https://accounts.emqx.com/ja') + + await setupI18n('en') + expect(wrapper.vm.authSite).toBe('https://accounts.emqx.com') + }) + + it('should return correct cloudTrial link', async () => { + await setupI18n('zh') + const wrapper = mount(createTestComponent(), { global: { plugins: [i18n] } }) + expect(wrapper.vm.cloudTrial).toBe('https://accounts-zh.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew') + + await setupI18n('ja') + expect(wrapper.vm.cloudTrial).toBe('https://accounts.emqx.com/ja/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew') + + await setupI18n('en') + expect(wrapper.vm.cloudTrial).toBe('https://accounts.emqx.com/signup?utm_source=mqttx&utm_medium=referral&utm_campaign=mqttx-to-cloud&continue=https%3A%2F%2Fcloud.emqx.com%2Fconsole%2Fdeployments%2Fnew') + }) })