Skip to content

Commit

Permalink
Merge branch 'main' into overview-single-event-source
Browse files Browse the repository at this point in the history
  • Loading branch information
decleaver authored Nov 4, 2024
2 parents bc2efbe + 45b0041 commit 2f8e717
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 81 deletions.
8 changes: 4 additions & 4 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:local-auth": "playwright test tests/local-auth.spec.ts --config=playwright.config.local-auth.ts",
"test:reconnect": "playwright test tests/reconnect.spec.ts --config=playwright.reconnect.config.ts",
"test:e2e": "playwright test",
"test:e2e-in-cluster": "playwright test --config=playwright.config.in-cluster.ts",
"test:local-auth": "TEST_CFG=localAuth playwright test",
"test:reconnect": "TEST_CFG=reconnect playwright test",
"test:e2e": "TEST_CFG=default playwright test",
"test:e2e-in-cluster": "TEST_CFG=inCluster playwright test",
"test:install": "playwright install",
"test:unit": "vitest run"
},
Expand Down
21 changes: 0 additions & 21 deletions ui/playwright.config.in-cluster.ts

This file was deleted.

21 changes: 0 additions & 21 deletions ui/playwright.config.local-auth.ts

This file was deleted.

69 changes: 66 additions & 3 deletions ui/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// Copyright 2024 Defense Unicorns
// SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial

import { defineConfig } from '@playwright/test'
import { defineConfig, PlaywrightTestConfig } from '@playwright/test'
import { loadEnv } from 'vite'

const { VITE_PORT_ENV } = loadEnv('dev', process.cwd())

type TestConfig = keyof typeof configs
const TEST_CONFIG: TestConfig = (process.env.TEST_CFG as TestConfig) || 'default'

// use port 8443 because by default we use TLS when running locally
const port = VITE_PORT_ENV ?? '8443'
const protocol = 'https'
const host = 'runtime-local.uds.dev'

export default defineConfig({
// For all default E2E tests
const defaultConfig: PlaywrightTestConfig = {
name: 'default',
webServer: {
command: '../build/uds-runtime',
url: `${protocol}://${host}:${port}`,
Expand All @@ -27,6 +32,64 @@ export default defineConfig({
use: {
baseURL: `${protocol}://${host}:${port}/`,
},
})
}

// For testing reconnecting to the cluster
const reconnect: PlaywrightTestConfig = {
name: 'reconnect',
webServer: {
command: '../build/uds-runtime',
url: `${protocol}://${host}:${port}`,
reuseExistingServer: !process.env.CI,
env: { LOCAL_AUTH_ENABLED: 'false' },
},
timeout: 10 * 1000,
testDir: 'tests',
fullyParallel: false,
retries: process.env.CI ? 2 : 1,
testMatch: 'reconnect.spec.ts',
use: {
baseURL: `https://runtime-local.uds.dev:${port}/`,
},
}

// For testing local auth only
const localAuth: PlaywrightTestConfig = {
name: 'local-auth',
timeout: 60 * 1000,
testDir: 'tests',
fullyParallel: false,
retries: process.env.CI ? 2 : 1,
testMatch: 'local-auth.spec.ts',
use: {
baseURL: `https://runtime-local.uds.dev:${port}/`,
},
}

// For running E2E tests against Runtime in-cluster
const inCluster: PlaywrightTestConfig = {
name: 'in-cluster',
globalSetup: './tests/global-setup',
timeout: 10 * 1000,
testDir: 'tests',
/* Run tests in files in parallel */
fullyParallel: true,
retries: process.env.CI ? 2 : 1,
testMatch: /^(?!.*local-auth|.*reconnect)(.+\.)?(test|spec)\.[jt]s$/,
use: {
baseURL: `${protocol}://runtime.admin.uds.dev/`,
storageState: './tests/state.json',
},
}

// Use configs object for selecting desired config based on TEST_CONFIG, which is set by caller script in package.json
const configs = {
default: defaultConfig,
localAuth,
inCluster,
reconnect,
}

export default defineConfig({ ...configs[TEST_CONFIG] })

export { port }
31 changes: 0 additions & 31 deletions ui/playwright.reconnect.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion ui/src/lib/features/k8s/networks/gateways/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Resource extends VirtualService {
export type Columns = ColumnWrapper<Row>

export function createStore(): ResourceStoreInterface<Resource, Row> {
const url = `/api/v1/resources/networks/gateways?fields=.metadata.name,.metadata.namespace,.metadata.creationTimestamp,.spec.servers`
const url = `/api/v1/resources/networks/gateways?fields=.metadata,.spec.servers`

const transform = transformResource<Resource, Row>((r) => {
const hosts = r.spec?.servers?.map((gateway) => gateway.hosts[0])
Expand Down
14 changes: 14 additions & 0 deletions ui/src/lib/features/navigation/sidebar/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@
return route
})
}
// If link was clicked, updating url, but path is a child route that is currently not renendered
// we need to toggle the submenu to show the child route
function updateOnLinkClicks(path: string) {
for (const route of routes) {
if (path.includes(route.path) && !toggleSubmenus[route.path]) {
toggleSubmenus[route.path] = true
}
}
}
$: if ($page.url.pathname) {
updateOnLinkClicks($page.url.pathname)
}
</script>

<aside
Expand Down

0 comments on commit 2f8e717

Please sign in to comment.