Skip to content

Commit

Permalink
redo PR based on previous PR 11626 and taking into account changes to…
Browse files Browse the repository at this point in the history
… the utils files + comment unwanted workflow runs
  • Loading branch information
aalves08 committed Aug 19, 2024
1 parent dc7784a commit 7c0eace
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: check-plugins-build
on:
pull_request:
branches:
- master
- master-banans
env:
TEST_PERSIST_BUILD: true
jobs:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docusaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master
# pull_request:
# branches:
# - master
jobs:
build:
name: Build
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/extensions-compatibility-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Extensions Compatibility Tests
on:
schedule:
- cron: "0 0 * * *" # runs at midnight every day
# TO DELETE!!!!!!!
pull_request:
branches:
- master

env:
TEST_USERNAME: admin
Expand All @@ -22,7 +26,8 @@ jobs:
{ username: 'admin', tag: '@adminUser' }
]
features: [
['@elemental', 'elemental']
['@elemental', 'elemental'],
# ['@kubewarden', 'kubewarden'],
]
rancherEnv: [
['2.10', 'v2.9-head'],
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/storybook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master
# pull_request:
# branches:
# - master
jobs:
storybook:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
branches:
- master
- 'release-*'
pull_request:
branches:
- master
- 'release-*'
# pull_request:
# branches:
# - master
# - 'release-*'
workflow_dispatch:
inputs:
environment:
Expand Down
6 changes: 4 additions & 2 deletions cypress/e2e/po/components/kubectl.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export default class Kubectl extends ComponentPo {
* @param command Kube command without the 'kubectl'
* @returns executeCommand for method chanining
*/
executeCommand(command: string, wait = 3000) {
this.self().get(this.terminalRow).type(`${ this.kubeCommand } ${ command }{enter}`);
executeCommand(command: string, prependKubectl = true, wait = 3000) {
const parsedCommand = prependKubectl ? `${ this.kubeCommand } ${ command }{enter}` : `${ command }{enter}`;

this.self().get(this.terminalRow).type(parsedCommand);
cy.wait(wait);

return this;
Expand Down
158 changes: 158 additions & 0 deletions cypress/e2e/po/extensions/kubewarden/kubewarden.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import ExtensionsCompatibilityUtils from '@/cypress/e2e/po/extensions/extensions-compatibility.utils';
import Kubectl from '~/cypress/e2e/po/components/kubectl.po';
import LabeledSelectPo from '@/cypress/e2e/po/components/labeled-select.po';
import SortableTablePo from '@/cypress/e2e/po/components/sortable-table.po';
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po';
import PagePo from '@/cypress/e2e/po/pages/page.po';

class KubewardenDashboardPagePo extends PagePo {
static url = '/c/local/kubewarden';
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(KubewardenDashboardPagePo.url);
}

constructor() {
super(KubewardenDashboardPagePo.url);
}

waitForTitlePreControllerInstall(): Cypress.Chainable {
return this.self().find('h1').should('contain', 'OS Management');
}

waitForTitleAfterControllerInstall(): Cypress.Chainable {
return this.self().find('[data-testid="kw-dashboard-title"]').should('contain', 'Welcome to Kubewardent');
}

startBackendInstallClick(): Cypress.Chainable {
return this.self().getId('kw-initial-install-button').click();
}

openTerminalClick() {
return this.self().getId('kw-cm-open-shell').click();
}

addKwRepoClick() {
return this.self().getId('kw-repo-add-button').click();
}

installOperatorBtnClick(): Cypress.Chainable {
return this.self().getId('kw-app-install-button').click();
}

defaultPolicyServerInstallClick() {
return this.self().getId('kw-defaults-banner-button').click();
}
}

class KubewardenPolicyServerListPagePo extends PagePo {
static url = '/c/local/kubewarden/policies.kubewarden.io.policyserver';
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(KubewardenPolicyServerListPagePo.url);
}

constructor() {
super(KubewardenPolicyServerListPagePo.url);
}
}

class KubewardenPolicyServerDetailPagePo extends PagePo {
static url = '/c/local/kubewarden/policies.kubewarden.io.policyserver';
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(KubewardenPolicyServerDetailPagePo.url);
}

constructor() {
super(KubewardenPolicyServerDetailPagePo.url);
}

metricsAddServiceMonitorClick() {
this.self().getId('kw-monitoring-checklist-step-service-monitor-button').click();
}

metricsAddGrafanaDasboardClick() {
this.self().getId('kw-monitoring-checklist-step-config-map-button').click();
}
}

class KubewardenAdmissionPoliciesListPagePo extends PagePo {
static url = '/c/local/kubewarden/policies.kubewarden.io.admissionpolicy';
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(KubewardenAdmissionPoliciesListPagePo.url);
}

constructor() {
super(KubewardenAdmissionPoliciesListPagePo.url);
}

addToArtifactHubClick() {
this.self().getId('action-button-async-button').click();
}

apOfficialPoliciesTable() {
return new SortableTablePo(this.self().get('.sortable-table'));
}

apOfficialPoliciesTableRowClick(policyName: string) {
this.apOfficialPoliciesTable().rowElementWithName(policyName).scrollIntoView().click();
}

apCreateBtn(): AsyncButtonPo {
return new AsyncButtonPo('[data-testid="kw-policy-create-finish-button"]', this.self());
}
}

export default class KubewardenPo extends ExtensionsCompatibilityUtils {
dashboard() {
return new KubewardenDashboardPagePo();
}

policyServerList() {
return new KubewardenPolicyServerListPagePo();
}

policyServerDetail() {
return new KubewardenPolicyServerDetailPagePo();
}

admissionPoliciesList() {
return new KubewardenAdmissionPoliciesListPagePo();
}

kubectlShell() {
return new Kubectl();
}

waitForCertManagerToInstall() {
return cy.get('[data-testid="kw-repo-add-button"]', { timeout: 30000 }).invoke('text').should('contain', 'Add Kubewarden Repository');
}

waitForKwRepoToBeAdded() {
return cy.get('[data-testid="kw-app-install-button"]', { timeout: 30000 }).invoke('text').should('contain', 'Install Kubewarden');
}

rancherMonitoringInstallIntoProjectSelect(optionIndex: number): Cypress.Chainable {
const selectProject = new LabeledSelectPo('.labeled-select.edit');

selectProject.toggle();

return selectProject.clickOption(optionIndex);
}

waitForNamespaceCreation(interceptName: string, namespaceToCheck: string) {
cy.wait(`@${ interceptName }`, { requestTimeout: 15000 }).then(({ response }) => {
expect(response?.statusCode).to.eq(201);
expect(response?.body.metadata).to.have.property('name', namespaceToCheck);
cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting
});
}

waitForApCreation(interceptName: string, name: string) {
cy.wait(`@${ interceptName }`, { requestTimeout: 15000 }).then(({ response }) => {
expect(response?.statusCode).to.eq(201);
expect(response?.body).to.have.property('id', `default/${ name }`);
expect(response?.body.spec).to.have.property('mode', 'protect');
expect(response?.body.spec.settings).to.have.property('requireTLS', true);
cy.wait(3000); // eslint-disable-line cypress/no-unnecessary-waiting
});
}
}
30 changes: 27 additions & 3 deletions cypress/e2e/po/pages/chart-installed-apps.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export default class ChartInstalledAppsPagePo extends PagePo {
return new ChartInstalledAppsListPo('[data-testid="installed-app-catalog-list"]');
}

waitForInstallCloseTerminal(interceptName: string, installableParts: Array<String>) {
cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201);
waitForInstallCloseTerminal(interceptName: string, installableParts: Array<String>, beforeTimeout = 15000, requestTimeout = 20000) {
cy.wait(`@${ interceptName }`, { requestTimeout }).its('response.statusCode').should('eq', 201);

// giving it a small buffer so that the install is properly triggered
cy.wait(15000); // eslint-disable-line cypress/no-unnecessary-waiting
cy.wait(beforeTimeout); // eslint-disable-line cypress/no-unnecessary-waiting
terminal.closeTerminal();

installableParts.forEach((item:string) => {
Expand All @@ -43,4 +43,28 @@ export default class ChartInstalledAppsPagePo extends PagePo {
// won't find the chart and show the correct screen
return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting
}

waitForUpgradeAndCloseTerminal(interceptName: string, beforeTimeout = 15000) {
cy.wait(`@${ interceptName }`, { requestTimeout: 20000 }).its('response.statusCode').should('eq', 201);

// giving it a small buffer so that the install is properly triggered
cy.wait(beforeTimeout); // eslint-disable-line cypress/no-unnecessary-waiting
terminal.closeTerminal();

cy.get('.masthead-state.badge-state').invoke('text').should('contain', 'Deployed'); // badge on masthead

// timeout to give time for everything to be setup, otherwise the extension
// won't find the chart and show the correct screen
return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting
}

waitForAppToInstall(appName: string, isTerminalOp = true) {
if (isTerminalOp) {
cy.wait(20000); // eslint-disable-line cypress/no-unnecessary-waiting
terminal.closeTerminal();
}
this.list().state(appName).should('contain', 'Deployed');

return cy.wait(10000); // eslint-disable-line cypress/no-unnecessary-waiting
}
}
5 changes: 5 additions & 0 deletions cypress/e2e/po/pages/explorer/charts/install-charts.po.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po';
import TabbedPo from '~/cypress/e2e/po/components/tabbed.po';
import CheckboxInputPo from '@/cypress/e2e/po/components/checkbox-input.po';

export class InstallChartPage extends PagePo {
private static createPath(clusterId: string) {
Expand All @@ -15,6 +16,10 @@ export class InstallChartPage extends PagePo {
super(InstallChartPage.createPath(clusterId));
}

getCheckboxByLabel(label: string): CheckboxInputPo {
return CheckboxInputPo.byLabel(this.self(), label);
}

waitForChartPage(repository: string, chart: string) {
return this.waitForPage(`repo-type=cluster&repo=${ repository }&chart=${ chart }`);
}
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/po/side-bars/product-side-nav.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ export default class ProductNavPo extends ComponentPo {
.click({ force: true });
}

/**
* Navigate to a side menu entry by label (exact match)
*/
navToSideMenuEntryByExactLabel(label: string): Cypress.Chainable {
const regexp = new RegExp(`^${ label }$`);

return this.self().should('exist').find('.child.nav-type a .label').contains(regexp)
.click({ force: true });
}

/**
* Check existence of menu group by label
*/
Expand Down
Loading

0 comments on commit 7c0eace

Please sign in to comment.