-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIxes for the close welcome modal command
- Loading branch information
Konstantinos Galanakis
committed
Aug 3, 2023
1 parent
1bbbebf
commit 1096b0d
Showing
3 changed files
with
68 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable tsdoc/syntax */ | ||
/** | ||
* Check Block Pattern Exists. Works only with WordPress \>=5.5 | ||
* | ||
* \@param postData { | ||
* `title` - Patttern name/title, | ||
* `categoryValue` - Value of the pattern category, | ||
* } | ||
* | ||
* @example | ||
* For WP v5.5 | ||
* ``` | ||
* cy.checkBlockPatternExists({ | ||
* title: 'Two buttons', | ||
* }); | ||
* ``` | ||
* | ||
* @example | ||
* For WP v5.9 | ||
* ``` | ||
* cy.checkBlockPatternExists({ | ||
* title: 'Three columns with offset images', | ||
* categoryValue: 'gallery', | ||
* }); | ||
* ``` | ||
*/ | ||
declare global { | ||
interface Window { | ||
wp: any; | ||
} | ||
} | ||
|
||
export const closeWelcomeGuideJavascript = (): void => { | ||
cy.window() | ||
.then(win => { | ||
/* eslint-disable */ | ||
let elapsed = 0; | ||
console.log('hello'); | ||
|
||
setInterval(function () { | ||
if (elapsed > 2500) { | ||
return; | ||
} | ||
|
||
const { wp } = win; | ||
|
||
const { isFeatureActive } = wp.data.select('core/edit-post'); | ||
const { toggleFeature } = wp.data.dispatch('core/edit-post'); | ||
const isWelcomeGuideActive = isFeatureActive('welcomeGuide'); | ||
|
||
if (!!isWelcomeGuideActive) { | ||
toggleFeature('welcomeGuide'); | ||
return; | ||
} | ||
|
||
elapsed += 100; | ||
}, 100); | ||
|
||
|
||
|
||
|
||
/* eslint-enable */ | ||
}) | ||
}; |
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