diff --git a/src/internal/api/packages/find.go b/src/internal/api/packages/find.go index 01bbee296c..697c99b36c 100644 --- a/src/internal/api/packages/find.go +++ b/src/internal/api/packages/find.go @@ -16,7 +16,7 @@ import ( "github.com/defenseunicorns/zarf/src/pkg/message" ) -var packagePattern = regexp.MustCompile(`zarf-package.+\.tar\.zst$`) +var packagePattern = regexp.MustCompile(`zarf-package.*.tar\.zst$`) var initPattern = regexp.MustCompile(`(?i).*init.*\.tar\.zst$`) // Find returns all packages anywhere down the directory tree of the working directory. @@ -73,7 +73,7 @@ func recursiveFileListSkipPermissionErrors(dir string, pattern *regexp.Regexp) ( if !d.IsDir() { if pattern != nil { - if len(pattern.FindStringIndex(path)) > 0 { + if pattern.MatchString(d.Name()) { files = append(files, path) } } else { diff --git a/src/test/ui/01_start_page.spec.ts b/src/test/ui/01_start_page.spec.ts index eca1489926..21ab518595 100644 --- a/src/test/ui/01_start_page.spec.ts +++ b/src/test/ui/01_start_page.spec.ts @@ -4,43 +4,48 @@ test.beforeEach(async ({ page }) => { page.on('pageerror', (err) => console.log(err.message)); }); -test.describe.skip('start page', () => { - test('spinner loads properly, then displays init btn @pre-init', async ({ page }) => { - await page.goto('/auth?token=insecure'); +test.describe('Landing Page', () => { + test('Connect cluster @pre-init', async ({ page }) => { + await page.goto('/auth?token=insecure', { waitUntil: 'networkidle' }); - const clusterSelector = page.locator('#cluster-selector'); - await expect(clusterSelector).toBeEmpty(); + // Expect cluster table to display not connected state + const clusterInfo = page.locator('.cluster-not-connected'); + expect(await clusterInfo.textContent()).toContain('Cluster not connected'); - // display loading spinner - const spinner = page.locator('.spinner'); - await expect(spinner).toBeVisible(); + // Expect navdrawer cluster state to display not connected + const navDrawerHeader = page.locator('.nav-drawer-header'); + expect(await navDrawerHeader.textContent()).toContain('Cluster not connected'); - // spinner disappears, init btn appears - await expect(spinner).not.toBeVisible(); + // Expect the Packages Table to contain no packages + const packageTableBody = page.locator('.package-list-body'); + expect(await packageTableBody.textContent()).toContain('No Packages have been Deployed'); - // Make sure the home page contents are there - await expect(page.locator('text=No Active Zarf Clusters')).toBeVisible(); - await expect( - page.locator( - '.hero-subtitle:has-text("cluster was found, click initialize cluster to initialize it now with Zarf")' - ) - ).toBeVisible(); + // Open Connect Cluster Dialog + const connectClusterButton = page.locator('button:has-text("Connect Cluster")'); + await connectClusterButton.click(); - await page.locator('span:has-text("Initialize Cluster")').click(); + // Ensure Kubeconfig is found + const kubeconfigDialog = page.locator('.dialog-content'); + expect(await kubeconfigDialog.textContent()).toContain('Kubeconfig Found'); - await page.waitForURL('/package/init/configure'); + // Click Connect Cluster Anchor in the dialog to goto /packages?init=true + const connectAnchor = kubeconfigDialog.locator('a:has-text("Connect Cluster")'); + await connectAnchor.click(); + + await page.waitForURL('/packages?init=true'); }); - test('page redirects to /packages @post-init', async ({ page }) => { - await page.goto('/auth?token=insecure'); - // display loading spinner - const spinner = page.locator('.spinner'); - await expect(spinner).toBeVisible(); + // test('page redirects to /packages @post-init', async ({ page }) => { + // await page.goto('/auth?token=insecure'); - // spinner disappears - await expect(spinner).not.toBeVisible(); + // // display loading spinner + // const spinner = page.locator('.spinner'); + // await expect(spinner).toBeVisible(); - // expect to be redirected to /packages - await page.waitForURL('/packages', { timeout: 10000 }); - }); + // // spinner disappears + // await expect(spinner).not.toBeVisible(); + + // // expect to be redirected to /packages + // await page.waitForURL('/packages', { timeout: 10000 }); + // }); }); diff --git a/src/ui/lib/components/local-package-table.svelte b/src/ui/lib/components/local-package-table.svelte index 1fd74cc7f6..b81e01c4c7 100644 --- a/src/ui/lib/components/local-package-table.svelte +++ b/src/ui/lib/components/local-package-table.svelte @@ -11,7 +11,7 @@ const initPkg = $page.url.searchParams.get('init'); async function readPackages(): Promise { - const paths = initPkg ? await Packages.findInit() : await Packages.find(); + const paths = initPkg ? await Packages.findInit() : await Packages.findInHome(); const packages = paths.map((p) => Packages.read(p)); return Promise.all(packages); } diff --git a/src/ui/lib/components/nav-drawer.svelte b/src/ui/lib/components/nav-drawer.svelte index 987f8f7771..d957e14b04 100644 --- a/src/ui/lib/components/nav-drawer.svelte +++ b/src/ui/lib/components/nav-drawer.svelte @@ -25,6 +25,12 @@ '& .inset-shadow': { boxShadow: 'inset 0px -1px 0px rgba(255, 255, 255, 0.12)', }, + '& .nav-drawer-header': { + display: 'flex', + flexDirection: 'column', + gap: '4px', + padding: '0px 1rem', + }, }, }; @@ -34,19 +40,18 @@ - + Cluster {#if $clusterStore?.hasZarf && $clusterStore?.rawConfig} - {$clusterStore.rawConfig['current-context']} + + {$clusterStore.rawConfig['current-context']} + {:else} warning