Skip to content

Commit d4bcc01

Browse files
committed
tests
1 parent 6121dcb commit d4bcc01

File tree

2 files changed

+26
-41
lines changed

2 files changed

+26
-41
lines changed
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
import GravityForms from "./gravity-forms";
22

33
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();
77

8-
cy.visit("/wp-admin/post.php?post=126&action=edit");
8+
cy.visit("/wp-admin/post.php?post=126&action=edit");
99

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"' : '';
1811

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}]`);
2014

21-
cy.get(".components-snackbar__content").should("exist");
22-
});
23-
}
15+
cy.get(".editor-post-publish-button").click();
2416

25-
protected beforeScenario() {
26-
super.beforeScenario();
17+
cy.get(".components-snackbar__content").should("exist");
18+
});
19+
}
2720

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+
}
3026

31-
protected afterScenario() {
32-
super.afterScenario();
27+
protected beforeScenario() {
28+
super.beforeScenario();
3329

34-
this.toggleAjaxSubmissionSetting(false);
35-
}
30+
this.toggleAjaxSubmissionSetting(true);
31+
}
32+
33+
protected afterScenario() {
34+
super.afterScenario();
35+
36+
this.toggleAjaxSubmissionSetting(false);
37+
}
3638
}
3739

3840
export default GravityFormsWithAjax;

tests/cypress/support/commands.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,32 +81,15 @@ Cypress.Commands.add(
8181
(formElementSelector: string): Chainable<JQuery> => {
8282
return cy.get(formElementSelector).then(($formElement) => {
8383
if ("form" === $formElement.prop("tagName").toLowerCase()) {
84-
85-
cy.log(':getForm:1', {
86-
formElementSelector: formElementSelector,
87-
$formElement: $formElement.attr('class'),
88-
});
89-
9084
return cy.wrap($formElement);
9185
}
9286

9387
let $form = $formElement.find("form");
9488

9589
if ($form.length > 0) {
96-
cy.log(':getForm:2', {
97-
formElementSelector: formElementSelector,
98-
$form: $form.attr('class'),
99-
length: $form.length,
100-
});
101-
10290
return cy.wrap($form);
10391
}
10492

105-
cy.log(':getForm:3', {
106-
formElementSelector: formElementSelector,
107-
$formElement: $formElement.attr('class'),
108-
});
109-
11093
return cy.wrap($formElement);
11194
});
11295
},

0 commit comments

Comments
 (0)