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

Chore/e2e test unregistered user #1826

Merged
merged 25 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8565ee5
Add new user to multiple users e2e test
EmiM Sep 15, 2023
e1d07b7
Uncomment showing label
EmiM Sep 18, 2023
9a801f9
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Sep 18, 2023
4cc10b1
Fix few steps in e2e multiple user test
EmiM Sep 19, 2023
544496d
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Sep 19, 2023
83e28cf
E2E tests - finish all steps for checking if unregistered user is lab…
EmiM Sep 19, 2023
7973672
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Sep 19, 2023
15a9d41
Fix closing debug modal in test
EmiM Sep 19, 2023
6720c6f
Show Quiet logs in e2e tests
EmiM Sep 20, 2023
6e19b17
Fixes
EmiM Sep 20, 2023
567d044
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Sep 20, 2023
b7686e8
Fix selectors in e2e tests
EmiM Sep 21, 2023
9658700
Finish e2e test for unregistered user; Remove dupliated sortPeers fun…
EmiM Sep 22, 2023
72dfe76
E2E test for multiple users - group users data
EmiM Sep 25, 2023
8b78e9d
Rename twoClients to multipleClients e2e test
EmiM Sep 25, 2023
287004b
Clean up variables naming in e2e multiple clients test
EmiM Sep 25, 2023
5c59ecd
Make test steps in multiple clients e2e test more clear
EmiM Sep 25, 2023
8cee282
Don't stop CI workflow if tor or quiet processes can't be found on wi…
EmiM Sep 26, 2023
9c093f8
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Sep 26, 2023
06c887c
Update changelog
EmiM Sep 26, 2023
14e36cd
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Oct 3, 2023
4af8ccd
Remove unused code
EmiM Oct 4, 2023
3c52f96
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Oct 4, 2023
b99429d
Merge branch 'develop' into chore/e2e-test-unregistered-user
EmiM Oct 5, 2023
850514b
Remove test logs
EmiM Oct 5, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/e2e-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ jobs:
max_attempts: 3
command: cd packages/e2e-tests && npm run test oneClient.test.ts

- name: Run two clients test
- name: Run multiple clients test
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: 3
command: cd packages/e2e-tests && npm run test twoClients.test.ts
command: cd packages/e2e-tests && npm run test multipleClients.test.ts

- name: Run invitation link test - Includes 2 separate application clients
uses: nick-fields/retry@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ jobs:
max_attempts: 3
command: cd packages/e2e-tests && npm run test oneClient.test.ts

- name: Run two clients test
- name: Run multiple clients test
uses: nick-fields/retry@v2
with:
timeout_minutes: 25
max_attempts: 3
command: cd packages/e2e-tests && npm run test twoClients.test.ts
command: cd packages/e2e-tests && npm run test multipleClients.test.ts


8 changes: 4 additions & 4 deletions .github/workflows/e2e-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ jobs:
shell: powershell

- name: Kill Quiet
run: Stop-Process -Name "Quiet" -Force
run: Get-Process -Name "Quiet" -ErrorAction SilentlyContinue | Stop-Process -Force
shell: powershell

- name: Kill tor
run: Stop-Process -Name "tor" -Force
run: Get-Process -Name "tor" -ErrorAction SilentlyContinue | Stop-Process -Force
shell: powershell

- name: Delay
Expand All @@ -87,13 +87,13 @@ jobs:
shell: bash
command: cd packages/e2e-tests && npm run test oneClient.test.ts

- name: Run two clients test
- name: Run multiple clients test
uses: nick-fields/retry@v2
with:
timeout_minutes: 30
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test twoClients.test.ts
command: cd packages/e2e-tests && npm run test multipleClients.test.ts

- name: Run invitation link test - Includes 2 separate application clients
uses: nick-fields/retry@v2
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Running Chromatic tests for forked PRs

* Added e2e test for user joining community when owner is offline. Improved e2e tests

[2.0.0-alpha.11]

* Customize Launch Screen on iOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
targetPort: this.ports.libp2pHiddenService,
peers,
}
this.logger('libp2p params', params)

await this.libp2pService.createInstance(params)
// KACPER
Expand Down
3 changes: 0 additions & 3 deletions packages/backend/src/nest/socket/socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ export class SocketService extends EventEmitter implements OnModuleInit {
ownerCertificate: payload.certificate,
rootCa: payload.permsData.certificate,
}

console.log('Metadata from state-manager', communityMetadataPayload)

this.emit(SocketActionTypes.SEND_COMMUNITY_METADATA, communityMetadataPayload)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('BasicMessage', () => {
>
<div
class="MuiListItemText-root BasicMessageComponentmessageCard css-tlelie-MuiListItemText-root"
data-testid="userMessagesWrapper-gringo-0"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-wrap-xs-nowrap css-aii0rt-MuiGrid-root"
Expand Down Expand Up @@ -124,6 +125,7 @@ describe('BasicMessage', () => {
>
<div
class="MuiListItemText-root BasicMessageComponentmessageCard css-tlelie-MuiListItemText-root"
data-testid="userMessagesWrapper-gringo-0"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-wrap-xs-nowrap css-aii0rt-MuiGrid-root"
Expand Down Expand Up @@ -222,6 +224,7 @@ describe('BasicMessage', () => {
>
<div
class="MuiListItemText-root BasicMessageComponentmessageCard css-tlelie-MuiListItemText-root"
data-testid="userMessagesWrapper-gringo-0"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-wrap-xs-nowrap css-aii0rt-MuiGrid-root"
Expand Down Expand Up @@ -324,6 +327,7 @@ describe('BasicMessage', () => {
>
<div
class="MuiListItemText-root BasicMessageComponentmessageCard css-tlelie-MuiListItemText-root"
data-testid="userMessagesWrapper-gringo-0"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-wrap-xs-nowrap css-aii0rt-MuiGrid-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export const BasicMessageComponent: React.FC<BasicMessageProps & FileActionsProp
<ListItemText
disableTypography
className={classes.messageCard}
data-testid={`userMessagesWrapper-${messageDisplayData.nickname}-${messageDisplayData.id}`}
primary={
<Grid container direction='row' justifyContent='flex-start' alignItems='flex-start' wrap={'nowrap'}>
<Grid item className={classNames({ [classes.avatar]: true })}>
Expand All @@ -219,7 +220,7 @@ export const BasicMessageComponent: React.FC<BasicMessageProps & FileActionsProp
</Typography>
</Grid>
{userLabel && (
<Grid>
<Grid data-testid={`userLabel-${messageDisplayData.nickname}-${messageDisplayData.id}`}>
<UserLabel
username={messageDisplayData.nickname}
type={userLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('ChannelMessages', () => {
>
<div
class="MuiListItemText-root BasicMessageComponentmessageCard css-tlelie-MuiListItemText-root"
data-testid="userMessagesWrapper-string-string"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-wrap-xs-nowrap css-aii0rt-MuiGrid-root"
Expand Down
3 changes: 2 additions & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint-ci": "eslint --ext .js,.ts ./src/",
"prettier:write": "prettier --write .",
"prettier:check": "prettier --check .",
"test": "jest --runInBand --detectOpenHandles --forceExit",
"test": "cross-env TEST_MODE=true jest --runInBand --detectOpenHandles --forceExit",
"test:prod": "jest --runInBand --detectOpenHandles --forceExit",
"test:watch": "jest --watchAll"
},
"devDependencies": {
Expand Down
75 changes: 63 additions & 12 deletions packages/e2e-tests/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BuildSetup, type BuildSetupInit } from './utils'
export class App {
thenableWebDriver?: ThenableWebDriver
buildSetup: BuildSetup
isOpened: boolean
constructor(buildSetupConfig?: BuildSetupInit) {
this.buildSetup = new BuildSetup({ ...buildSetupConfig })
}
Expand All @@ -16,13 +17,19 @@ export class App {
}

async open() {
console.log('Opening the app', this.buildSetup.dataDir)
this.buildSetup.resetDriver()
await this.buildSetup.createChromeDriver()
this.isOpened = true
this.thenableWebDriver = this.buildSetup.getDriver()
await this.driver.getSession()
const debugModal = new DebugModeModal(this.driver)
await debugModal.close()
}

async close(options?: { forceSaveState?: boolean }) {
if (!this.isOpened) return
console.log('Closing the app', this.buildSetup.dataDir)
if (options?.forceSaveState) {
await this.saveState() // Selenium creates community and closes app so fast that redux state may not be saved properly
await this.waitForSavedState()
Expand All @@ -33,6 +40,8 @@ export class App {
this.buildSetup.killNine()
await new Promise<void>(resolve => setTimeout(() => resolve(), 2000))
}
this.isOpened = false
console.log('App closed', this.buildSetup.dataDir)
}

get saveStateButton() {
Expand All @@ -59,12 +68,6 @@ export class StartingLoadingPanel {
get element() {
return this.driver.wait(until.elementLocated(By.xpath('//div[@data-testid="startingPanelComponent"]')))
}
// get element() {
// return this.driver.wait(until.elementLocated(By.xpath(`//span[text()="${this.text}"]`)))
// }
// get title() {
// return this.driver.findElement(By.xpath(`//span[text()="${this.text}"]`))
// }
}

export class WarningModal {
Expand Down Expand Up @@ -227,6 +230,19 @@ export class Channel {
return await messagesGroup.findElement(By.xpath('//p[@data-testid="/messagesGroupContent-/"]'))
}

async waitForUserMessage(username: string, messageContent: string) {
console.log(`Waiting for user "${username}" message "${messageContent}"`)
return this.driver.wait(async () => {
const messages = await this.getUserMessages(username)
const hasMessage = messages.find(async msg => {
const messageText = await msg.getText()
console.log(`got message "${messageText}"`)
return messageText.includes(messageContent)
})
return hasMessage
})
}

get getAllMessages() {
return this.driver.wait(until.elementsLocated(By.xpath('//*[contains(@data-testid, "userMessages-")]')))
}
Expand Down Expand Up @@ -256,6 +272,32 @@ export class Channel {
)
}

async getUserMessagesWrapper(username: string) {
return await this.driver.wait(
until.elementsLocated(By.xpath(`//*[contains(@data-testid, "userMessagesWrapper-${username}")]`))
)
}

async waitForLabel(username: string, label: string) {
console.log(`Waiting for user's "${username}" label "${label}" label`)
await this.driver.wait(async () => {
const labels = await this.driver.findElements(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`))
const properLabels = labels.filter(async labelElement => {
const labelText = await labelElement.getText()
return labelText === label
})
return properLabels.length > 0
})
}

async waitForLabelsNotPresent(username: string) {
leblowl marked this conversation as resolved.
Show resolved Hide resolved
console.log(`Waiting for user's "${username}" label to not be present`)
await this.driver.wait(async () => {
const labels = await this.driver.findElements(By.xpath(`//*[contains(@data-testid, "userLabel-${username}")]`))
return labels.length === 0
})
}

async getMessage(text: string) {
return await this.driver.wait(until.elementLocated(By.xpath(`//span[contains(text(),"${text}")]`)))
}
Expand Down Expand Up @@ -375,18 +417,27 @@ export class DebugModeModal {
}

get element() {
return this.driver.wait(until.elementLocated(By.xpath("//h3[text()='App is running in debug mode']")))
return this.driver.wait(until.elementLocated(By.xpath("//h3[text()='App is running in debug mode']")), 5000)
}

get button() {
return this.driver.wait(until.elementLocated(By.xpath("//button[text()='Understand']")))
return this.driver.wait(until.elementLocated(By.xpath("//button[text()='Understand']")), 5000)
}

async close() {
console.log('Closing debug modal')
await this.element.isDisplayed()
const button = await this.button
console.log('Debug modal title is displayed')
if (!process.env.TEST_MODE) return
let button
try {
console.log('Closing debug modal')
await this.element.isDisplayed()
console.log('Debug modal title is displayed')
button = await this.button
console.log('Debug modal button is displayed')
} catch (e) {
console.log('Debug modal might have been covered by "join community" modal', e.message)
return
}

await button.isDisplayed()
console.log('Button is displayed')
await button.click()
Expand Down
15 changes: 0 additions & 15 deletions packages/e2e-tests/src/tests/invitationLink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ describe('New user joins using invitation link while having app opened', () => {
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('JoinCommunityModal - owner switches to create community', async () => {
console.log('Invitation Link', 4)
const joinModal = new JoinCommunityModal(ownerApp.driver)
Expand Down Expand Up @@ -121,13 +113,6 @@ describe('New user joins using invitation link while having app opened', () => {
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.skip('Guest clicks invitation link with invalid invitation code', async () => {
// Fix when modals ordering is fixed (joining modal hiddes warning modal)
Expand Down
Loading
Loading