-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(integration): add cases for joining a community
This change adds test cases for joining a community. It includes a failing case for existing members who still see the button to join. Refs #388, #431
- Loading branch information
1 parent
fa31ef1
commit 1b545a5
Showing
5 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { expect, test } from './test'; | ||
import { screenshot } from './utils'; | ||
|
||
test.asALoggedInUser('can join a community', async ({ community, page }) => { | ||
await page.goto(`/communities/${community.slug}`); | ||
|
||
const joinButton = page.locator('button:has-text("Join community")'); | ||
|
||
await expect(joinButton).toBeVisible(); | ||
expect(await screenshot(page, joinButton)).toMatchSnapshot('join-button.png'); | ||
|
||
page.on('dialog', async (dialog) => await dialog.dismiss()); | ||
const [joinDialog] = await Promise.all([ | ||
page.waitForEvent('dialog'), | ||
joinButton.click(), | ||
]); | ||
|
||
await expect(joinDialog.message()).toContain( | ||
`Thanks for your request to join ${community.name}`, | ||
); | ||
}); | ||
|
||
test.asAReturningUser( | ||
'have to log in with ORCID', | ||
async ({ community, page }) => { | ||
await page.goto(`/communities/${community.slug}`); | ||
|
||
await page.click('button:has-text("Join community")'); | ||
|
||
const dialog = page.locator('[role="dialog"]'); | ||
|
||
await expect(dialog).toContainText('You must be logged in'); | ||
expect(await screenshot(dialog)).toMatchSnapshot('log-in.png'); | ||
}, | ||
); | ||
|
||
test.asACommunityMember( | ||
'cannot join a community', | ||
async ({ community, page }, { fixme }) => { | ||
await page.goto(`/communities/${community.slug}`); | ||
|
||
const joinButton = page.locator('button:has-text("Join community")'); | ||
|
||
await expect(page.locator('body')).toContainText(community.name); | ||
|
||
fixme(true, '"Join community" button is still shown to members'); | ||
|
||
await expect(joinButton).not.toBeVisible(); | ||
}, | ||
); |
3 changes: 3 additions & 0 deletions
3
...c/browser/join-community.spec.ts-snapshots/join-button-Desktop-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...on/src/browser/join-community.spec.ts-snapshots/join-button-iPhone-11-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...on/src/browser/join-community.spec.ts-snapshots/log-in-Desktop-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...gration/src/browser/join-community.spec.ts-snapshots/log-in-iPhone-11-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.