-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add maestro tests and unit tests
- Loading branch information
1 parent
c1df3cd
commit 1a877e5
Showing
64 changed files
with
549 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,60 @@ | ||
import Movie from 'app/movie/[id]'; | ||
|
||
import { MOCK_LOGO, MOCK_LOGO_EMPTY } from 'api/__mocks__/logo'; | ||
import { MOCK_MOVIE, MOCK_MOVIE_WITH_NETWORK } from 'api/__mocks__/movie'; | ||
|
||
import * as logo from '../src/api/logo'; | ||
import * as movie from '../src/api/movie'; | ||
import { mockQuery, render, screen } from '../tests/render'; | ||
|
||
describe('<Movie />', () => { | ||
test('should render correctly', () => { | ||
jest.spyOn(movie, 'useGetMovie').mockReturnValue(mockQuery(MOCK_MOVIE)); | ||
jest.spyOn(logo, 'useGetContentLogo').mockReturnValue(mockQuery(MOCK_LOGO)); | ||
|
||
render(<Movie />); | ||
|
||
const releaseDate = screen.getByTestId('release-date'); | ||
expect(releaseDate).toHaveTextContent('November 16, 2001'); | ||
|
||
const runtime = screen.getByTestId('runtime'); | ||
expect(runtime).toHaveTextContent('2h32m'); | ||
|
||
const votes = screen.getByTestId('votes'); | ||
expect(votes).toHaveTextContent('7.9 (26908)'); | ||
|
||
const network = screen.queryByTestId('network-1234'); | ||
expect(network).toBeFalsy(); | ||
expect(screen.getByTestId('release-date')).toHaveTextContent( | ||
'November 16, 2001' | ||
); | ||
expect(screen.getByTestId('runtime')).toHaveTextContent('2h32m'); | ||
expect(screen.getByTestId('votes')).toHaveTextContent('7.9 (26908)'); | ||
expect(screen.queryByTestId('network-1234')).toBeFalsy(); | ||
expect(screen.queryByTestId('subtitle')).toHaveTextContent( | ||
'Adventure - Fantasy' | ||
); | ||
expect(screen.queryByTestId('cover-title')).toBeFalsy(); | ||
expect(screen.queryByTestId('cover-image')).toHaveProp('source', { | ||
uri: 'https://image.tmdb.org/t/p/w780/hziiv14OpD73u9gAak4XDDfBKa2.jpg' | ||
}); | ||
expect(screen.queryByTestId('cover-logo')).toHaveProp( | ||
'src', | ||
'https://image.tmdb.org/t/p/w500url-logo.png' | ||
); | ||
}); | ||
|
||
test('should render correctly with network', () => { | ||
jest | ||
.spyOn(movie, 'useGetMovie') | ||
.mockReturnValue(mockQuery(MOCK_MOVIE_WITH_NETWORK)); | ||
jest.spyOn(logo, 'useGetContentLogo').mockReturnValue(mockQuery(MOCK_LOGO)); | ||
|
||
render(<Movie />); | ||
|
||
expect(screen.getByTestId('network-213')).toBeTruthy(); | ||
}); | ||
|
||
test('should render correctly without logo', () => { | ||
jest.spyOn(movie, 'useGetMovie').mockReturnValue(mockQuery(MOCK_MOVIE)); | ||
jest | ||
.spyOn(logo, 'useGetContentLogo') | ||
.mockReturnValue(mockQuery(MOCK_LOGO_EMPTY)); | ||
|
||
render(<Movie />); | ||
|
||
const network = screen.queryByTestId('network-213'); | ||
expect(network).toBeTruthy(); | ||
expect(screen.queryByTestId('cover-title')).toHaveTextContent( | ||
"Harry Potter and the Philosopher's Stone" | ||
); | ||
expect(screen.queryByTestId('cover-logo')).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Person from 'app/person/[id]'; | ||
|
||
import { | ||
MOCK_PERSON, | ||
MOCK_PERSON_MOVIES, | ||
MOCK_PERSON_TV | ||
} from 'api/__mocks__/person'; | ||
|
||
import * as person from '../src/api/person'; | ||
import { mockQuery, render, screen } from '../tests/render'; | ||
|
||
describe('<Person />', () => { | ||
test('should render correctly', () => { | ||
jest.spyOn(person, 'useGetPerson').mockReturnValue(mockQuery(MOCK_PERSON)); | ||
jest | ||
.spyOn(person, 'useGetPersonMovieCredits') | ||
.mockReturnValue(mockQuery(MOCK_PERSON_MOVIES)); | ||
jest | ||
.spyOn(person, 'useGetPersonTvCredits') | ||
.mockReturnValue(mockQuery(MOCK_PERSON_TV)); | ||
|
||
render(<Person />); | ||
|
||
expect(screen.getByTestId('department')).toHaveTextContent('Acting'); | ||
expect(screen.getByTestId('birthday')).toHaveTextContent( | ||
'Born on July 23, 1989 (35y)' | ||
); | ||
expect(screen.getByTestId('place-of-birth')).toHaveTextContent( | ||
'Hammersmith, London, England, UK' | ||
); | ||
expect(screen.getByTestId('movies')).toHaveTextContent('1 movie'); | ||
expect(screen.getByTestId('series')).toHaveTextContent('1 serie'); | ||
expect(screen.queryByTestId('cover-title')).toHaveTextContent( | ||
'Daniel Radcliffe' | ||
); | ||
expect(screen.queryByTestId('cover-image')).toHaveProp('source', { | ||
uri: 'https://image.tmdb.org/t/p/w780/iPg0J9UzAlPj1fLEJNllpW9IhGe.jpg' | ||
}); | ||
}); | ||
|
||
test('should render correctly with deathday', () => { | ||
jest | ||
.spyOn(person, 'useGetPerson') | ||
.mockReturnValue(mockQuery({ ...MOCK_PERSON, deathday: '2024-07-23' })); | ||
|
||
render(<Person />); | ||
|
||
expect(screen.getByTestId('birthday')).toHaveTextContent( | ||
'Born on July 23, 1989' | ||
); | ||
expect(screen.getByTestId('deathday')).toHaveTextContent( | ||
'Died on July 23, 2024 (35y)' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import Tv from 'app/tv/[id]'; | ||
|
||
import { MOCK_LOGO, MOCK_LOGO_EMPTY } from 'api/__mocks__/logo'; | ||
import { MOCK_TV, MOCK_TV_WITH_NETWORK } from 'api/__mocks__/tv'; | ||
|
||
import * as logo from '../src/api/logo'; | ||
import * as tv from '../src/api/tv'; | ||
import { mockQuery, render, screen } from '../tests/render'; | ||
|
||
describe('<Tv />', () => { | ||
test('should render correctly', () => { | ||
jest.spyOn(tv, 'useGetTv').mockReturnValue(mockQuery(MOCK_TV)); | ||
jest.spyOn(logo, 'useGetContentLogo').mockReturnValue(mockQuery(MOCK_LOGO)); | ||
|
||
render(<Tv />); | ||
|
||
expect(screen.getByTestId('release-date')).toHaveTextContent('2022 - 2024'); | ||
expect(screen.getByTestId('runtime')).toHaveTextContent('1h8m'); | ||
expect(screen.getByTestId('votes')).toHaveTextContent('8.4 (4773)'); | ||
expect(screen.queryByTestId('network-1234')).toBeFalsy(); | ||
expect(screen.queryByTestId('subtitle')).toHaveTextContent( | ||
'Sci-Fi & Fantasy - Drama' | ||
); | ||
expect(screen.queryByTestId('cover-title')).toBeFalsy(); | ||
expect(screen.queryByTestId('cover-image')).toHaveProp('source', { | ||
uri: 'https://image.tmdb.org/t/p/w780/etj8E2o0Bud0HkONVQPjyCkIvpv.jpg' | ||
}); | ||
expect(screen.queryByTestId('cover-logo')).toHaveProp( | ||
'src', | ||
'https://image.tmdb.org/t/p/w500url-logo.png' | ||
); | ||
}); | ||
|
||
test('should render correctly with network', () => { | ||
jest.spyOn(tv, 'useGetTv').mockReturnValue(mockQuery(MOCK_TV_WITH_NETWORK)); | ||
jest.spyOn(logo, 'useGetContentLogo').mockReturnValue(mockQuery(MOCK_LOGO)); | ||
|
||
render(<Tv />); | ||
|
||
expect(screen.getByTestId('network-49')).toBeTruthy(); | ||
}); | ||
|
||
test('should render correctly without logo', () => { | ||
jest.spyOn(tv, 'useGetTv').mockReturnValue(mockQuery(MOCK_TV)); | ||
jest | ||
.spyOn(logo, 'useGetContentLogo') | ||
.mockReturnValue(mockQuery(MOCK_LOGO_EMPTY)); | ||
|
||
render(<Tv />); | ||
|
||
expect(screen.queryByTestId('cover-title')).toHaveTextContent( | ||
'House of the Dragon' | ||
); | ||
expect(screen.queryByTestId('cover-logo')).toBeFalsy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- waitForAnimationToEnd | ||
- takeScreenshot: 'maestro/screenshots/discover/index' | ||
- tapOn: 'Discover' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
point: '14%,79%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/discover/index-2' | ||
- tapOn: '1' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
point: '18%,52%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: 'Action Action' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/discover/index-3' | ||
- tapOn: | ||
point: '33%,28%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: '1' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
point: '18%,84%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/discover/index-4' | ||
- tapOn: 'Action & Adventure Action & Adventure' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/discover/index-5' | ||
- tapOn: | ||
point: '33%,48%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
point: '18%,78%' | ||
- tapOn: | ||
id: 'header-back-button' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- scroll | ||
- scroll | ||
- tapOn: 'Action Action' | ||
- takeScreenshot: 'maestro/screenshots/genre/movie' | ||
- tapOn: | ||
point: '50%,31%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/genre/movie-2' | ||
- tapOn: | ||
point: '19%,26%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- scroll | ||
- tapOn: 'Action & Adventure Action & Adventure' | ||
- takeScreenshot: 'maestro/screenshots/genre/tv' | ||
- tapOn: | ||
point: '50%,31%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/genre/tv-2' | ||
- tapOn: | ||
point: '19%,26%' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
id: 'header-back-button' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- tapOn: 'Streaming, tab, 3 of 3' | ||
- waitForAnimationToEnd | ||
- takeScreenshot: 'maestro/screenshots/network/streaming' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/network/streaming-2' | ||
- tapOn: | ||
point: '18%,78%' | ||
- takeScreenshot: 'maestro/screenshots/network/index' | ||
- tapOn: | ||
point: '50%,31%' | ||
- assertVisible: '2 seasons' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/network/index-2' | ||
- tapOn: | ||
point: '50%,28%' | ||
- assertVisible: '7 seasons' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- tapOn: 'Search, tab, 2 of 3' | ||
- tapOn: 'What would you like to watch?' | ||
- inputText: 'Daniel Radcliffe' | ||
- doubleTapOn: | ||
point: '19%,38%' | ||
- waitForAnimationToEnd | ||
- takeScreenshot: 'maestro/screenshots/person/index' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/person/index-2' | ||
- tapOn: | ||
point: '25%,42%' | ||
- takeScreenshot: 'maestro/screenshots/person/know-for' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
id: 'credits-movie' | ||
- takeScreenshot: 'maestro/screenshots/person/movies' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
id: 'credits-tv' | ||
- takeScreenshot: 'maestro/screenshots/person/series' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- tapOn: | ||
point: '18%,85%' | ||
- swipe: | ||
direction: LEFT | ||
- takeScreenshot: 'maestro/screenshots/person/pictures' | ||
- tapOn: | ||
id: 'header-close-button' | ||
- assertVisible: 'Pictures' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
appId: com.theomesnil.WhatToWatch | ||
--- | ||
- launchApp | ||
- tapOn: 'Search, tab, 2 of 3' | ||
- tapOn: 'What would you like to watch?' | ||
- inputText: 'House of the Dragon' | ||
- doubleTapOn: | ||
point: '19%,38%' | ||
- waitForAnimationToEnd | ||
- takeScreenshot: 'maestro/screenshots/tv/index' | ||
- assertVisible: 'Watch on' | ||
- tapOn: 'Watch the trailer' | ||
- assertVisible: | ||
id: 'video' | ||
- takeScreenshot: 'maestro/screenshots/tv/trailer' | ||
- tapOn: | ||
id: 'header-close-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/tv/index-2' | ||
- tapOn: 'S2' | ||
- takeScreenshot: 'maestro/screenshots/tv/index-3' | ||
- scroll | ||
- scroll | ||
- waitForAnimationToEnd | ||
- takeScreenshot: 'maestro/screenshots/tv/index-4' | ||
- tapOn: 'Matt Smith Prince Daemon Targaryen' | ||
- takeScreenshot: 'maestro/screenshots/tv/casting' | ||
- tapOn: | ||
id: 'header-back-button' | ||
- scroll | ||
- takeScreenshot: 'maestro/screenshots/tv/index-5' | ||
- tapOn: 'House of the Dragon Opening Credits 4K | Season 1 (HBO) | Game Of Thrones Extras' | ||
- takeScreenshot: 'maestro/screenshots/tv/video' | ||
- tapOn: | ||
id: 'header-close-button' | ||
- tapOn: 'Backdrops' | ||
- swipe: | ||
direction: LEFT | ||
- takeScreenshot: 'maestro/screenshots/tv/backdrops' | ||
- tapOn: | ||
id: 'header-close-button' | ||
- tapOn: 'Posters' | ||
- swipe: | ||
direction: LEFT | ||
- takeScreenshot: 'maestro/screenshots/tv/posters' | ||
- tapOn: | ||
id: 'header-close-button' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { UseGetContentLogo } from 'api/logo'; | ||
|
||
export const MOCK_LOGO: UseGetContentLogo['data'] = { | ||
url: 'url-logo.png', | ||
aspectRatio: 245 / 234 | ||
}; | ||
|
||
export const MOCK_LOGO_EMPTY: UseGetContentLogo['data'] = null; |
Oops, something went wrong.