feat(apps): update mobile app store links and implement unified device-detecting QR code
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { NextRequest } from 'next/server';
|
||||
import { GET } from '@/app/go/[tool]/[app]/route';
|
||||
|
||||
describe('/go/[tool]/[app] dynamic redirect route', () => {
|
||||
it('redirects Android user to Enhance Photo Quality on Google Play', async () => {
|
||||
const req = new NextRequest('http://localhost:3000/go/photo-enhancer/photo-enhancer-pro', {
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 Chrome/120.0.0.0 Mobile Safari/537.36',
|
||||
},
|
||||
});
|
||||
|
||||
const res = await GET(req, {
|
||||
params: { tool: 'photo-enhancer', app: 'photo-enhancer-pro' },
|
||||
});
|
||||
|
||||
expect(res.status).toBe(307);
|
||||
const location = res.headers.get('location');
|
||||
expect(location).toContain('play.google.com/store/apps/details?id=com.smartworld.enhancephotoquality');
|
||||
expect(location).toContain('pcampaignid=web_share');
|
||||
expect(location).toContain('referrer=utm_source');
|
||||
});
|
||||
|
||||
it('redirects iOS user to Enhance Photo Quality on Apple App Store', async () => {
|
||||
const req = new NextRequest('http://localhost:3000/go/photo-enhancer/photo-enhancer-pro', {
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1',
|
||||
},
|
||||
});
|
||||
|
||||
const res = await GET(req, {
|
||||
params: { tool: 'photo-enhancer', app: 'photo-enhancer-pro' },
|
||||
});
|
||||
|
||||
expect(res.status).toBe(307);
|
||||
const location = res.headers.get('location');
|
||||
expect(location).toContain('apps.apple.com/mm/app/enhance-photo-quality/id1587310121');
|
||||
});
|
||||
|
||||
it('redirects Android user to BG Remove / Dress Changer on Google Play', async () => {
|
||||
const req = new NextRequest('http://localhost:3000/go/background-remover/bg-cleaner-app', {
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (Linux; Android 14; Samsung Galaxy S24) AppleWebKit/537.36',
|
||||
},
|
||||
});
|
||||
|
||||
const res = await GET(req, {
|
||||
params: { tool: 'background-remover', app: 'bg-cleaner-app' },
|
||||
});
|
||||
|
||||
expect(res.status).toBe(307);
|
||||
const location = res.headers.get('location');
|
||||
expect(location).toContain('play.google.com/store/apps/details?id=com.me2creative.AiDressChanger');
|
||||
expect(location).toContain('pcampaignid=web_share');
|
||||
});
|
||||
|
||||
it('redirects iOS user to BG Remove: Background Editor on Apple App Store', async () => {
|
||||
const req = new NextRequest('http://localhost:3000/go/background-remover/bg-cleaner-app', {
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15',
|
||||
},
|
||||
});
|
||||
|
||||
const res = await GET(req, {
|
||||
params: { tool: 'background-remover', app: 'bg-cleaner-app' },
|
||||
});
|
||||
|
||||
expect(res.status).toBe(307);
|
||||
const location = res.headers.get('location');
|
||||
expect(location).toContain('apps.apple.com/bn/app/bg-remove-background-editor/id1497878283');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user