Skip to content

Instantly share code, notes, and snippets.

@joakin
Created April 22, 2016 12:00
Show Gist options
  • Save joakin/88f2e1aaff2f354746de6445095576e5 to your computer and use it in GitHub Desktop.
Save joakin/88f2e1aaff2f354746de6445095576e5 to your computer and use it in GitHub Desktop.
Testing recording mobile content service
mobileapps (record-http-sepia) $ VCR_MODE=record npm test
> [email protected] test /Users/jhernandez/dev/wikimedia/mobileapps
> mocha
express app
server options changed; restarting
✓ should get robots.txt (44ms)
✓ should set CORS headers
✓ should set CSP headers
✓ should get static content uncompressed
Swagger spec
✓ get the spec
✓ spec validation
routes
✓ spec from root
✓ retrieve service info
✓ retrieve images and videos of en.wp Cat page via media route (1205ms)
✓ retrieve en-wiktionary definitions for 'cat' (772ms)
✓ retrieve en.wp main page via mobile-sections (746ms)
✓ retrieve lead section of en.wp main page via mobile-sections-lead (752ms)
✓ retrieve lead section of en.wp San Francisco page via mobile-sections-lead (1060ms)
✓ retrieve lead section of en.wp Barack Obama page via mobile-sections-lead (1308ms)
✓ retrieve remaining sections of en.wp main page via mobile-sections-remaining (504ms)
✓ retrieve page preview of Dog page (791ms)
✓ retrieve the lite en.wp main page (405ms)
definition
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (763ms)
✓ en 'cat' request should have expected structure and content (772ms)
✓ missing definitions (513ms)
✓ non-term page (809ms)
✓ unsupported language
✓ non-English term on English Wiktionary returns valid results (356ms)
✓ translingual term (346ms)
service information
✓ should get the service name
✓ should get the service version
✓ should redirect to the service home page
✓ should get the service info
media
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (515ms)
✓ return the sent ETag (532ms)
✓ Sections/deep page should have no media items (348ms)
✓ en Main page should have at least one image (598ms)
✓ Obama (redirect) should have a lead image, expected properties, and many media items (1614ms)
✓ Missing title should respond with 404 (840ms)
mobile-sections
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (370ms)
✓ return the sent ETag (358ms)
✓ Sections/deep page should have a lead object with expected properties (327ms)
✓ en Main page should have a lead object with expected properties (705ms)
✓ Obama (redirect) should have a lead image, description, redirected, and remaining sections (1609ms)
✓ Missing title should respond with 404 (260ms)
✓ Page with known past 'text-decoration' error should load successfully (577ms)
✓ Beta cluster request should load successfully (749ms)
✓ Page with irregular Spoken Wikipedia template usage should load correctly (449ms)
✓ Page with HTML entity in redirected page title should load (658ms)
✓ Page with % in redirected page title should load (494ms)
✓ Page with % in redirected page title should load 2 (737ms)
✓ Page with % in section header of redirected page title should load (882ms)
mobile-sections-lead
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (381ms)
✓ Sections/deep page should have a lead object with expected properties (333ms)
✓ en Cat page should have a lead object with expected properties (902ms)
✓ en San Francisco should have a lead object with a geo property (1053ms)
✓ Obama (redirect) should have a lead image (1541ms)
✓ Barack Obama should have a pronunciation (1399ms)
✓ Enwiki Uranus loads successfully (no pronunciation parsing TypeErrors) (839ms)
✓ Enwiki Odisha loads successfully (no pronunciation parsing TypeErrors) (755ms)
✓ Enwiki Lead_paragraph_move has the infobox moved after the lead paragraph (364ms)
pickPronunciationFilePageUrl
✓ spaces in title should not effect choice
✓ subset of filename should not effect choice
mobile-sections-remaining
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (362ms)
✓ Obama (redirect) should have at least one video, and many images (1526ms)
mobile-summary
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (332ms)
✓ Page should have expected properties (409ms)
mobile-text
✓ should respond to GET request with expected headers, incl. CORS and CSP headers (326ms)
✓ should have the right meta fields in the JSON response (542ms)
✓ should have the right structure of section objects (344ms)
✓ should have the right structure of paragraph, image, and video objects (278ms)
jshint
✓ should pass for working directory (453ms)
lib:anchorencode
✓ anchorencode(empty) should return an empty string
✓ anchorencode("a") should return a
✓ anchorencode("Z") should return Z
✓ anchorencode(" Z ") should return Z
✓ anchorencode("a b c") should return a_b_c
✓ anchorencode("a b c") should return a_b_c
✓ anchorencode("!@#$%^&*()") should return 21.40.23.24.25.5E.26.2A.28.29
✓ anchorencode(":") should not be converted
lib:mwapi:image
✓ buildLeadImageUrls("a") should return all "a"s
✓ buildLeadImageUrls with size 1024px
✓ buildLeadImageUrls with size 555px should return size 320 for 320 and then 555 for rest
✓ buildLeadImageUrls with size 750px should return size 320, 640, and then 750 for rest
✓ buildLeadImageUrls with size 200px should return size 200 for all URLs
lib:parsoid
✓ getSectionsText(empty) should produce an empty lead section
✓ getSectionsText() with just text should produce a lead section
✓ getSectionsText() with one h2 should produce two sections
✓ getSectionsText() with one h2 and h3 should produce three sections
✓ _hasRedirectInPayload() with redirect in body should return a redirect
✓ _hasRedirectInPayload() without redirect in body should not return a redirect
✓ _getRedirectTitleFromPayload(): HTML entities in redirected title should be decoded
✓ _getRedirectTitleFromPayload(): %25 in redirected title should be decoded
✓ _getRedirectTitleFromLocationHeader() with redirect
lib:transforms
✓ rmBracketSpans should remove the spans around brackets
✓ rmElementsWithSelectors should remove the spans with display:none
91 passing (36s)
mobileapps (record-http-sepia %) $ VCR_MODE=playback npm test
> [email protected] test /Users/jhernandez/dev/wikimedia/mobileapps
> mocha
express app
server options changed; restarting
✓ should get robots.txt
✓ should set CORS headers
✓ should set CSP headers
✓ should get static content uncompressed
Swagger spec
✓ get the spec
✓ spec validation
routes
✓ spec from root
✓ retrieve service info
✓ retrieve images and videos of en.wp Cat page via media route
✓ retrieve en-wiktionary definitions for 'cat'
✓ retrieve en.wp main page via mobile-sections
✓ retrieve lead section of en.wp main page via mobile-sections-lead
✓ retrieve lead section of en.wp San Francisco page via mobile-sections-lead
✓ retrieve lead section of en.wp Barack Obama page via mobile-sections-lead
✓ retrieve remaining sections of en.wp main page via mobile-sections-remaining
✓ retrieve page preview of Dog page
✓ retrieve the lite en.wp main page
definition
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ en 'cat' request should have expected structure and content
✓ missing definitions
✓ non-term page
✓ unsupported language
✓ non-English term on English Wiktionary returns valid results
✓ translingual term
service information
✓ should get the service name
✓ should get the service version
✓ should redirect to the service home page
✓ should get the service info
media
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ return the sent ETag
✓ Sections/deep page should have no media items
✓ en Main page should have at least one image
✓ Obama (redirect) should have a lead image, expected properties, and many media items
✓ Missing title should respond with 404
mobile-sections
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ return the sent ETag
✓ Sections/deep page should have a lead object with expected properties
✓ en Main page should have a lead object with expected properties
✓ Obama (redirect) should have a lead image, description, redirected, and remaining sections
✓ Missing title should respond with 404
✓ Page with known past 'text-decoration' error should load successfully
✓ Beta cluster request should load successfully
✓ Page with irregular Spoken Wikipedia template usage should load correctly
✓ Page with HTML entity in redirected page title should load
✓ Page with % in redirected page title should load
✓ Page with % in redirected page title should load 2
✓ Page with % in section header of redirected page title should load
mobile-sections-lead
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ Sections/deep page should have a lead object with expected properties
✓ en Cat page should have a lead object with expected properties
✓ en San Francisco should have a lead object with a geo property
✓ Obama (redirect) should have a lead image
✓ Barack Obama should have a pronunciation
✓ Enwiki Uranus loads successfully (no pronunciation parsing TypeErrors)
✓ Enwiki Odisha loads successfully (no pronunciation parsing TypeErrors)
✓ Enwiki Lead_paragraph_move has the infobox moved after the lead paragraph
pickPronunciationFilePageUrl
✓ spaces in title should not effect choice
✓ subset of filename should not effect choice
mobile-sections-remaining
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ Obama (redirect) should have at least one video, and many images
mobile-summary
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ Page should have expected properties
mobile-text
✓ should respond to GET request with expected headers, incl. CORS and CSP headers
✓ should have the right meta fields in the JSON response
✓ should have the right structure of section objects
✓ should have the right structure of paragraph, image, and video objects
jshint
✓ should pass for working directory (465ms)
lib:anchorencode
✓ anchorencode(empty) should return an empty string
✓ anchorencode("a") should return a
✓ anchorencode("Z") should return Z
✓ anchorencode(" Z ") should return Z
✓ anchorencode("a b c") should return a_b_c
✓ anchorencode("a b c") should return a_b_c
✓ anchorencode("!@#$%^&*()") should return 21.40.23.24.25.5E.26.2A.28.29
✓ anchorencode(":") should not be converted
lib:mwapi:image
✓ buildLeadImageUrls("a") should return all "a"s
✓ buildLeadImageUrls with size 1024px
✓ buildLeadImageUrls with size 555px should return size 320 for 320 and then 555 for rest
✓ buildLeadImageUrls with size 750px should return size 320, 640, and then 750 for rest
✓ buildLeadImageUrls with size 200px should return size 200 for all URLs
lib:parsoid
✓ getSectionsText(empty) should produce an empty lead section
✓ getSectionsText() with just text should produce a lead section
✓ getSectionsText() with one h2 should produce two sections
✓ getSectionsText() with one h2 and h3 should produce three sections
✓ _hasRedirectInPayload() with redirect in body should return a redirect
✓ _hasRedirectInPayload() without redirect in body should not return a redirect
✓ _getRedirectTitleFromPayload(): HTML entities in redirected title should be decoded
✓ _getRedirectTitleFromPayload(): %25 in redirected title should be decoded
✓ _getRedirectTitleFromLocationHeader() with redirect
lib:transforms
✓ rmBracketSpans should remove the spans around brackets
✓ rmElementsWithSelectors should remove the spans with display:none
91 passing (783ms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment