Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.22.5 #956

Merged
merged 6 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]

## [[v2.22.5]](https://github.com/multiversx/mx-sdk-dapp/pull/956)] - 2023-10-13
- [Prevent "document/window is undefined" issue on Next.js](https://github.com/multiversx/mx-sdk-dapp/pull/955)

## [[v2.22.4]](https://github.com/multiversx/mx-sdk-dapp/pull/954)] - 2023-10-13
- [Integration tests](https://github.com/multiversx/mx-sdk-dapp/pull/953)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp",
"version": "2.22.4",
"version": "2.22.5",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('ExtensionLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
});
});

Expand All @@ -83,7 +83,7 @@ describe('ExtensionLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledWith(
expect(window?.location.assign).toHaveBeenCalledWith(
'https://multivers.com'
);
});
Expand All @@ -108,7 +108,7 @@ describe('ExtensionLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledTimes(0);
expect(window?.location.assign).toHaveBeenCalledTimes(0);
expect(onLoginRedirect).toHaveBeenCalledTimes(1);
expect(onLoginRedirect).toHaveBeenCalledWith(CALLBACK_ROUTE, {
address: testAddress,
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('ExtensionLoginButton tests', () => {
tokenLoginWithSignature
);

expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
});
});

Expand All @@ -164,7 +164,7 @@ describe('ExtensionLoginButton tests', () => {
fireEvent.click(loginButton);

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledTimes(0);
expect(window?.location.assign).toHaveBeenCalledTimes(0);
});
});
});
10 changes: 5 additions & 5 deletions src/UI/ledger/LedgerLoginButton/tests/LedgerLoginButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('LedgerLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
});
});

Expand All @@ -78,7 +78,7 @@ describe('LedgerLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledWith(
expect(window?.location.assign).toHaveBeenCalledWith(
'https://multivers.com'
);
});
Expand All @@ -101,7 +101,7 @@ describe('LedgerLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledTimes(0);
expect(window?.location.assign).toHaveBeenCalledTimes(0);
expect(onLoginRedirect).toHaveBeenCalledTimes(1);
expect(onLoginRedirect).toHaveBeenCalledWith(CALLBACK_ROUTE, {
address: testAddress,
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('LedgerLoginButton tests', () => {
tokenLoginWithSignature
);

expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
});
});

Expand All @@ -162,7 +162,7 @@ describe('LedgerLoginButton tests', () => {
await ledgerLogin(methods);

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledTimes(0);
expect(window?.location.assign).toHaveBeenCalledTimes(0);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe.skip('OperaLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
});
});
it('should perform simple login and call onLoginRedirect', async () => {
Expand All @@ -73,7 +73,7 @@ describe.skip('OperaLoginButton tests', () => {
await checkIsLoggedInStore();

await waitFor(() => {
expect(window.location.assign).toHaveBeenCalledTimes(0);
expect(window?.location.assign).toHaveBeenCalledTimes(0);
expect(onLoginRedirect).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -92,7 +92,7 @@ describe.skip('OperaLoginButton tests', () => {

await waitFor(() => {
expect(consoleWarnSpy).toHaveBeenCalledWith(tokenLogin);
expect(window.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
expect(window?.location.assign).toHaveBeenCalledWith(CALLBACK_ROUTE);
});
});
it('should not perform nativeAuth login when block call fails', async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/__mocks__/utils/mockWindowHistory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export const mockWindowHistory = () => {
if (!window) {
return;
}

const history = window.history;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
4 changes: 4 additions & 0 deletions src/__mocks__/utils/mockWindowLocation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export const mockWindowLocation = () => {
if (!window) {
return;
}

const location = window.location;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/login/useWebWalletLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const useWebWalletLogin = ({
const targetUrl = window?.location
? `${origin}${callbackRoute}`
: `${callbackRoute}`;
const params = new URLSearchParams(document.location.search);
const params = new URLSearchParams(document?.location.search);

// skip login when an address param is prefilled in URL
const skipLogin = params.get('address');
Expand Down