Skip to content

Commit

Permalink
Merge pull request #728 from ConvertKit/fix-failing-tests
Browse files Browse the repository at this point in the history
Fix Failing Tests
  • Loading branch information
n7studios authored Oct 23, 2024
2 parents 97cc5f9 + 5890ea6 commit 2ae7346
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ jobs:
working-directory: ${{ env.PLUGIN_DIR }}
run: php vendor/bin/codecept build

# Run Codeception WPUnit Tests on the PHP 8.0 instance before the acceptance/broadcasts acceptance tests.
# Run Codeception WPUnit Tests on the PHP 8.3 instance before the acceptance/tags acceptance tests.
# We run these once to avoid hitting API rate limits.
- name: Run tests/wpunit
if: ${{ matrix.php-versions == '8.0' && matrix.test-groups == 'acceptance/broadcasts' }}
if: ${{ matrix.php-versions == '8.3' && matrix.test-groups == 'acceptance/tags' }}
working-directory: ${{ env.PLUGIN_DIR }}
run: php vendor/bin/codecept run tests/wpunit --fail-fast

Expand Down
6 changes: 3 additions & 3 deletions tests/_support/Helper/Acceptance/ConvertKitForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ public function seeFormOutput($I, $formID, $position = false, $element = false,
// The block editor automatically adds CSS classes to some elements.
switch ( $element ) {
case 'p':
$I->seeInSource('<' . $element . '>Item #' . $element_index . '</' . $element . '><form action="https://app.convertkit.com/forms/' . $formID . '/subscriptions" ');
$I->seeInSource('<' . $element . '>Item #' . $element_index . '</' . $element . '><form action="https://app.kit.com/forms/' . $formID . '/subscriptions" ');
break;

case 'img':
$I->seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $element_index . '"><form action="https://app.convertkit.com/forms/' . $formID . '/subscriptions" ');
$I->seeInSource('<' . $element . ' decoding="async" src="https://placehold.co/600x400" alt="Image #' . $element_index . '"><form action="https://app.kit.com/forms/' . $formID . '/subscriptions" ');
break;

// Headings.
default:
$I->seeInSource('<' . $element . ' class="wp-block-heading">Item #' . $element_index . '</' . $element . '><form action="https://app.convertkit.com/forms/' . $formID . '/subscriptions" ');
$I->seeInSource('<' . $element . ' class="wp-block-heading">Item #' . $element_index . '</' . $element . '><form action="https://app.kit.com/forms/' . $formID . '/subscriptions" ');
break;
}
break;
Expand Down
8 changes: 4 additions & 4 deletions tests/acceptance/forms/general/CategoryFormCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function testAddCategoryWithFormPositionBefore(AcceptanceTester $I)
$I->seeInSource(
'</h1>
<form action="https://app.convertkit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
<form action="https://app.kit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
);

// Confirm that one ConvertKit Form is output in the DOM.
Expand Down Expand Up @@ -259,7 +259,7 @@ public function testAddCategoryWithFormPositionAfter(AcceptanceTester $I)
// Confirm form is after closing div element.
$I->seeInSource(
'</div>
<form action="https://app.convertkit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
<form action="https://app.kit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
);

// Confirm that one ConvertKit Form is output in the DOM.
Expand Down Expand Up @@ -339,7 +339,7 @@ public function testEditCategoryWithFormPositionBefore(AcceptanceTester $I)
$I->seeInSource(
'</h1>
<form action="https://app.convertkit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
<form action="https://app.kit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
);

// Confirm that one ConvertKit Form is output in the DOM.
Expand Down Expand Up @@ -418,7 +418,7 @@ public function testEditCategoryWithFormPositionAfter(AcceptanceTester $I)
// Confirm form is after closing div element.
$I->seeInSource(
'</div>
<form action="https://app.convertkit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
<form action="https://app.kit.com/forms/' . $_ENV['CONVERTKIT_API_FORM_ID'] . '/subscriptions"'
);

// Confirm that one ConvertKit Form is output in the DOM.
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/landing-pages/PageLandingPageCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function testLandingPageCharacterEncoding(AcceptanceTester $I)
$I->publishAndViewGutenbergPage($I);

// Confirm that the basic HTML structure is correct.
$I->seeLandingPageOutput($I);
$I->seeLandingPageOutput($I, true);

// Confirm that the Landing Page title is the same as defined on ConvertKit i.e. that character encoding is correct.
$I->seeInSource('Vantar þinn ungling sjálfstraust í stærðfræði?');
Expand Down
22 changes: 11 additions & 11 deletions tests/wpunit/ResourceFormsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function setUp(): void
update_option(
$this->settings::SETTINGS_NAME,
[
'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN_NO_DATA'],
'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN_NO_DATA'],
'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN'],
'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN'],
]
);

Expand Down Expand Up @@ -196,8 +196,8 @@ public function testGetWithInvalidOrderBy()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data has not changed.
$this->assertEquals('AAA Test', reset($result)['name']);
$this->assertEquals('WooCommerce Product Form', end($result)['name']);
$this->assertEquals('WPForms Form', reset($result)['name']);
$this->assertEquals('Legacy Form', end($result)['name']);
}

/**
Expand All @@ -223,8 +223,8 @@ public function testGetNonInline()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data is in ascending alphabetical order.
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'], reset($result)[ $this->resource->order_by ]);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME'], end($result)[ $this->resource->order_by ]);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME_ONLY'], reset($result)[ $this->resource->order_by ]);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME_ONLY'], end($result)[ $this->resource->order_by ]);
}

/**
Expand Down Expand Up @@ -254,8 +254,8 @@ public function testGetNonInlineWithValidOrderByAndOrder()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data is in ascending alphabetical order.
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME'], reset($result)[ $this->resource->order_by ]);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'], end($result)[ $this->resource->order_by ]);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME_ONLY'], reset($result)[ $this->resource->order_by ]);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME_ONLY'], end($result)[ $this->resource->order_by ]);
}

/**
Expand Down Expand Up @@ -284,8 +284,8 @@ public function testGetNonInlineWithInvalidOrderBy()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data has not changed.
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME'], reset($result)['name']);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME'], end($result)['name']);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_STICKY_BAR_NAME_ONLY'], reset($result)['name']);
$this->assertEquals($_ENV['CONVERTKIT_API_FORM_FORMAT_MODAL_NAME_ONLY'], end($result)['name']);
}

/**
Expand Down Expand Up @@ -332,7 +332,7 @@ public function testGetHTML()
{
$result = $this->resource->get_html($_ENV['CONVERTKIT_API_FORM_ID']);
$this->assertNotInstanceOf(WP_Error::class, $result);
$this->assertSame($result, '<script async data-uid="85629c512d" src="https://cheerful-architect-3237.ck.page/85629c512d/index.js"></script>');
$this->assertSame($result, '<script async data-uid="85629c512d" src="https://cheerful-architect-3237.ck.page/85629c512d/index.js" data-jetpack-boost="ignore" data-no-defer="1" nowprocket></script>');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/wpunit/ResourcePostsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function setUp(): void
update_option(
$this->settings::SETTINGS_NAME,
[
'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN_NO_DATA'],
'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN_NO_DATA'],
'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN'],
'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN'],
]
);

Expand Down Expand Up @@ -248,7 +248,7 @@ public function testGet()
$this->assertArrayHasKey('title', reset($result));

// Assert order of data is in descending published_at order.
$this->assertEquals($_ENV['CONVERTKIT_API_BROADCAST_FIRST_DATE'], reset($result)[ $this->resource->order_by ]);
$this->assertEquals('2024-04-30T08:00:36.000Z', reset($result)[ $this->resource->order_by ]);
$this->assertEquals('2022-01-24T00:00:00.000Z', end($result)[ $this->resource->order_by ]);
}

Expand Down Expand Up @@ -309,7 +309,7 @@ public function testGetWithInvalidOrderBy()
$this->assertArrayHasKey('title', reset($result));

// Assert order of data has not changed.
$this->assertEquals($_ENV['CONVERTKIT_API_BROADCAST_FIRST_DATE'], reset($result)['published_at']);
$this->assertEquals('2024-04-30T08:00:36.000Z', reset($result)['published_at']);
$this->assertEquals('2022-01-24T00:00:00.000Z', end($result)['published_at']);
}

Expand Down
10 changes: 5 additions & 5 deletions tests/wpunit/ResourceProductsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function setUp(): void
update_option(
$this->settings::SETTINGS_NAME,
[
'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN_NO_DATA'],
'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN_NO_DATA'],
'access_token' => $_ENV['CONVERTKIT_OAUTH_ACCESS_TOKEN'],
'refresh_token' => $_ENV['CONVERTKIT_OAUTH_REFRESH_TOKEN'],
]
);

Expand Down Expand Up @@ -136,7 +136,7 @@ public function testGet()

// Assert order of data is in ascending alphabetical order.
$this->assertEquals('Example Tip Jar', reset($result)[ $this->resource->order_by ]);
$this->assertEquals('Newsletter Subscription', end($result)[ $this->resource->order_by ]);
$this->assertEquals('PDF Guide', end($result)[ $this->resource->order_by ]);
}

/**
Expand Down Expand Up @@ -166,7 +166,7 @@ public function testGetWithValidOrderByAndOrder()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data is in ascending alphabetical order.
$this->assertEquals('Newsletter Subscription', reset($result)[ $this->resource->order_by ]);
$this->assertEquals('PDF Guide', reset($result)[ $this->resource->order_by ]);
$this->assertEquals('Example Tip Jar', end($result)[ $this->resource->order_by ]);
}

Expand Down Expand Up @@ -196,7 +196,7 @@ public function testGetWithInvalidOrderBy()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data has not changed.
$this->assertEquals('Example Tip Jar', reset($result)['name']);
$this->assertEquals('PDF Guide', reset($result)['name']);
$this->assertEquals('Newsletter Subscription', end($result)['name']);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/wpunit/ResourceTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ public function testGetWithInvalidOrderBy()
$this->assertArrayHasKey('name', reset($result));

// Assert order of data has not changed.
$this->assertEquals('wordpress', reset($result)['name']);
$this->assertEquals('wpforms', end($result)['name']);
$this->assertEquals('wpforms', reset($result)['name']);
$this->assertEquals('wordpress', end($result)['name']);
}

/**
Expand Down

0 comments on commit 2ae7346

Please sign in to comment.