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

Integration Tests #11186

Merged
merged 8 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Sandboxing tests and login
  • Loading branch information
farmaazon committed Sep 25, 2024
commit 5110167c8e07d7c93ffc8cec1e105b0d5f244eb8
9 changes: 4 additions & 5 deletions app/ide-desktop/client/src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,11 @@ declare global {
// @ts-expect-error The index signature is intentional to disallow unknown env vars.
readonly ENSO_SUPPORTS_VIBRANCY?: string

// === E2E test variables ===
// === Integration test variables ===

// @ts-expect-error The index signature is intentional to disallow unknown env vars.
readonly IS_IN_PLAYWRIGHT_TEST?: `${boolean}`
// @ts-expect-error The index signature is intentional to disallow unknown env vars.
readonly PWDEBUG?: '1'
readonly ENSO_TEST?: string
readonly ENSO_TEST_USER?: string
readonly ENSO_TEST_USER_PASSWORD?: string

// === Electron watch script variables ===

Expand Down
4 changes: 3 additions & 1 deletion app/ide-desktop/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class App {

/** Process the command line arguments. */
processArguments(args = fileAssociations.CLIENT_ARGUMENTS) {
logger.log('ARGS', args)
// We parse only "client arguments", so we don't have to worry about the Electron-Dev vs
// Electron-Proper distinction.
const fileToOpen = fileAssociations.argsDenoteFileOpenAttempt(args)
Expand Down Expand Up @@ -357,6 +356,9 @@ class App {
enableBlinkFeatures: argGroups.chrome.options.enableBlinkFeatures.value,
disableBlinkFeatures: argGroups.chrome.options.disableBlinkFeatures.value,
spellcheck: false,
...(process.env.ENSO_TEST != null && process.env.ENSO_TEST !== '' ?
{ partition: 'test' }
: {}),
}
const windowPreferences: electron.BrowserWindowConstructorOptions = {
webPreferences,
Expand Down
12 changes: 8 additions & 4 deletions app/ide-desktop/client/src/projectManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,15 @@ export function getProjectRoot(subtreePath: string): string | null {

/** Get the directory that stores Enso projects. */
export function getProjectsDirectory(): string {
const documentsPath = desktopEnvironment.DOCUMENTS
if (documentsPath === undefined) {
return pathModule.join(os.homedir(), 'enso', 'projects')
if (process.env.ENSO_TEST != null && process.env.ENSO_TEST !== '') {
return pathModule.join(os.tmpdir(), 'enso-test-projects', process.env.ENSO_TEST)
} else {
return pathModule.join(documentsPath, 'enso-projects')
const documentsPath = desktopEnvironment.DOCUMENTS
if (documentsPath === undefined) {
return pathModule.join(os.homedir(), 'enso', 'projects')
} else {
return pathModule.join(documentsPath, 'enso-projects')
}
}
}

Expand Down
16 changes: 15 additions & 1 deletion app/ide-desktop/client/tests/creatingNewProject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@ import { _electron, expect, test } from '@playwright/test'
test('Create new project', async () => {
const app = await _electron.launch({
executablePath: '../../../dist/ide/linux-unpacked/enso',
env: { ...process.env, ['ENSO_TEST']: 'Create new project' },
})
const page = await app.firstWindow()

// TODO Login?
await expect(page.getByRole('textbox', { name: 'email' })).toBeVisible()
await expect(page.getByRole('textbox', { name: 'password' })).toBeVisible()
await page.keyboard.insertText(process.env.ENSO_TEST_USER ?? '')
await page.keyboard.press('Tab')
await page.keyboard.insertText(process.env.ENSO_TEST_USER_PASSWORD ?? '')
await page.keyboard.press('Enter')

await expect(page.getByText('I agree')).toHaveCount(2)
await expect(page.getByRole('button')).toHaveCount(1)
for (const checkbox of await page.getByText('I agree').all()) {
await checkbox.click()
}
await page.getByRole('button').click()

await expect(page.getByRole('button', { name: 'New Project', exact: true })).toBeVisible()
await page.getByRole('button', { name: 'New Project', exact: true }).click()
await expect(page.locator('.GraphNode'), {}).toBeVisible({ timeout: 30000 })

Expand Down