-
Notifications
You must be signed in to change notification settings - Fork 183
**suggestion (testing):** Add tests around the new warningMessage / shouldSkipYouTubeDataApi behavior. #448
Copy link
Copy link
Open
Description
suggestion (testing): Add tests around the new warningMessage / shouldSkipYouTubeDataApi behavior.
These helpers now change runtime behavior locally / under file:// (warning banner, skipping YouTube Data API, disabling search/autocomplete), but none of the tests assert this.
Please add coverage for at least:
- When
shouldSkipYouTubeDataApi()is true (as in the current Playwright setup),.warning-messageis rendered with the expected text. - Search/autocomplete in this mode:
typeaheadis not attached to.search-input, and search still supports direct video ID/URL playback.
You can either extend this Form suite or add a small e2e suite that:
- Waits for
.warning-messageand asserts its text. - Verifies autocomplete is disabled (e.g.,
window.getAutocompleteSuggestionsis not called or typeahead-specific DOM is absent on.search-input).
Suggested implementation:
await page.goto(indexHTMLURL);
// Test that warning message is rendered when YouTube Data API is skipped
const warningElement = await page.waitForSelector(".warning-message", { state: "visible" });
const warningText = await warningElement.textContent();
assert.ok(
warningText && warningText.toLowerCase().includes("youtube data api"),
`Warning text should mention YouTube Data API, got: "${warningText}"`
);
// Test that error element exists and can be controlled
const errorElement = await page.$(".error-message");
assert.ok(errorElement, "Error element should exist");
// Verify that autocomplete/typeahead is disabled when skipping YouTube Data API
const searchInput = await page.$(".search-input");
assert.ok(searchInput, "Search input should exist");
// Common typeahead.js DOM hooks: no menu / hint inputs should be present
const typeaheadMenu = await page.$(".tt-menu");
assert.strictEqual(
typeaheadMenu,
null,
"Typeahead menu (.tt-menu) should not be present when YouTube Data API is skipped"
);
const typeaheadHint = await page.$(".tt-hint");
assert.strictEqual(
typeaheadHint,
null,
"Typeahead hint input (.tt-hint) should not be present when YouTube Data API is skipped"
);
// Verify that direct video ID / URL playback still works without autocomplete
const directVideoId = "dQw4w9WgXcQ";
await searchInput.fill(directVideoId);
await searchInput.press("Enter");
const playerFrame = await page.waitForSelector(
'iframe[src*="youtube.com"], iframe[src*="youtube-nocookie.com"]',
{ timeout: 10000 }
);
assert.ok(playerFrame, "Player iframe should be rendered for direct video ID search");
// Test that we can programmatically show/hide the error- If your actual warning copy differs, replace the
includes("youtube data api")check with a stricter assertion on the exact expected string. - If your autocomplete implementation uses different DOM markers than
.tt-menu/.tt-hint, update those selectors to match the actual typeahead-specific elements added in the non-shouldSkipYouTubeDataApipath. - If the search interaction in this form uses a different trigger than pressing Enter on
.search-input(e.g., clicking a search button or submitting a specific form), adjust thefill/presslogic accordingly to follow the existing tests intest/form.js. - If the player is rendered with a non-iframe container or a different selector than a YouTube iframe, update the
waitForSelectorto use the actual player element/selector used elsewhere in your e2e tests.
Originally posted by @sourcery-ai[bot] in #447 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels