-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Add Mobile Live status test written by elreydetoda
- Loading branch information
1 parent
b244af0
commit d36770f
Showing
5 changed files
with
301 additions
and
25 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
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
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
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,92 @@ | ||
from pathlib import Path | ||
from typing import Tuple, Callable | ||
from playwright.sync_api import Page, expect, Locator, FrameLocator | ||
|
||
|
||
def test_live_indicator( | ||
page: Page, | ||
set_live: Tuple[Callable, str] | ||
): | ||
# explicitly defining tuple objects for clarity | ||
replace_live_event: Callable = set_live[0] | ||
live_event: str = set_live[1] | ||
|
||
# intercepting reponses for live event, and make live | ||
replace_live_event(page, live_event) | ||
|
||
# go to the live page | ||
page.goto("/live") | ||
|
||
# validate live button is red | ||
expect(page.locator("#mainnavigation.is-live").locator("#livebutton")).to_have_css( | ||
name="background-color", | ||
value="rgb(255, 0, 0)", # red | ||
) | ||
|
||
# waiting for peertube iframe to load | ||
jbtube_video: FrameLocator = page.frame_locator("#liveStream") | ||
video_player_peertube_icon: Locator = jbtube_video.locator(".peertube-dock-avatar") | ||
expect(video_player_peertube_icon).to_be_visible() | ||
|
||
page.evaluate("window.scrollTo(0, 0)") | ||
|
||
|
||
def test_mobile_live_indicator( | ||
mobile_device_tuple: Tuple[Page, str], | ||
set_live: Tuple[Callable, str], | ||
screenshot_dir: Path, | ||
): | ||
# explicitly defining tuple objects for clarity | ||
replace_live_event: Callable = set_live[0] | ||
live_event: str = set_live[1] | ||
|
||
# set mobile page to variable | ||
mobile_device = mobile_device_tuple[0] | ||
|
||
# intercepting reponses for live event, and make live | ||
replace_live_event(mobile_device, live_event) | ||
|
||
mobile_device.goto("/live") | ||
|
||
navbar: Locator = mobile_device.locator("#mainnavigation.is-live",).locator( | ||
".navbar-burger", | ||
) | ||
|
||
# wait for navbar to be visible | ||
expect(navbar).to_be_visible() | ||
|
||
# check if live indicator is red | ||
assert ( | ||
navbar.evaluate( | ||
# integrated docs for python evaluate function: | ||
# https://github.com/microsoft/playwright/blob/a30aac56687598c373c51255308ef5833de0c9bb/docs/src/api/class-jshandle.md?plain=1#L77-L80 | ||
# use evaluate function in python: https://playwright.dev/python/docs/api/class-page#page-evaluate | ||
# use getComputerStyle w/playwright: https://stackoverflow.com/a/71433333 | ||
"element => window.getComputedStyle(element, ':before').backgroundColor" | ||
) | ||
== "rgb(255, 0, 0)" | ||
) | ||
|
||
# waiting for peertube iframe to load | ||
jbtube_video: FrameLocator = mobile_device.frame_locator("#liveStream") | ||
video_player_peertube_icon: Locator = jbtube_video.locator(".peertube-dock-avatar") | ||
expect(video_player_peertube_icon).to_be_visible() | ||
|
||
mobile_device.evaluate("window.scrollTo(0, 0)") | ||
|
||
# click navbar to expand | ||
navbar.click() | ||
|
||
# repeat test_live_indicator for mobile device | ||
expect( | ||
mobile_device.locator("#mainnavigation.is-live",).locator( | ||
"#livebutton", | ||
), | ||
).to_have_css( | ||
name="background-color", | ||
value="rgb(255, 0, 0)", # red | ||
) | ||
|
||
mobile_device.locator("#mainnavigation").locator( | ||
".navbar-menu.is-active" | ||
).screenshot(path=f"{screenshot_dir}/live-mobile_navbar.png") |
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,98 @@ | ||
{ | ||
"total": 1, | ||
"data": [ | ||
{ | ||
"id": 50, | ||
"uuid": "55b2e9d1-ccf3-4914-9f3f-c5d8a59bd4c1", | ||
"shortUUID": "bzMpxgG2rDKn9C99GSab92", | ||
"url": "https://jupiter.tube/videos/watch/55b2e9d1-ccf3-4914-9f3f-c5d8a59bd4c1", | ||
"name": "LINUX Unplugged 471 - We Broke Our Server", | ||
"category": { | ||
"id": 15, | ||
"label": "Science & Technology" | ||
}, | ||
"licence": { | ||
"id": 5, | ||
"label": "Attribution - Non Commercial - Share Alike" | ||
}, | ||
"language": { | ||
"id": "en", | ||
"label": "English" | ||
}, | ||
"privacy": { | ||
"id": 1, | ||
"label": "Public" | ||
}, | ||
"nsfw": false, | ||
"description": "We broke our server, so lets see if we can fix it live before the show is over!", | ||
"isLocal": true, | ||
"duration": 0, | ||
"views": 0, | ||
"viewers": 19, | ||
"likes": 0, | ||
"dislikes": 0, | ||
"thumbnailPath": "/static/thumbnails/b610e5f5-bbb5-4ee1-ac24-421c50f0daf5.jpg", | ||
"previewPath": "/lazy-static/previews/fcd582d8-68c5-4f00-8a4a-0a8ffde1a4a5.jpg", | ||
"embedPath": "/videos/embed/55b2e9d1-ccf3-4914-9f3f-c5d8a59bd4c1", | ||
"createdAt": "2022-08-14T16:26:27.938Z", | ||
"updatedAt": "2022-08-14T18:53:15.544Z", | ||
"publishedAt": "2022-08-14T18:53:15.543Z", | ||
"originallyPublishedAt": null, | ||
"isLive": true, | ||
"account": { | ||
"id": 3, | ||
"displayName": "JBLive Stream", | ||
"name": "jblive", | ||
"url": "https://jupiter.tube/accounts/jblive", | ||
"host": "jupiter.tube", | ||
"avatars": [ | ||
{ | ||
"width": 48, | ||
"path": "/lazy-static/avatars/e4d17e7f-a144-4a4a-b5d8-b297b06b727f.png", | ||
"createdAt": "2022-06-07T23:43:56.565Z", | ||
"updatedAt": "2022-06-07T23:43:56.565Z" | ||
}, | ||
{ | ||
"width": 120, | ||
"path": "/lazy-static/avatars/1340f3e9-d0a7-4bc4-bcbd-a8c865eaf1b8.png", | ||
"createdAt": "2022-05-30T20:36:19.005Z", | ||
"updatedAt": "2022-05-30T20:36:19.005Z" | ||
} | ||
], | ||
"avatar": { | ||
"width": 48, | ||
"path": "/lazy-static/avatars/e4d17e7f-a144-4a4a-b5d8-b297b06b727f.png", | ||
"createdAt": "2022-06-07T23:43:56.565Z", | ||
"updatedAt": "2022-06-07T23:43:56.565Z" | ||
} | ||
}, | ||
"channel": { | ||
"id": 2, | ||
"name": "live", | ||
"displayName": "live", | ||
"url": "https://jupiter.tube/video-channels/live", | ||
"host": "jupiter.tube", | ||
"avatars": [ | ||
{ | ||
"width": 48, | ||
"path": "/lazy-static/avatars/8acfd2a2-ab4e-48aa-990c-3156a2765d2e.png", | ||
"createdAt": "2022-06-07T23:43:56.607Z", | ||
"updatedAt": "2022-06-07T23:43:56.607Z" | ||
}, | ||
{ | ||
"width": 120, | ||
"path": "/lazy-static/avatars/e9bcfdb7-90a2-479c-b1da-1ab0e5fc9442.png", | ||
"createdAt": "2022-05-30T20:38:33.632Z", | ||
"updatedAt": "2022-05-30T20:38:33.632Z" | ||
} | ||
], | ||
"avatar": { | ||
"width": 48, | ||
"path": "/lazy-static/avatars/8acfd2a2-ab4e-48aa-990c-3156a2765d2e.png", | ||
"createdAt": "2022-06-07T23:43:56.607Z", | ||
"updatedAt": "2022-06-07T23:43:56.607Z" | ||
} | ||
} | ||
} | ||
] | ||
} |