-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/using custom protocol multiple times causes wrong invitation code…
…s being stored #1847 (#2068) * fix: mock store readyness for mobile tests * test: deep linking on mobile * test: deep linking on desktop * fix: correct store data injecting #1847 * test: remove component from rendering * chore: update CHANGELOG * test: adjust tests after merging psk work * chore: refactor invitation data mocking * fix: lint * fix: test snapshot for mobile deep linking * chore: skip mobile splash screen tests due to changes made to data mocking
- Loading branch information
Showing
15 changed files
with
209 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { act } from 'react-dom/test-utils' | ||
import { AnyAction } from 'redux' | ||
import { take } from 'typed-redux-saga' | ||
import MockedSocket from 'socket.io-mock' | ||
import { ioMock } from '../shared/setupTests' | ||
import { prepareStore } from '../renderer/testUtils/prepareStore' | ||
import { renderComponent } from '../renderer/testUtils/renderComponent' | ||
import { validInvitationCodeTestData } from '@quiet/common' | ||
import { communities } from '@quiet/state-manager' | ||
|
||
describe('Deep linking', () => { | ||
let socket: MockedSocket | ||
|
||
beforeEach(async () => { | ||
socket = new MockedSocket() | ||
ioMock.mockImplementation(() => socket) | ||
}) | ||
|
||
test('does not override network data if triggered twice', async () => { | ||
const { store, runSaga } = await prepareStore({}, socket) | ||
|
||
// Log all the dispatched actions in order | ||
const actions: AnyAction[] = [] | ||
runSaga(function* (): Generator { | ||
while (true) { | ||
const action = yield* take() | ||
actions.push(action.type) | ||
} | ||
}) | ||
|
||
renderComponent(<></>, store) | ||
|
||
store.dispatch(communities.actions.customProtocol(validInvitationCodeTestData[0])) | ||
await act(async () => {}) | ||
|
||
const originalPair = communities.selectors.invitationCodes(store.getState()) | ||
|
||
// Redo the action to provoke renewed saga runs | ||
store.dispatch(communities.actions.customProtocol(validInvitationCodeTestData[1])) | ||
await act(async () => {}) | ||
|
||
const currentPair = communities.selectors.invitationCodes(store.getState()) | ||
|
||
expect(originalPair).toEqual(currentPair) | ||
|
||
expect(actions).toMatchInlineSnapshot(` | ||
Array [ | ||
"Communities/customProtocol", | ||
"Communities/createNetwork", | ||
"Communities/setInvitationCodes", | ||
"Communities/savePSK", | ||
"Communities/addNewCommunity", | ||
"Communities/setCurrentCommunity", | ||
"Communities/customProtocol", | ||
"Modals/openModal", | ||
] | ||
`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.