Skip to content

Commit

Permalink
Add step decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
kravciak committed Nov 10, 2023
1 parent 14ba440 commit e106822
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/e2e/components/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,23 @@ export class Navigation {
// === Kubewarden specific navigation ===

// Policy Servers
@step
async pserver(name: string, tab?: 'Policies' | 'Metrics' | 'Tracing' | 'Conditions' | 'Recent Events' | 'Related Resources') {
await this.explorer('Kubewarden', 'PolicyServers')
await this.ui.getRow(name).open()
if (tab) await this.page.getByRole('tablist').locator(`li#${kwTabId[tab]}`).click()
}

// Cluster Admission Policies
@step
async capolicy(name: string, tab?: 'Rules' | 'Tracing' | 'Metrics' | 'Conditions' | 'Recent Events' | 'Related Resources') {
await this.explorer('Kubewarden', 'ClusterAdmissionPolicies')
await this.ui.getRow(name).open()
if (tab) await this.page.getByRole('tablist').locator(`li#${kwTabId[tab]}`).click()
}

// Admission Policies
@step
async apolicy(name: string, tab?: 'Rules' | 'Tracing' | 'Metrics' | 'Conditions' | 'Recent Events') {
await this.explorer('Kubewarden', 'AdmissionPolicies')
await this.ui.getRow(name).open()
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/components/rancher-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Locator, Page } from '@playwright/test'
import { expect, test } from '@playwright/test'
import jsyaml from 'js-yaml'
import _ from 'lodash'
import { step } from '../rancher-test'
import { TableRow } from './table-row'

export type YAMLPatch = { [key: string]: unknown } | string
Expand Down Expand Up @@ -88,6 +89,7 @@ export class RancherUI {
* await editYaml({ 'policyServer.telemetry.enabled' = false })
* await editYaml('{"policyServer": {"telemetry": { "enabled": false }}}')
*/
@step
async editYaml(patch: YAMLPatch) {
const cmEditor = this.page.locator('div.CodeMirror-lines[role="presentation"]')

Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/pages/rancher-apps.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Locator, Page } from '@playwright/test'
import { expect } from '@playwright/test'
import type { YAMLPatch } from '../components/rancher-ui'
import { step } from '../rancher-test'
import { BasePage } from './basepage'

export interface Chart {
Expand Down Expand Up @@ -38,6 +39,7 @@ export class RancherAppsPage extends BasePage {
* @param name
* @param url Git or http(s) url of the repository
*/
@step
async addRepository(name: string, url: string) {
await this.nav.explorer('Apps', 'Repositories')
await this.ui.button('Create').click()
Expand Down Expand Up @@ -81,6 +83,7 @@ export class RancherAppsPage extends BasePage {
}
}

@step
async installChart(chart: Chart, options?: { questions?: () => Promise<void>, yamlPatch?: YAMLPatch, timeout?: number, navigate?: boolean }) {
// Select chart by title
if (options?.navigate !== false) {
Expand Down Expand Up @@ -126,6 +129,7 @@ export class RancherAppsPage extends BasePage {
}

// Without parameters only for upgrade/reload
@step
async updateApp(name: string, options?: { questions?: () => Promise<void>, yamlPatch?: YAMLPatch, timeout?: number, navigate?: boolean }) {
if (options?.navigate !== false) {
await this.nav.explorer('Apps', 'Installed Apps')
Expand Down

0 comments on commit e106822

Please sign in to comment.