|
1 | 1 | import GravityForms from "./gravity-forms";
|
2 | 2 |
|
3 | 3 | class GravityFormsWithAjax extends GravityForms {
|
4 |
| - protected toggleAjaxSubmissionSetting(isActivation: boolean): void { |
5 |
| - it("toggleAjaxSubmissionSetting", () => { |
6 |
| - this.integrationTest.login(); |
| 4 | + protected toggleAjaxSubmissionSetting(isActivation: boolean): void { |
| 5 | + it("toggleAjaxSubmissionSetting", () => { |
| 6 | + this.integrationTest.login(); |
7 | 7 |
|
8 |
| - cy.visit("/wp-admin/post.php?post=126&action=edit"); |
| 8 | + cy.visit("/wp-admin/post.php?post=126&action=edit"); |
9 | 9 |
|
10 |
| - cy.get("#blocks-shortcode-input-1").then(($input) => { |
11 |
| - true === isActivation |
12 |
| - ? cy.safeType( |
13 |
| - $input, |
14 |
| - '[gravityform id="2" title="true" ajax="true"]', |
15 |
| - ) |
16 |
| - : cy.safeType($input, '[gravityform id="2" title="true"]'); |
17 |
| - }); |
| 10 | + const ajaxArgument = isActivation ? 'ajax="true"' : ''; |
18 | 11 |
|
19 |
| - cy.get(".editor-post-publish-button").click(); |
| 12 | + this.replaceShortcode('#blocks-shortcode-input-1', `[gravityform id="2" title="true" ${ajaxArgument}]`); |
| 13 | + this.replaceShortcode('#blocks-shortcode-input-3', `[gravityform id="1" title="true" ${ajaxArgument}]`); |
20 | 14 |
|
21 |
| - cy.get(".components-snackbar__content").should("exist"); |
22 |
| - }); |
23 |
| - } |
| 15 | + cy.get(".editor-post-publish-button").click(); |
24 | 16 |
|
25 |
| - protected beforeScenario() { |
26 |
| - super.beforeScenario(); |
| 17 | + cy.get(".components-snackbar__content").should("exist"); |
| 18 | + }); |
| 19 | + } |
27 | 20 |
|
28 |
| - this.toggleAjaxSubmissionSetting(true); |
29 |
| - } |
| 21 | + protected replaceShortcode(shortocodeSelector: string, shortcode: string): void { |
| 22 | + cy.get(shortocodeSelector).then(($input) => { |
| 23 | + cy.safeType($input, shortcode); |
| 24 | + }); |
| 25 | + } |
30 | 26 |
|
31 |
| - protected afterScenario() { |
32 |
| - super.afterScenario(); |
| 27 | + protected beforeScenario() { |
| 28 | + super.beforeScenario(); |
33 | 29 |
|
34 |
| - this.toggleAjaxSubmissionSetting(false); |
35 |
| - } |
| 30 | + this.toggleAjaxSubmissionSetting(true); |
| 31 | + } |
| 32 | + |
| 33 | + protected afterScenario() { |
| 34 | + super.afterScenario(); |
| 35 | + |
| 36 | + this.toggleAjaxSubmissionSetting(false); |
| 37 | + } |
36 | 38 | }
|
37 | 39 |
|
38 | 40 | export default GravityFormsWithAjax;
|
0 commit comments