Skip to content

Commit

Permalink
debbug macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacper-RF committed Aug 10, 2023
1 parent 8d5d72c commit 8e5660f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/e2e-tests/src/tests/invitationLink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,46 @@ describe('New user joins using invitation link while having app opened', () => {
guestApp = new App({ useDataDir: false })
})

beforeEach(async () => {
await new Promise<void>(resolve => setTimeout(() => resolve(), 2000))
})

afterAll(async () => {
await ownerApp?.close()
await guestApp?.close()
})

describe('Stages:', () => {
it('Owner opens the app', async () => {
console.log('Invitation Link', 1)
await ownerApp.open()
})

if (process.env.TEST_MODE) {
it('Owner closes debug modal', async () => {
console.log('Invitation Link', 2)
const debugModal = new DebugModeModal(ownerApp.driver)
await debugModal.close()
})
}

it('StartingLoadingPanel modal', async () => {
console.log('Invitation Link', 3)
const loadingPanel = new StartingLoadingPanel(ownerApp.driver)
const isLoadingPanel = await loadingPanel.element.isDisplayed()
expect(isLoadingPanel).toBeTruthy()
})

it('JoinCommunityModal - owner switches to create community', async () => {
console.log('Invitation Link', 4)
const joinModal = new JoinCommunityModal(ownerApp.driver)
const isJoinModal = await joinModal.element.isDisplayed()
expect(isJoinModal).toBeTruthy()
await joinModal.switchToCreateCommunity()
})

it('CreateCommunityModal - owner creates his community', async () => {
console.log('Invitation Link', 5)
const createModal = new CreateCommunityModal(ownerApp.driver)
const isCreateModal = await createModal.element.isDisplayed()
expect(isCreateModal).toBeTruthy()
Expand All @@ -69,6 +78,7 @@ describe('New user joins using invitation link while having app opened', () => {
})

it('RegisterUsernameModal - owner has registered', async () => {
console.log('Invitation Link', 6)
const registerModal = new RegisterUsernameModal(ownerApp.driver)
const isRegisterModal = await registerModal.element.isDisplayed()
expect(isRegisterModal).toBeTruthy()
Expand All @@ -77,12 +87,14 @@ describe('New user joins using invitation link while having app opened', () => {
})

it('Connecting to peers modal', async () => {
console.log('Invitation Link', 7)
const loadingPanelCommunity = new JoiningLoadingPanel(ownerApp.driver)
const isLoadingPanelCommunity = await loadingPanelCommunity.element.isDisplayed()
expect(isLoadingPanelCommunity).toBeTruthy()
})

it('Owner sees general channel', async () => {
console.log('Invitation Link', 8)
const generalChannel = new Channel(ownerApp.driver, 'general')
const isGeneralChannel = await generalChannel.element.isDisplayed()
const generalChannelText = await generalChannel.element.getText()
Expand All @@ -91,10 +103,12 @@ describe('New user joins using invitation link while having app opened', () => {
})

it('Owner opens the settings tab and gets an invitation code', async () => {
console.log('Invitation Link', 9)
const settingsModal = await new Sidebar(ownerApp.driver).openSettings()
const isSettingsModal = await settingsModal.element.isDisplayed()
expect(isSettingsModal).toBeTruthy()
await settingsModal.switchTab('invite') // TODO: Fix - the invite tab should be default for the owner
await new Promise<void>(resolve => setTimeout(() => resolve(), 1000))
const invitationCodeElement = await settingsModal.invitationCode()
invitationCode = await invitationCodeElement.getText()
console.log('Received invitation link:', invitationCode)
Expand All @@ -105,21 +119,25 @@ describe('New user joins using invitation link while having app opened', () => {
// MacOS tries to open link in first app (owner's app) so the workaround is to temporarly close owner
// while clicking on the invitation link to have just one instance of app opened
it('Owner closes the app', async () => {
console.log('Invitation Link', 10)
await ownerApp.close({ forceSaveState: true })
})
}

it('Guest opens the app', async () => {
console.log('Invitation Link', 11)
console.log('Guest opens app')
await guestApp.open()
})
if (process.env.TEST_MODE) {
it('Close debug modal', async () => {
console.log('Invitation Link', 12)
const debugModal = new DebugModeModal(guestApp.driver)
await debugModal.close()
})
}
it('StartingLoadingPanel modal', async () => {
console.log('Invitation Link', 13)
const loadingPanel = new StartingLoadingPanel(guestApp.driver)
const isLoadingPanel = await loadingPanel.element.isDisplayed()
expect(isLoadingPanel).toBeTruthy()
Expand All @@ -141,6 +159,7 @@ describe('New user joins using invitation link while having app opened', () => {
})

it('Guest clicks invitation link with valid code', async () => {
console.log('Invitation Link', 14)
// Extract code from copied invitation url

const url = new URL(invitationCode)
Expand All @@ -155,13 +174,15 @@ describe('New user joins using invitation link while having app opened', () => {
})

it('Guest is redirected to UsernameModal', async () => {
console.log('Invitation Link', 15)
console.log('Guest sees username modal')
const registerModal = new RegisterUsernameModal(guestApp.driver)
const isRegisterModalDisplayed = await registerModal.element.isDisplayed()
expect(isRegisterModalDisplayed).toBeTruthy()
})

it('Guest submits username', async () => {
console.log('Invitation Link', 16)
console.log('Guest submits username')
const registerModal = new RegisterUsernameModal(guestApp.driver)
await registerModal.typeUsername(joiningUserUsername)
Expand All @@ -171,16 +192,19 @@ describe('New user joins using invitation link while having app opened', () => {
if (process.platform === 'darwin') {
// Open the owner's app again so guest would be able to register
it('Owner opens the app again', async () => {
console.log('Invitation Link', 17)
console.log('Owner opens the app again')
await ownerApp.open()
})
if (process.env.TEST_MODE) {
it('Owner closes debug modal', async () => {
console.log('Invitation Link', 18)
const debugModal = new DebugModeModal(ownerApp.driver)
await debugModal.close()
})
}
it('Owner sees starting panel', async () => {
console.log('Invitation Link', 19)
console.log('Owner sees starting panel')
const loadingPanel = new StartingLoadingPanel(ownerApp.driver)
const isLoadingPanel = await loadingPanel.element.isDisplayed()
Expand All @@ -189,12 +213,14 @@ describe('New user joins using invitation link while having app opened', () => {
}

it('Guest joined a community and sees general channel', async () => {
console.log('Invitation Link', 20)
console.log('guest sees general channel')
const generalChannel = new Channel(guestApp.driver, 'general')
await generalChannel.element.isDisplayed()
})

it('Owner sees that guest joined community', async () => {
console.log('Invitation Link', 21)
const generalChannel = new Channel(ownerApp.driver, 'general')
await generalChannel.element.isDisplayed()
const userJoinedMessage = await generalChannel.getMessage(
Expand Down

0 comments on commit 8e5660f

Please sign in to comment.