Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
enmaboya committed Nov 11, 2024
1 parent 41e641d commit 78aaa4f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Traits/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function authenticate(Request $request, AuthenticateShop $authShop)
'shopify-app::auth.fullpage_redirect',
[
'apiKey' => Util::getShopifyConfig('api_key', $shopOrigin),
'authUrl' => $result['url'],
'url' => $result['url'],
'host' => $request->get('host'),
'shopDomain' => $shopDomain,
'locale' => $request->get('locale'),
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/auth/fullpage_redirect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
let redirectUrl = "{!! $authUrl !!}";
let redirectUrl = "{!! $url !!}";
if (window.top === window.self) {
window.top.location.href = redirectUrl;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/billing/fullpage_redirect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
let redirectUrl = "{!! $authUrl !!}";
let redirectUrl = "{!! $url !!}";
if (window.top === window.self) {
window.top.location.href = redirectUrl;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/layouts/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="shopify-api-key" content="{{ config('shopify-app.api_key') }}" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>

<title>{{ \Osiset\ShopifyApp\Util::getShopifyConfig('app_name') }}</title>
<title>{{ config('shopify-app.app_name') }}</title>
@yield('styles')
</head>

Expand Down
6 changes: 3 additions & 3 deletions src/resources/views/partials/token_handler.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script>
let SESSION_TOKEN_REFRESH_INTERVAL = {{ \Osiset\ShopifyApp\Util::getShopifyConfig('session_token_refresh_interval') }};
var SESSION_TOKEN_REFRESH_INTERVAL = {{ config('shopify-app.session_token_refresh_interval') }};
var LOAD_EVENT = 'DOMContentLoaded'
document.addEventListener('DOMContentLoaded', () => {
document.addEventListener(LOAD_EVENT, () => {
retrieveToken();
keepRetrievingToken();
});
Expand Down Expand Up @@ -29,7 +30,6 @@
}
if (window.Livewire) {
// Works only with Livewire 2
window.Livewire.hook('request', ({options}) => {
options.headers['Authorization'] = `Bearer ${window.sessionToken}`;
options.headers['Content-Type'] = 'application/json';
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/AuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testAuthRedirectsToShopifyWhenNoCode(): void
// Check the redirect happens and location is set properly in the header.
$response->assertViewHas('shopDomain', 'example.myshopify.com');
$response->assertViewHas(
'authUrl',
'url',
'https://example.myshopify.com/admin/oauth/authorize?client_id='.Util::getShopifyConfig('api_key').'&scope=read_products%2Cwrite_products%2Cread_themes&redirect_uri=https%3A%2F%2Flocalhost%2Fauthenticate'
);

Expand Down
1 change: 1 addition & 0 deletions tests/Traits/BillingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function testSendsShopToBillingScreen(): void

// Run the call
$response = $this->call('get', '/billing', ['shop' => $shop->getDomain()->toNative()]);

$response->assertViewHas(
'url',
'https://example.myshopify.com/admin/charges/1029266947/confirm_recurring_application_charge?signature=BAhpBANeWT0%3D--64de8739eb1e63a8f848382bb757b20343eb414f'
Expand Down
9 changes: 3 additions & 6 deletions tests/Traits/HomeControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Auth\AuthManager;
use Osiset\ShopifyApp\Test\TestCase;
use Osiset\ShopifyApp\Util;

class HomeControllerTest extends TestCase
{
Expand All @@ -27,18 +26,16 @@ public function testHomeRoute(): void
$host = base64_encode($shop->getDomain()->toNative().'/admin');
$this->call('get', '/', ['token' => $this->buildToken(), 'host' => $host])
->assertOk()
->assertSee('apiKey: "'.Util::getShopifyConfig('api_key').'"', false)
->assertSee("host: \"{$host}\"", false);
->assertSee("https://cdn.shopify.com/shopifycloud/app-bridge.js");
}

public function testHomeRouteHostAdmin(): void
{
$shop = factory($this->model)->create(['name' => 'shop-name.myshopify.com']);
factory($this->model)->create(['name' => 'shop-name.myshopify.com']);

$host = base64_encode('admin.shopify.com/store/shop-name');
$this->call('get', '/', ['token' => $this->buildToken(), 'host' => $host])
->assertOk()
->assertSee('apiKey: "'.Util::getShopifyConfig('api_key').'"', false)
->assertSee("host: \"{$host}\"", false);
->assertSee("https://cdn.shopify.com/shopifycloud/app-bridge.js");
}
}

0 comments on commit 78aaa4f

Please sign in to comment.