Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automation: fix flaky tests based on jenkins failures #13131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cypress/e2e/po/pages/extensions.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RepositoriesPagePo from '@/cypress/e2e/po/pages/chart-repositories.po';
import BannersPo from '@/cypress/e2e/po/components/banners.po';
import ChartRepositoriesCreateEditPo from '@/cypress/e2e/po/edit/chart-repositories.po';
import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po';
import { LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';
import { LONG_TIMEOUT_OPT, MEDIUM_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';

export default class ExtensionsPagePo extends PagePo {
static url = '/c/local/uiplugins'
Expand All @@ -34,7 +34,7 @@ export default class ExtensionsPagePo extends PagePo {
return this.title().should('contain', 'Extensions');
}

loading() {
loading(options: any) {
return this.self().get('.data-loading');
}

Expand All @@ -50,12 +50,16 @@ export default class ExtensionsPagePo extends PagePo {
* @returns {Cypress.Chainable}
*/
addExtensionsRepository(repo: string, branch: string, name: string): Cypress.Chainable {
cy.intercept('GET', '/v1/catalog.cattle.io.clusterrepos?exclude=metadata.managedFields').as('getRepos');

// we should be on the extensions page
this.waitForPage();
this.waitForPage(null, 'available');
this.loading(MEDIUM_TIMEOUT_OPT).should('not.exist');

// go to app repos
this.extensionMenuToggle();
this.manageReposClick();
cy.wait('@getRepos').its('response.statusCode').should('eq', 200);

// create a new clusterrepo
const appRepoList = new RepositoriesPagePo('local', 'apps');
Expand All @@ -82,6 +86,8 @@ export default class ExtensionsPagePo extends PagePo {

appRepoList.waitForPage();
appRepoList.list().state(name).should('contain', 'Active');

return cy.wrap(appRepoList.list());
}

/**
Expand Down
12 changes: 10 additions & 2 deletions cypress/e2e/tests/pages/explorer/apps/charts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const chartsPage = new ChartsPage();

describe('Apps/Charts', { tags: ['@explorer', '@adminUser'] }, () => {
beforeEach(() => {
cy.intercept('GET', '/v1/catalog.cattle.io.clusterrepos/**').as('fetchChartData');

cy.login();
chartsPage.goTo();
chartsPage.waitForPage();
Expand Down Expand Up @@ -94,6 +96,9 @@ describe('Apps/Charts', { tags: ['@explorer', '@adminUser'] }, () => {
it('should call fetch when route query changes with valid parameters', () => {
const chartName = 'Logging';

cy.wait('@fetchChartData');
cy.get('@fetchChartData.all').should('have.length.at.least', 3);

chartsPage.getChartByName(chartName)
.should('exist')
.scrollIntoView()
Expand All @@ -105,16 +110,19 @@ describe('Apps/Charts', { tags: ['@explorer', '@adminUser'] }, () => {
chartPage.waitForPage();

// Set up intercept for the network request triggered by $fetch
cy.intercept('GET', '**/v1/catalog.cattle.io.clusterrepos/**').as('fetchChartData');
cy.intercept('GET', '**/v1/catalog.cattle.io.clusterrepos/**').as('fetchChartDataAfterSelect');

chartPage.selectVersion('103.1.1+up4.4.0');

cy.wait('@fetchChartData').its('response.statusCode').should('eq', 200);
cy.wait('@fetchChartDataAfterSelect').its('response.statusCode').should('eq', 200);
});

it('should not call fetch when navigating back to charts page', () => {
const chartName = 'Logging';

cy.wait('@fetchChartData');
cy.get('@fetchChartData.all').should('have.length.at.least', 3);

chartsPage.getChartByName(chartName)
.should('exist')
.scrollIntoView()
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/tests/pages/explorer/apps/repositories.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('Apps', () => {
cy.intercept('GET', '/v1/catalog.cattle.io.clusterrepos/rancher-charts?*').as('rancherCharts1');

// Nav to a summary page for a specific chart
ChartsPage.navTo(clusterId);
chartsPage.goTo();
chartsPage.chartsFilterCategoriesSelect().toggle();
chartsPage.chartsFilterCategoriesSelect().clickOptionWithLabel('All Categories');
chartsPage.chartsFilterReposSelect().toggle();
Expand Down
17 changes: 16 additions & 1 deletion cypress/e2e/tests/pages/extensions/extensions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.

const namespaceFilter = new NamespaceFilterPo();
const cluster = 'local';
let removeExtensions = false;

const DISABLED_CACHE_EXTENSION_NAME = 'large-extension';
// const DISABLED_CACHE_EXTENSION_MENU_LABEL = 'Large-extension';
Expand All @@ -16,6 +17,7 @@ const UNAUTHENTICATED_EXTENSION_NAME = 'uk-locale';
const EXTENSION_NAME = 'clock';
const UI_PLUGINS_PARTNERS_REPO_URL = 'https://github.com/rancher/partner-extensions';
const UI_PLUGINS_PARTNERS_REPO_NAME = 'partner-extensions';
const GIT_REPO_NAME = 'rancher-plugin-examples';

describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
beforeEach(() => {
Expand Down Expand Up @@ -69,7 +71,9 @@ describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
extensionsPo.extensionTabInstalledClick(); // Avoid nav guard failures that probably auto move user to this tab

// install the rancher plugin examples
extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-examples', 'main', 'rancher-plugin-examples');
extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-examples', 'main', GIT_REPO_NAME).then(() => {
removeExtensions = true;
});
});

it('has the correct title for Prime users and should display banner on main extensions screen EVEN IF setting is empty string', () => {
Expand Down Expand Up @@ -253,9 +257,11 @@ describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
});

it('Should install an extension', () => {
cy.intercept('POST', `/v1/catalog.cattle.io.clusterrepos/${ GIT_REPO_NAME }?action=install`).as('installExtension');
const extensionsPo = new ExtensionsPagePo();

extensionsPo.goTo();
extensionsPo.waitForPage();

extensionsPo.extensionTabAvailableClick();
extensionsPo.waitForPage(null, 'available');
Expand All @@ -267,6 +273,7 @@ describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
// select version and click install
extensionsPo.installModalSelectVersionClick(2);
extensionsPo.installModalInstallClick();
cy.wait('@installExtension').its('response.statusCode').should('eq', 201);

// let's check the extension reload banner and reload the page
extensionsPo.extensionReloadBanner().should('be.visible');
Expand Down Expand Up @@ -297,6 +304,7 @@ describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
});

it('Should update an extension version', () => {
cy.intercept('POST', `/v1/catalog.cattle.io.clusterrepos/${ GIT_REPO_NAME }?action=upgrade`).as('upgradeExtension');
const extensionsPo = new ExtensionsPagePo();

extensionsPo.goTo();
Expand All @@ -308,6 +316,7 @@ describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
// click on update button on card
extensionsPo.extensionCardUpdateClick(EXTENSION_NAME);
extensionsPo.installModalInstallClick();
cy.wait('@upgradeExtension').its('response.statusCode').should('eq', 201);

// let's check the extension reload banner and reload the page
extensionsPo.extensionReloadBanner().should('be.visible');
Expand Down Expand Up @@ -515,4 +524,10 @@ describe('Extensions page', { tags: ['@extensions', '@adminUser'] }, () => {
extensionsPo.extensionCardClick(DISABLED_CACHE_EXTENSION_NAME);
extensionsPo.extensionDetailsTitle().should('contain', DISABLED_CACHE_EXTENSION_NAME);
});

after(() => {
if ( removeExtensions ) {
cy.deleteRancherResource('v1', 'catalog.cattle.io.clusterrepos', GIT_REPO_NAME);
}
});
});
15 changes: 13 additions & 2 deletions cypress/e2e/tests/pages/extensions/kubewarden.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import KubewardenExtensionPo from '@/cypress/e2e/po/pages/extensions/kubewarden.
import { catchTargetPageException } from '@/cypress/support/utils/exception-utils';

const extensionName = 'kubewarden';
const gitRepoName = 'rancher-extensions';
let removeExtensions = false;

describe('Kubewarden Extension', { tags: ['@extensions-temp-excluded', '@adminUser'] }, () => {
describe('Kubewarden Extension', { tags: ['@extensions', '@adminUser'] }, () => {
before(() => {
catchTargetPageException('Navigation cancelled');
cy.login();
Expand All @@ -18,7 +20,9 @@ describe('Kubewarden Extension', { tags: ['@extensions-temp-excluded', '@adminUs
extensionsPo.waitForPage();

// install the ui-plugin-charts repo
extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', 'rancher-extensions');
extensionsPo.addExtensionsRepository('https://github.com/rancher/ui-plugin-charts', 'main', gitRepoName).then(() => {
removeExtensions = true;
});
});

beforeEach(() => {
Expand All @@ -32,6 +36,7 @@ describe('Kubewarden Extension', { tags: ['@extensions-temp-excluded', '@adminUs
extensionsPo.waitForPage();

extensionsPo.extensionTabAvailableClick();
extensionsPo.waitForPage(null, 'available');

// click on install button on card
extensionsPo.extensionCardInstallClick(extensionName);
Expand Down Expand Up @@ -110,4 +115,10 @@ describe('Kubewarden Extension', { tags: ['@extensions-temp-excluded', '@adminUs
extensionsPo.extensionCardClick(extensionName);
extensionsPo.extensionDetailsTitle().should('contain', extensionName);
});

after(() => {
if ( removeExtensions ) {
cy.deleteRancherResource('v1', 'catalog.cattle.io.clusterrepos', gitRepoName);
}
});
});
Loading