Skip to content

Commit 6929c10

Browse files
max-nextcloudsusnux
authored andcommitted
feat: expose user in random-user-fixture
Signed-off-by: Max <max@nextcloud.com>
1 parent 91f24c4 commit 6929c10

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

playwright/e2e/random-user.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ test.beforeEach(async ({ page }) => {
1111
await page.waitForURL(/apps\/files/)
1212
})
1313

14-
test('Random user is authenticated', async ({ page }) => {
14+
test('Random user is authenticated', async ({ page, user }) => {
1515
await expect(page.getByLabel('Settings menu')).toBeVisible()
16+
expect(user.userId).toEqual(user.password)
1617
})

playwright/support/fixtures/random-user.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@
66
import { test as base } from '@playwright/test'
77
import { createRandomUser, login } from '../utils/session'
88

9+
interface RandomUserFixture {
10+
user: User
11+
}
12+
913
/**
1014
* This test fixture ensures a new random user is created and used for the test (current page)
1115
*/
12-
export const test = base.extend({
13-
page: async ({ browser, baseURL }, use) => {
16+
export const test = base.extend<RandomUserFixture>({
17+
user: async ({ }, use) => {
18+
const user = await createRandomUser()
19+
await use(user)
20+
},
21+
page: async ({ browser, baseURL, user }, use) => {
1422
// Important: make sure we authenticate in a clean environment by unsetting storage state.
1523
const page = await browser.newPage({
1624
storageState: undefined,
1725
baseURL,
1826
})
1927

20-
const user = await createRandomUser()
2128
await login(page.request, user)
2229

2330
await use(page)

0 commit comments

Comments
 (0)