mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-10 08:07:03 +00:00
global setup login
This commit is contained in:
@@ -24,3 +24,4 @@ src/lib/components/copilot/chat/__tests__/app/results/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
/playwright/.auth/
|
||||
e2e/auth.json
|
||||
@@ -0,0 +1,6 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
|
||||
test('has Home text', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
await expect(page.locator('text=Home').first()).toBeVisible()
|
||||
})
|
||||
@@ -1,7 +1,14 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
// global-setup.ts
|
||||
import { chromium, FullConfig } from '@playwright/test'
|
||||
|
||||
test('log in correctly', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
async function globalSetup(config: FullConfig) {
|
||||
const browser = await chromium.launch()
|
||||
const context = await browser.newContext()
|
||||
const page = await context.newPage()
|
||||
|
||||
// Use baseURL from config
|
||||
const baseURL = config.projects[0].use.baseURL || 'http://localhost:3000'
|
||||
await page.goto(baseURL)
|
||||
|
||||
// Wait for and fill the email input
|
||||
const emailInput = page.locator('input#email[type="email"]')
|
||||
@@ -13,10 +20,6 @@ test('log in correctly', async ({ page }) => {
|
||||
await passwordInput.waitFor({ state: 'visible' })
|
||||
await passwordInput.fill('changeme')
|
||||
|
||||
// Verify the inputs are filled correctly
|
||||
await expect(emailInput).toHaveValue('admin@windmill.dev')
|
||||
await expect(passwordInput).toHaveValue('changeme')
|
||||
|
||||
// Click the sign-in button
|
||||
const signInButton = page.locator('button:has-text("Sign in")')
|
||||
await signInButton.click()
|
||||
@@ -30,17 +33,19 @@ test('log in correctly', async ({ page }) => {
|
||||
|
||||
// Wait for navigation to workspaces page
|
||||
await page.waitForURL('**/user/workspaces')
|
||||
await expect(page).toHaveURL(/\/user\/workspaces$/)
|
||||
|
||||
// Click on the "Admins" workspace
|
||||
const adminsWorkspace = page.locator('text=Admins').first()
|
||||
await adminsWorkspace.waitFor({ state: 'visible' })
|
||||
await adminsWorkspace.click()
|
||||
|
||||
// Verify we're on the root path of the workspace
|
||||
// Wait for workspace to load
|
||||
await page.waitForURL('**/')
|
||||
await expect(page).toHaveURL(/\/$/)
|
||||
await page.locator('text=Home').first().waitFor({ state: 'visible' })
|
||||
|
||||
// Wait for the page to load and verify it contains "Home"
|
||||
await expect(page.locator('text=Home').first()).toBeVisible()
|
||||
})
|
||||
// Save the authenticated state
|
||||
await context.storageState({ path: './e2e/auth.json' })
|
||||
await browser.close()
|
||||
}
|
||||
|
||||
export default globalSetup
|
||||
@@ -12,6 +12,7 @@ import { defineConfig, devices } from '@playwright/test'
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
export default defineConfig({
|
||||
globalSetup: './e2e/global-setup',
|
||||
testDir: './e2e',
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
@@ -29,7 +30,9 @@ export default defineConfig({
|
||||
baseURL: process.env.BASE_URL || 'http://localhost:3000',
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry'
|
||||
trace: 'on-first-retry',
|
||||
|
||||
storageState: './e2e/auth.json'
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
|
||||
Reference in New Issue
Block a user