Skip to content

Commit

Permalink
add first test to run locally
Browse files Browse the repository at this point in the history
  • Loading branch information
mruoss committed Nov 9, 2023
1 parent 4e3260a commit fe94f0f
Show file tree
Hide file tree
Showing 19 changed files with 240 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LIVEBOOK_TOKEN_ENABLED=0
ERL_AFLAGS = "-kernel shell_history enabled"
3 changes: 0 additions & 3 deletions .envrc

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ kino_k8s-*.tar
*node_modules/*

*.livemd_files
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
3 changes: 1 addition & 2 deletions .rtx.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[env]
ERL_AFLAGS = "-kernel shell_history enabled"
env_file = '.env'

[tools]
erlang = "26.1.2"
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"playwright.env": {
"KUBECONTEXT": "kind-kino-k8s",
"KUBECONFIG": "~/.kube/config"
}
}
2 changes: 1 addition & 1 deletion assets/apply_cell/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const init = async (
ctx: KinoContext,
attrs: ApplyCellAttrs,
): Promise<void> => {
await loadReact(ctx, attrs)
await loadReact(ctx)

ctx.root.innerHTML = 'loading...'

Expand Down
2 changes: 1 addition & 1 deletion assets/connection_cell/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const init = async (
ctx: KinoContext,
attrs: ConnectionCellAttrs,
): Promise<void> => {
await loadReact(ctx, attrs)
await loadReact(ctx)

ctx.root.innerHTML = 'loading...'

Expand Down
2 changes: 1 addition & 1 deletion assets/get_cell/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const init = async (
ctx: KinoContext,
attrs: ListCellAttrs,
): Promise<void> => {
await loadReact(ctx, attrs)
await loadReact(ctx)

ctx.root.innerHTML = 'loading...'

Expand Down
3 changes: 3 additions & 0 deletions assets/shared/form/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ type InputProps = {
name: string
label: string
defaultValue: string
testId?: string
onChange: (value: string) => void
orientation?: 'horiz' | 'vert'
}
const Input: React.FC<InputProps> = ({
name,
label,
defaultValue,
testId,
onChange,
orientation = 'vert',
}) => {
Expand All @@ -34,6 +36,7 @@ const Input: React.FC<InputProps> = ({
</label>
<input
type="text"
data-testid={testId ?? name}
value={defaultValue}
name={name}
onChange={(e) => onChange(e.target.value)}
Expand Down
2 changes: 1 addition & 1 deletion assets/terminal_cell/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const init = async (
ctx: KinoContext,
attrs: TerminalCellAttrs,
): Promise<void> => {
await loadReact(ctx, attrs)
await loadReact(ctx)

ctx.root.innerHTML = 'loading...'

Expand Down
36 changes: 36 additions & 0 deletions e2e/kino_k8s/connection_cell.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { expect, test } from '@playwright/test'

test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:8080/new')

await page.getByText('Notebook dependencies and setup').click()
await page
.locator('#cell-editor-setup-primary')
.getByRole('textbox')
.fill(`Mix.install([{:kino_k8s, path: "${process.cwd()}"}])`)

await page.getByRole('button', { name: 'Reconnect and setup' }).click()
await expect(page.locator('#outputs-setup-2')).toHaveText(/:ok/)

const smart = page
.locator('section')
.first()
.getByRole('button', { name: '+ Smart' })
.first()
await smart.click()
await page.getByRole('menuitem', { name: 'K8s - Cluster Connection' }).click()
})

test.describe('File', () => {
test('loads from local file', async ({ page }) => {
const cell = page.locator('[data-smart-cell-js-view-ref]').first()
const iframe = page.frameLocator('iframe').first()
await iframe.getByTestId('source').fill(process.env.KUBECONFIG!)
await iframe.getByTestId('context').fill(process.env.KUBECONTEXT!)
await cell.locator('button[data-el-queue-cell-evaluation-button]').click()

const result = page.frameLocator('iframe').nth(1).locator('body')
await expect(result).toHaveText(/%K8s.Conn/)
await expect(result).toHaveText(/K8s.Conn.Auth.Certificate/)
})
})
2 changes: 1 addition & 1 deletion lib/assets/apply_cell/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fe94f0f

Please sign in to comment.