Skip to content
Merged
8 changes: 6 additions & 2 deletions src/app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
"trash": "Papierkorb",
"desktop": "Desktop",
"referralBanner": {
"message": "Denk daran! Verdiene bis zu 1.000 €, indem du einen Freund empfiehlst",
"message": "Verdiene 10% Provision für jede Empfehlung!",
"cta": "Empfehlen und verdienen"
}
},
Expand Down Expand Up @@ -401,7 +401,7 @@
"settings": "Einstellungen",
"logout": "Log-out",
"referAndEarn": "Empfehlen und verdienen",
"earnReferral": "Verdiene 1.000 €",
"earnReferral": "Verdiene 100 €",
"spaceUsed": "{{space}}% Platz verbraucht"
},
"tabs": {
Expand Down Expand Up @@ -1588,6 +1588,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "Bestätige deine E-Mail-Adresse, um für Empfehlungen berechtigt zu sein. Überprüfe deinen Posteingang oder",
"resendVerification": "Bestätigung erneut senden"
},
"items": {
"create-account": "Erstelle ein Konto",
"install-mobile-app": "Installiere die mobile App und lade eine Datei hoch",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@
"trash": "Trash",
"desktop": "Desktop",
"referralBanner": {
"message": "Remember! Earn up to €1,000 by referring a friend",
"message": "Earn 10% commission for every referral!",
"cta": "Refer and Earn"
}
},
Expand Down Expand Up @@ -461,7 +461,7 @@
"settings": "Settings",
"logout": "Log out",
"referAndEarn": "Refer and Earn",
"earnReferral": "Earn €1,000",
"earnReferral": "Earn €100",
"spaceUsed": "{{space}}% space used"
},
"tabs": {
Expand Down Expand Up @@ -1671,6 +1671,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "Verify your email to be eligible to referrals. Check your inbox or",
"resendVerification": "resend verification"
},
"items": {
"create-account": "Create an account",
"install-mobile-app": "Install mobile app and upload a file",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
"trash": "Papelera",
"desktop": "Escritorio",
"referralBanner": {
"message": "¡Recuerda! Gana hasta 1.000 € recomendando a un amigo",
"message": "¡Gana un 10% de comisión por cada referido!",
"cta": "Recomienda y gana"
}
},
Expand Down Expand Up @@ -444,7 +444,7 @@
"settings": "Ajustes",
"logout": "Cerrar sesión",
"referAndEarn": "Recomienda y gana",
"earnReferral": "Gana 1.000 €",
"earnReferral": "Gana 100 €",
"spaceUsed": "{{space}}% espacio usado"
},
"tabs": {
Expand Down Expand Up @@ -1648,6 +1648,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "Verifica tu correo electrónico para ser elegible para referidos. Revisa tu bandeja de entrada o",
"resendVerification": "reenviar verificación"
Comment on lines +1651 to +1653
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something’s missing here "Revisa tu bandeja de entrada o" or what? :O
It might work in English, but in other languages it sounds a bit robotic, like in Spanish

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is aligned with the design provided by the product team

},
"items": {
"create-account": "Crea una cuenta",
"install-mobile-app": "Instala la app móvil y sube un archivo",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
"trash": "Corbeille",
"desktop": "App de bureau",
"referralBanner": {
"message": "N'oubliez pas ! Gagnez jusqu'à 1 000 € en parrainant un ami",
"message": "Gagnez 10% de commission pour chaque parrainage !",
"cta": "Parrainez et gagnez"
}
},
Expand Down Expand Up @@ -413,7 +413,7 @@
"settings": "Paramètres",
"logout": "Déconnexion",
"referAndEarn": "Parrainez et gagnez",
"earnReferral": "Gagnez 1 000 €",
"earnReferral": "Gagnez 100 €",
"spaceUsed": "{{space}}% d'espace utilisé"
},
"tabs": {
Expand Down Expand Up @@ -1594,6 +1594,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "Vérifiez votre e-mail pour être éligible aux parrainages. Consultez votre boîte de réception ou",
"resendVerification": "renvoyer la vérification"
},
"items": {
"create-account": "Créer un compte",
"install-mobile-app": "Installer l'app mobile et télécharger un fichier",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@
"trash": "Cestino",
"desktop": "Applicazione desktop",
"referralBanner": {
"message": "Ricorda! Guadagna fino a 1.000 € invitando un amico",
"message": "Guadagna il 10% di commissione per ogni referral!",
"cta": "Invita e guadagna"
}
},
Expand Down Expand Up @@ -504,7 +504,7 @@
"settings": "Impostazioni",
"logout": "Disconnettersi",
"referAndEarn": "Invita e guadagna",
"earnReferral": "Guadagna 1.000 €",
"earnReferral": "Guadagna 100 €",
"spaceUsed": "{{space}}% spazio usato"
},
"tabs": {
Expand Down Expand Up @@ -1701,6 +1701,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "Verifica la tua email per essere idoneo ai referral. Controlla la tua casella di posta o",
"resendVerification": "rinvia verifica"
},
"items": {
"create-account": "Creazione dell’account",
"install-mobile-app": "Installa l’app mobile e carica un file",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
"trash": "Корзина",
"desktop": "Рабочий стол",
"referralBanner": {
"message": "Помните! Заработайте до 1 000 €, пригласив друга",
"message": "Зарабатывайте 10% комиссии за каждого приглашённого!",
"cta": "Приглашайте и зарабатывайте"
}
},
Expand Down Expand Up @@ -413,7 +413,7 @@
"settings": "Настройки",
"logout": "Выйти",
"referAndEarn": "Приглашайте и зарабатывайте",
"earnReferral": "Заработайте 1 000 €",
"earnReferral": "Заработайте 100 €",
"spaceUsed": "{{space}}% памяти использовано"
},
"tabs": {
Expand Down Expand Up @@ -1609,6 +1609,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "Подтвердите свою электронную почту, чтобы участвовать в реферальной программе. Проверьте свой почтовый ящик или",
"resendVerification": "отправить повторно"
},
"items": {
"create-account": "Создать аккаунт",
"install-mobile-app": "Установить мобильное приложение и загрузить файл",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
"trash": "垃圾桶",
"desktop": "桌面",
"referralBanner": {
"message": "別忘了!推薦朋友最高可賺取 €1,000",
"message": "每次推薦可賺取10%佣金!",
"cta": "推薦賺取"
}
},
Expand Down Expand Up @@ -429,7 +429,7 @@
"settings": "設定",
"logout": "登出",
"referAndEarn": "推薦賺取",
"earnReferral": "賺取 €1,000",
"earnReferral": "賺取 €100",
"spaceUsed": "已使用 {{space}}% 的空間"
},
"tabs": {
Expand Down Expand Up @@ -1601,6 +1601,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "請驗證您的電子郵件以獲得推薦資格。請檢查您的收件匣或",
"resendVerification": "重新發送驗證"
},
"items": {
"create-account": "創建帳戶",
"install-mobile-app": "安裝移動應用程序並上傳文件",
Expand Down
8 changes: 6 additions & 2 deletions src/app/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
"trash": "垃圾箱",
"desktop": "桌面应用程序",
"referralBanner": {
"message": "别忘了!推荐朋友最高可赚取 €1,000",
"message": "每次推荐可赚取10%佣金!",
"cta": "推荐赚取"
}
},
Expand Down Expand Up @@ -427,7 +427,7 @@
"settings": "设置",
"logout": "登出",
"referAndEarn": "推荐赚取",
"earnReferral": "赚取 €1,000",
"earnReferral": "赚取 €100",
"spaceUsed": "已使用储存空间的{{space}}%"
},
"tabs": {
Expand Down Expand Up @@ -1636,6 +1636,10 @@
}
},
"referrals": {
"emailVerification": {
"message": "请验证您的电子邮件以获得推荐资格。请检查您的收件箱或",
"resendVerification": "重新发送验证"
},
"items": {
"create-account": "创建一个账户",
"install-mobile-app": "安装移动应用程序并上传一个文件",
Expand Down
6 changes: 6 additions & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ code {
}
}

#cello-launcher > div {
position: absolute !important;
top: 2px;
right: 2px;
}

/* RECAPTCHA */
.grecaptcha-badge {
visibility: hidden;
Expand Down
77 changes: 77 additions & 0 deletions src/services/referral.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ vi.mock('./date.service', () => ({
},
}));

const mockRefreshUser = vi.fn().mockResolvedValue({ user: { emailVerified: true } });

vi.mock('app/core/factory/sdk', () => ({
SdkFactory: {
getNewApiInstance: vi.fn(() => ({
createReferralsClient: vi.fn(() => ({
createReferralToken: vi.fn().mockResolvedValue({ token: 'mock-token' }),
isReferralEnabled: vi.fn().mockResolvedValue({ isEnabled: true }),
})),
createUsersClient: vi.fn(() => ({
refreshUser: mockRefreshUser,
})),
})),
},
}));
Expand Down Expand Up @@ -169,6 +174,25 @@ describe('referralService', () => {
});
});

describe('isEligibleForReferral', () => {
it('when no account creation date is provided, then the user is eligible', async () => {
expect(await referralService.isEligibleForReferral()).toBe(true);
});

it.each([
{ scenario: 'when the account is older than 30 days, then the user is eligible', days: 31, expected: true },
{ scenario: 'when the account is exactly 30 days old, then the user is eligible', days: 30, expected: true },
{
scenario: 'when the account is younger than 30 days, then the user is not eligible',
days: 15,
expected: false,
},
])('$scenario', async ({ days, expected }) => {
vi.mocked(dateService.getDaysSince).mockReturnValue(days);

expect(await referralService.isEligibleForReferral(new Date())).toBe(expected);
});
});
describe('tracking events', () => {
it.each([
{
Expand Down Expand Up @@ -283,6 +307,26 @@ describe('referralService', () => {
});
});

describe('getCustomLauncherLabel', () => {
it('when the Cello widget is loaded, then the custom launcher label is returned', async () => {
const mockCello = vi.fn().mockResolvedValue({ customLauncher: 'Give 85% off' });
globalThis.Cello = mockCello;

const label = await referralService.getCustomLauncherLabel();

expect(mockCello).toHaveBeenCalledWith('getLabels');
expect(label).toBe('Give 85% off');
});

it('when the Cello widget is not available, then undefined is returned', async () => {
delete globalThis.Cello;

const label = await referralService.getCustomLauncherLabel();

expect(label).toBeUndefined();
});
});

describe('changeLanguage', () => {
it('when the referral widget is loaded, then the language is updated', async () => {
const mockCello = vi.fn().mockResolvedValue(undefined);
Expand Down Expand Up @@ -374,5 +418,38 @@ describe('referralService', () => {
const saved = localStorage.getItem(BANNER_STATE_KEY);
expect(saved).toBeNull();
});

it('when the API returns emailVerified true but the passed-in value is false, then the panel opens', async () => {
setupCelloBootFlow();
const mockCello = vi.fn().mockResolvedValue(undefined);
globalThis.Cello = mockCello;
mockRefreshUser.mockResolvedValueOnce({ user: { emailVerified: true } });

const unverifiedUser = { ...mockUser, emailVerified: false };
await referralService.openPanel(unverifiedUser);

expect(mockCello).toHaveBeenCalledWith('open');
});

it('when the API call fails, then it falls back to the passed-in emailVerified value', async () => {
mockRefreshUser.mockRejectedValueOnce(new Error('network error'));

const unverifiedUser = { ...mockUser, emailVerified: false };
await referralService.openPanel(unverifiedUser);

expect(globalThis.Cello).toBeUndefined();
});

it('when email is already verified, then the panel opens', async () => {
const mockCello = vi.fn().mockResolvedValue(undefined);
globalThis.Cello = mockCello;
mockRefreshUser.mockResolvedValueOnce({ user: { emailVerified: false } });

await referralService.openPanel(mockUser);

expect(mockRefreshUser).not.toHaveBeenCalled();
expect(mockCello).toHaveBeenCalledWith('open');
expect(mockCello).not.toHaveBeenCalledWith('close');
});
});
});
Loading
Loading