Skip to content

Commit

Permalink
Fix tests for Vue3 compliance
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kravec <kravciak@gmail.com>
  • Loading branch information
kravciak committed Nov 5, 2024
1 parent f32a702 commit 5c6a2e1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
rancher: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_run') && fromJSON('["2.7", "2.8", "2.9"]') || fromJSON(format('["{0}"]', inputs.rancher || 'released')) }}
mode: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_run') && fromJSON('["base", "upgrade", "fleet"]') || fromJSON(format('["{0}"]', inputs.mode || 'base')) }}
exclude:
# Run full tests on 2.8 since it's latest prime version
# Run full tests on 2.9 since it's latest prime version
- rancher: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_run') && '2.7' }}
mode: upgrade
- rancher: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_run') && '2.7' }}
Expand Down Expand Up @@ -220,20 +220,15 @@ jobs:
# Setup playwright ENV and run tests
# https://rancher.github.io/dashboard/testing/e2e-test#setup-for-local-tests
- uses: actions/setup-node@v4
if: env.KUBEWARDEN == 'source'
with:
node-version: '16'
node-version: '20'

- name: Build Kubewarden extension
if: env.KUBEWARDEN == 'source'
run: |
yarn install --ignore-engines
VERSION=0.0.1 yarn build-pkg kubewarden
- uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install playwright
working-directory: tests
run: |
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/00-installation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ test('Install Kubewarden', async({ page, ui, nav }) => {
await expect(page.getByRole('heading', { name: 'Welcome to Kubewarden' })).toBeVisible()
}, 'Kubewarden installation not detected')

// Workaround for issues#938: Both singular & plural resource names in menu
await page.reload()

await test.step('Install default policyserver', async() => {
const psPage = new PolicyServersPage(page)

Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/10-landing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ test('Brief check of landing pages', async({ page, ui, nav }) => {
await expect(head.getByText(/App Version:\s+v[1-9][0-9.]+[0-9]/)).toBeVisible()

// Recommended policies stats
await expect1m(page.getByText('Active 1 of 1 Pods / 100%')).toBeVisible()
await expect1m(page.getByText('Active 0 of 0 Namespaced Policies / 0%')).toBeVisible()
await expect1m(page.getByText('Active 6 of 6 Global Policies / 100%')).toBeVisible()
await expect1m(page.getByText('Active1 of 1 Pods / 100%')).toBeVisible()
await expect1m(page.getByText('Active0 of 0 Namespaced Policies / 0%')).toBeVisible()
await expect1m(page.getByText('Active6 of 6 Global Policies / 100%')).toBeVisible()
})

await test.step('Policy Servers Landing Page', async() => {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/60-telemetry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ test.describe('Tracing', () => {

await telPage.toBeIncomplete('config')
await telPage.configBtn.click()
const now = new Date().toISOString()
await apps.updateApp('rancher-kubewarden-controller', {
navigate : false,
questions: async() => {
Expand All @@ -88,7 +89,6 @@ test.describe('Tracing', () => {
}
})
// Wait until kubewarden controller restarts policyserver
const now = new Date().toISOString()
await shell.retry(`kubectl logs -l app=kubewarden-policy-server-default -n cattle-kubewarden-system -c otc-container --since-time ${now} | grep -F "Everything is ready."`)
})

Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/components/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export class Navigation {
async explorer<T extends ExpGroup>(groupName: T, childName?: ExpItemMap[T]) {
if (this.isblank()) await this.cluster()
await this.sideNavHandler(groupName, childName)
// Wait for child page before next step
if (groupName == 'Kubewarden' && childName && childName != 'Policy Reporter') {
await expect(this.page.getByRole('heading', { name: childName })).toBeVisible()
}
}

// Wrapper for page.goto using default cluster
Expand Down Expand Up @@ -118,7 +122,7 @@ export class Navigation {
await this.explorer('Kubewarden', 'PolicyServers')
if (name) {
await this.ui.tableRow(name).open()
await expect(this.page.getByTestId('kw-ps-detail-status-title')).toBeVisible()
await expect(this.page.getByRole('heading', { name: `PolicyServer: ${name}` })).toBeVisible()
}
if (tab) await this.ui.tab(tab).click()
}
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/components/rancher-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ export class RancherUI {
}

static isVersion(query: string|Range): boolean {
// Convert v2.10-6e85a811efd6b831c3d49a7336a6d4b3e96c1a93-head -> v2.10.0-head
const version = this.requireEnv('RANCHER_VERSION').replace(/-[a-f0-9]{40}/, '.0')
if (!semver.validRange(query)) throw new Error(`Invalid range: ${query}`)
return semver.satisfies(this.requireEnv('RANCHER_VERSION'), query, { includePrerelease: true })
return semver.satisfies(version, query, { includePrerelease: true })
}

static get hasAppCollection(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/pages/policyservers.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export class PolicyServersPage extends BasePage {
}

async goto(): Promise<void> {
// await this.nav.explorer('Kubewarden', 'PolicyServers')
await this.nav.goto('dashboard/c/local/kubewarden/policies.kubewarden.io.policyserver')
await this.nav.explorer('Kubewarden', 'PolicyServers')
// await this.nav.goto('dashboard/c/local/kubewarden/policies.kubewarden.io.policyserver')
}

async setName(name: string) {
Expand Down

0 comments on commit 5c6a2e1

Please sign in to comment.