1
Fork 0

Fix UI not serving media and tests expecting localhost:3000 as base URL (#874)

* fix UI tests expecting localhost:3000 as base URL

* fix: avoid prefixing UI domain when serving media URLs
This commit is contained in:
Davide Cavestro 2024-03-29 14:49:50 +01:00 committed by GitHub
parent a90f30391c
commit b8504c47be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 35 additions and 38 deletions

View File

@ -13,7 +13,7 @@ test('face circle image', () => {
title: 'my_image.jpg', title: 'my_image.jpg',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_my_image_jpg_p9x8dLWr.jpg', url: '/photo/thumbnail_my_image_jpg_p9x8dLWr.jpg',
width: 1024, width: 1024,
height: 641, height: 641,
}, },
@ -32,6 +32,6 @@ test('face circle image', () => {
expect(screen.getByRole('img')).toBeInTheDocument() expect(screen.getByRole('img')).toBeInTheDocument()
expect(screen.getByRole('img')).toHaveAttribute( expect(screen.getByRole('img')).toHaveAttribute(
'src', 'src',
imageFace.media.thumbnail!.url 'http://localhost:3000/photo/thumbnail_my_image_jpg_p9x8dLWr.jpg'
) )
}) })

View File

@ -48,7 +48,7 @@ describe('PeoplePage component', () => {
title: 'image.jpg', title: 'image.jpg',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_image_jpg_p9x8dLWr.jpg', url: '/photo/thumbnail_image_jpg_p9x8dLWr.jpg',
width: 1024, width: 1024,
height: 641, height: 641,
}, },
@ -119,7 +119,7 @@ describe('FaceDetails component', () => {
id: '63', id: '63',
title: 'image.jpg', title: 'image.jpg',
thumbnail: { thumbnail: {
url: 'http://localhost:4001/photo/thumbnail_image_jpg_p9x8dLWr.jpg', url: '/photo/thumbnail_image_jpg_p9x8dLWr.jpg',
width: 1024, width: 1024,
height: 641, height: 641,
__typename: 'MediaURL', __typename: 'MediaURL',

View File

@ -37,13 +37,13 @@ test('single face group', async () => {
title: '122A2785-2.jpg', title: '122A2785-2.jpg',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2785-2_jpg_lFmZcaN5.jpg', url: '/photo/thumbnail_122A2785-2_jpg_lFmZcaN5.jpg',
width: 1024, width: 1024,
height: 1024, height: 1024,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2785-2_e4nCeMHU.jpg', url: '/photo/122A2785-2_e4nCeMHU.jpg',
}, },
favorite: false, favorite: false,
}, },
@ -65,13 +65,13 @@ test('single face group', async () => {
title: 'image.png', title: 'image.png',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_image_png_OwTDG5fM.jpg', url: '/photo/thumbnail_image_png_OwTDG5fM.jpg',
width: 1024, width: 1024,
height: 699, height: 699,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/image_A2YB0x3z.png', url: '/photo/image_A2YB0x3z.png',
}, },
favorite: false, favorite: false,
}, },

View File

@ -19,7 +19,7 @@ test('photo gallery with media', () => {
id: '165', id: '165',
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
url: 'http://localhost:4001/photo/thumbnail_3666760020_jpg_x76GG5pS.jpg', url: '/photo/thumbnail_3666760020_jpg_x76GG5pS.jpg',
width: 768, width: 768,
height: 1024, height: 1024,
__typename: 'MediaURL', __typename: 'MediaURL',
@ -96,7 +96,7 @@ describe('photo gallery presenting', () => {
id: '165', id: '165',
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
url: 'http://localhost:4001/photo/thumbnail_3666760020_jpg_x76GG5pS.jpg', url: '/photo/thumbnail_3666760020_jpg_x76GG5pS.jpg',
width: 768, width: 768,
height: 1024, height: 1024,
__typename: 'MediaURL', __typename: 'MediaURL',

View File

@ -13,10 +13,7 @@ const placeholder =
const getProtectedUrl = (url?: string) => { const getProtectedUrl = (url?: string) => {
if (url == undefined) return undefined if (url == undefined) return undefined
const imgUrl = new URL( const imgUrl = new URL(url, location.origin)
`${import.meta.env.BASE_URL}${url}`.replace(/\/\//g, '/'),
location.origin
)
const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/) const tokenRegex = location.pathname.match(/^\/share\/([\d\w]+)(\/?.*)$/)
if (tokenRegex) { if (tokenRegex) {

View File

@ -19,13 +19,13 @@ describe('MediaSidebar', () => {
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail.jpg', url: '/photo/thumbnail.jpg',
width: 1024, width: 1024,
height: 839, height: 839,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/highres.jpg', url: '/photo/highres.jpg',
width: 5322, width: 5322,
height: 4362, height: 4362,
}, },
@ -51,7 +51,7 @@ describe('MediaSidebar', () => {
expect(screen.getByText('122A6069.jpg')).toBeInTheDocument() expect(screen.getByText('122A6069.jpg')).toBeInTheDocument()
expect(screen.getByRole('img')).toHaveAttribute( expect(screen.getByRole('img')).toHaveAttribute(
'src', 'src',
'http://localhost:4001/photo/highres.jpg' 'http://localhost:3000/photo/highres.jpg'
) )
expect( expect(
@ -74,7 +74,7 @@ describe('MediaSidebar', () => {
expect(screen.getByText('122A6069.jpg')).toBeInTheDocument() expect(screen.getByText('122A6069.jpg')).toBeInTheDocument()
expect(screen.getByRole('img')).toHaveAttribute( expect(screen.getByRole('img')).toHaveAttribute(
'src', 'src',
'http://localhost:4001/photo/highres.jpg' 'http://localhost:3000/photo/highres.jpg'
) )
expect(screen.getByText('Set as album cover photo')).toBeInTheDocument() expect(screen.getByText('Set as album cover photo')).toBeInTheDocument()

View File

@ -49,14 +49,14 @@ describe('timeline gallery reducer', () => {
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 4480, height: 4480,
url: 'http://localhost:4001/photo/122A2876_5cSPMiKL.jpg', url: '/photo/122A2876_5cSPMiKL.jpg',
width: 6720, width: 6720,
}, },
id: '1058', id: '1058',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 682, height: 682,
url: 'http://localhost:4001/photo/thumbnail_122A2876_jpg_Kp1U80vD.jpg', url: '/photo/thumbnail_122A2876_jpg_Kp1U80vD.jpg',
width: 1024, width: 1024,
}, },
title: '122A2876.jpg', title: '122A2876.jpg',
@ -87,14 +87,14 @@ describe('timeline gallery reducer', () => {
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 4118, height: 4118,
url: 'http://localhost:4001/photo/122A2630-Edit_ySQWFAgE.jpg', url: '/photo/122A2630-Edit_ySQWFAgE.jpg',
width: 6177, width: 6177,
}, },
id: '1059', id: '1059',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 682, height: 682,
url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_pwjtMkpy.jpg', url: '/photo/thumbnail_122A2630-Edit_jpg_pwjtMkpy.jpg',
width: 1024, width: 1024,
}, },
title: '122A2630-Edit.jpg', title: '122A2630-Edit.jpg',
@ -113,14 +113,14 @@ describe('timeline gallery reducer', () => {
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 884, height: 884,
url: 'http://localhost:4001/photo/122A2785-2_mCnWjLdb.jpg', url: '/photo/122A2785-2_mCnWjLdb.jpg',
width: 884, width: 884,
}, },
id: '1060', id: '1060',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 1024, height: 1024,
url: 'http://localhost:4001/photo/thumbnail_122A2785-2_jpg_CevmxEXf.jpg', url: '/photo/thumbnail_122A2785-2_jpg_CevmxEXf.jpg',
width: 1024, width: 1024,
}, },
title: '122A2785-2.jpg', title: '122A2785-2.jpg',
@ -145,14 +145,14 @@ describe('timeline gallery reducer', () => {
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 4118, height: 4118,
url: 'http://localhost:4001/photo/122A2630-Edit_em9g89qg.jpg', url: '/photo/122A2630-Edit_em9g89qg.jpg',
width: 6177, width: 6177,
}, },
id: '1056', id: '1056',
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
height: 682, height: 682,
url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_aJPCSDDl.jpg', url: '/photo/thumbnail_122A2630-Edit_jpg_aJPCSDDl.jpg',
width: 1024, width: 1024,
}, },
title: '122A2630-Edit.jpg', title: '122A2630-Edit.jpg',
@ -177,13 +177,13 @@ describe('timeline gallery reducer', () => {
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2559_jpg_MsOJtPi8.jpg', url: '/photo/thumbnail_122A2559_jpg_MsOJtPi8.jpg',
width: 1024, width: 1024,
height: 712, height: 712,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2559_FDsQHuBN.jpg', url: '/photo/122A2559_FDsQHuBN.jpg',
width: 6246, width: 6246,
height: 4346, height: 4346,
}, },

View File

@ -9,13 +9,13 @@ export const timelineData: myTimeline_myTimeline[] = [
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2876_jpg_Kp1U80vD.jpg', url: '/photo/thumbnail_122A2876_jpg_Kp1U80vD.jpg',
width: 1024, width: 1024,
height: 682, height: 682,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2876_5cSPMiKL.jpg', url: '/photo/122A2876_5cSPMiKL.jpg',
width: 6720, width: 6720,
height: 4480, height: 4480,
}, },
@ -32,13 +32,13 @@ export const timelineData: myTimeline_myTimeline[] = [
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_pwjtMkpy.jpg', url: '/photo/thumbnail_122A2630-Edit_jpg_pwjtMkpy.jpg',
width: 1024, width: 1024,
height: 682, height: 682,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2630-Edit_ySQWFAgE.jpg', url: '/photo/122A2630-Edit_ySQWFAgE.jpg',
width: 6177, width: 6177,
height: 4118, height: 4118,
}, },
@ -55,13 +55,13 @@ export const timelineData: myTimeline_myTimeline[] = [
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2785-2_jpg_CevmxEXf.jpg', url: '/photo/thumbnail_122A2785-2_jpg_CevmxEXf.jpg',
width: 1024, width: 1024,
height: 1024, height: 1024,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2785-2_mCnWjLdb.jpg', url: '/photo/122A2785-2_mCnWjLdb.jpg',
width: 884, width: 884,
height: 884, height: 884,
}, },
@ -78,13 +78,13 @@ export const timelineData: myTimeline_myTimeline[] = [
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_aJPCSDDl.jpg', url: '/photo/thumbnail_122A2630-Edit_jpg_aJPCSDDl.jpg',
width: 1024, width: 1024,
height: 682, height: 682,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2630-Edit_em9g89qg.jpg', url: '/photo/122A2630-Edit_em9g89qg.jpg',
width: 6177, width: 6177,
height: 4118, height: 4118,
}, },
@ -101,13 +101,13 @@ export const timelineData: myTimeline_myTimeline[] = [
type: MediaType.Photo, type: MediaType.Photo,
thumbnail: { thumbnail: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/thumbnail_122A2559_jpg_MsOJtPi8.jpg', url: '/photo/thumbnail_122A2559_jpg_MsOJtPi8.jpg',
width: 1024, width: 1024,
height: 712, height: 712,
}, },
highRes: { highRes: {
__typename: 'MediaURL', __typename: 'MediaURL',
url: 'http://localhost:4001/photo/122A2559_FDsQHuBN.jpg', url: '/photo/122A2559_FDsQHuBN.jpg',
width: 6246, width: 6246,
height: 4346, height: 4346,
}, },