Skip to content

Commit

Permalink
Merge branch 'main' of github.com:wikimedia/pixel into thanks
Browse files Browse the repository at this point in the history
  • Loading branch information
jdlrobson committed Jul 27, 2023
2 parents d833af1 + 37c482c commit 77e52c6
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 31 deletions.
4 changes: 0 additions & 4 deletions configDesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ const tests = [
label: 'Search in header (#vector-2022, #search-focus)',
path: '/wiki/Test'
},
{
label: 'Search loading in header (#vector-2022, #search-focus, #search-offline)',
path: '/wiki/Test'
},
{
label: 'Search in sticky header (#logged-in, #vector-2022, #scroll, #search-sticky, #search-focus)',
path: '/wiki/Test',
Expand Down
64 changes: 64 additions & 0 deletions configLogin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const utils = require( './utils' );

const {
VIEWPORT_PHONE,
VIEWPORT_TABLET,
VIEWPORT_DESKTOP,
VIEWPORT_DESKTOP_WIDE,
VIEWPORT_DESKTOP_WIDEST
} = require( './viewports' );

const scenarios = utils.makeScenariosForSkins( [
{
label: 'Login',
path: '/wiki/Special:UserLogin',
hashtags: [],
selectors: [ 'viewport' ]
},
{
label: 'Create account',
path: '/wiki/Special:CreateAccount',
hashtags: [],
selectors: [ 'viewport' ]
},
{
label: 'login when logged in',
hashtags: [ 'logged-in' ],
path: '/wiki/Special:UserLogin',
selectors: [ 'viewport' ]
},
{
label: 'create account when logged in',
hashtags: [ 'logged-in' ],
path: '/wiki/Special:CreateAccount',
selectors: [ 'viewport' ]
}
], [ 'vector-2022', 'vector', 'minerva' ] ).map( ( s ) => Object.assign( {}, s, {
misMatchThreshold: 0.05
} ) );

module.exports = {
id: 'MediaWiki',
viewports: [
VIEWPORT_PHONE,
VIEWPORT_TABLET,
VIEWPORT_DESKTOP,
VIEWPORT_DESKTOP_WIDE,
VIEWPORT_DESKTOP_WIDEST
],
onBeforeScript: 'puppet/onBefore.js',
onReadyScript: 'puppet/onReady.js',
scenarios,
paths: utils.makePaths( 'login' ),
report: [],
engine: 'puppeteer',
engineOptions: {
args: [
'--no-sandbox'
]
},
asyncCaptureLimit: 10,
asyncCompareLimit: 50,
debug: false,
debugWindow: false
};
20 changes: 20 additions & 0 deletions configMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ const tests = [
{
label: 'Non-existent user page (#minerva #mobile)',
path: '/wiki/User:Echo1'
},
{
label: 'Test language overlay (#minerva #mobile #click-language)',
path: '/wiki/Test'
},
{
label: 'Test CTADrawer (#minerva #mobile #click-watch)',
path: '/wiki/Test'
},
{
label: 'Test red link drawer (#minerva #mobile #click-redlink)',
path: '/wiki/Test'
},
{
label: 'Test (#minerva #mobile #logged-in #click-edit)',
path: '/wiki/Test'
},
{
label: 'Diff page logged in (#minerva #mobile #logged-in)',
path: '/wiki/Special:MobileDiff/335'
}
];

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ services:
- ./configDesktopDev.js:/pixel/configDesktopDev.js
- ./configEcho.js:/pixel/configEcho.js
- ./configCampaignEvents.js:/pixel/configCampaignEvents.js
- ./configLogin.js:/pixel/configLogin.js
- ./configWebMaintained.js:/pixel/configWebMaintained.js
- ./configMobile.js:/pixel/configMobile.js
- ./configCodex.js:/pixel/configCodex.js
Expand Down
2 changes: 2 additions & 0 deletions pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ ${markerString}`
*/
const getGroupConfig = ( groupName ) => {
switch ( groupName ) {
case 'login':
return 'configLogin.js';
case 'web-maintained':
return 'configWebMaintained.js';
case 'echo':
Expand Down
13 changes: 13 additions & 0 deletions src/engine-scripts/puppet/minerva/clickBtn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Open or close Vector-2022's sidebar.
*
* @param {import('puppeteer').Page} page
* @param {string} selector
*/
module.exports = async ( page, selector ) => {
await page.evaluate( async ( s ) => {
const btn = document.querySelector( s );
await btn.click();
}, selector );
await page.waitForSelector( '.drawer,.overlay' );
};
15 changes: 15 additions & 0 deletions src/engine-scripts/puppet/onReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ module.exports = async ( page, scenario ) => {
// These only apply to Minerva
if ( hashtags.includes( '#minerva' ) ) {
await require( './minerva/mainMenuState' )( page, hashtags );

const clickBtn = require( './minerva/clickBtn' );
// Run click handlers if necessary.
if ( hashtags.includes( '#click-edit' ) ) {
await clickBtn( page, '#ca-edit' );
}
if ( hashtags.includes( '#click-language' ) ) {
await clickBtn( page, '#language-selector a' );
}
if ( hashtags.includes( '#click-watch' ) ) {
await clickBtn( page, '#ca-watch' );
}
if ( hashtags.includes( '#click-redlink' ) ) {
await clickBtn( page, 'a.new' );
}
}

// Run Echo handlers if necessary.
Expand Down
39 changes: 12 additions & 27 deletions src/engine-scripts/puppet/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ const fastForwardAnimations = require( './fastForwardAnimations' );
* @param {string[]} hashtags
*/
module.exports = async ( page, hashtags ) => {
const isOffline = hashtags.includes( '#search-offline' );
if ( isOffline ) {
await page.setOfflineMode( true );
}

const viewportWidth = page.viewport().width;
const isStickyHeaderScenario = hashtags.includes( '#search-sticky' );
const selectorSearchToggle = isStickyHeaderScenario ?
Expand All @@ -38,26 +33,16 @@ module.exports = async ( page, hashtags ) => {
await button.click();
// Focus the server side rendered search to trigger the loading of Vue.
await page.focus( selectorSearchInput );
if ( isOffline ) {
// type into the server side rendered input
page.keyboard.type( 't' );
// Wait for the loader to display
await page.waitForSelector( '.search-form__loader', {
visible: true
} );
await fastForwardAnimations( page );
} else {
// Make sure Codex kicked in.
await page.waitForSelector( '.cdx-typeahead-search' );
// Wait for Vue to load.
await moduleReady( page, 'vue' );
// focus and type into the newly added input
await page.focus( selectorSearchInput );
await page.keyboard.type( 't' );
// Wait for a search result to display.
await page.waitForSelector( selectorSearchSuggestion, {
visible: true,
timeout: 10000
} );
}
// Make sure Codex kicked in.
await page.waitForSelector( '.cdx-typeahead-search' );
// Wait for Vue to load.
await moduleReady( page, 'vue' );
// focus and type into the newly added input
await page.focus( selectorSearchInput );
await page.keyboard.type( 't' );
// Wait for a search result to display.
await page.waitForSelector( selectorSearchSuggestion, {
visible: true,
timeout: 10000
} );
};

0 comments on commit 77e52c6

Please sign in to comment.