From d6c2c94533636397fdce31650202891f7cb17ad1 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Thu, 11 Apr 2024 12:52:18 -0700 Subject: [PATCH 1/6] add waits to namespace-picker and gitrepo tests --- .../tests/pages/explorer/namespace-picker.spec.ts | 3 +++ cypress/e2e/tests/pages/fleet/gitrepo.spec.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts index cce23e6d0b0..846a3d74fc7 100644 --- a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts +++ b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts @@ -35,8 +35,11 @@ describe('Namespace picker', { testIsolation: 'off' }, () => { const workloadsPodPage = new WorkloadsPodsListPagePo('local'); + cy.intercept('GET', '/v1/pods?exclude=metadata.managedFields').as('getPods'); + WorkloadsPodsListPagePo.navTo(); workloadsPodPage.waitForPage(); + cy.wait('@getPods'); // Filter by Namespace: Select 'cattle-fleet-local-system' namespacePicker.toggle(); diff --git a/cypress/e2e/tests/pages/fleet/gitrepo.spec.ts b/cypress/e2e/tests/pages/fleet/gitrepo.spec.ts index 7d05da3e697..f64bbb5db2f 100644 --- a/cypress/e2e/tests/pages/fleet/gitrepo.spec.ts +++ b/cypress/e2e/tests/pages/fleet/gitrepo.spec.ts @@ -79,7 +79,13 @@ describe('Git Repo', { tags: ['@fleet', '@adminUser'] }, () => { prefPage.languageDropdownMenu().checkVisible(); prefPage.languageDropdownMenu().toggle(); prefPage.languageDropdownMenu().isOpened(); + + cy.intercept('PUT', 'v1/userpreferences/*').as(`prefUpdateZhHans`); prefPage.languageDropdownMenu().clickOption(2); + cy.wait('@prefUpdateZhHans').then(({ response }) => { + expect(response?.statusCode).to.eq(200); + expect(response?.body.data).to.have.property('locale', 'zh-hans'); + }); prefPage.languageDropdownMenu().isClosed(); listPage.goTo(); @@ -100,7 +106,13 @@ describe('Git Repo', { tags: ['@fleet', '@adminUser'] }, () => { prefPage.languageDropdownMenu().checkVisible(); prefPage.languageDropdownMenu().toggle(); prefPage.languageDropdownMenu().isOpened(); + + cy.intercept('PUT', 'v1/userpreferences/*').as(`prefUpdateEnUs`); prefPage.languageDropdownMenu().clickOption(1); + cy.wait('@prefUpdateEnUs').then(({ response }) => { + expect(response?.statusCode).to.eq(200); + expect(response?.body.data).to.have.property('locale', 'en-us'); + }); prefPage.languageDropdownMenu().isClosed(); const fleetDashboardPage = new FleetDashboardPagePo('_'); From 498f0ead52ed014fc8e5bed5cabbe975951b6220 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Thu, 11 Apr 2024 12:54:02 -0700 Subject: [PATCH 2/6] disable retries --- cypress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.config.ts b/cypress.config.ts index f3b1cb717f4..e8eacf2db6e 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -59,7 +59,7 @@ export default defineConfig({ trashAssetsBeforeRuns: true, chromeWebSecurity: false, retries: { - runMode: 2, + runMode: 0, openMode: 0 }, env: { From 1979b6bfc051356c3293e788655d6d48380f51c7 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Fri, 12 Apr 2024 09:25:37 -0700 Subject: [PATCH 3/6] enable retries --- cypress.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress.config.ts b/cypress.config.ts index e8eacf2db6e..f3b1cb717f4 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -59,7 +59,7 @@ export default defineConfig({ trashAssetsBeforeRuns: true, chromeWebSecurity: false, retries: { - runMode: 0, + runMode: 2, openMode: 0 }, env: { From 127fb73feea257a5ff4224f2c4a3e95dd97d74e3 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Fri, 12 Apr 2024 10:57:47 -0700 Subject: [PATCH 4/6] add assertion --- cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts index 846a3d74fc7..ce11b2c9f6f 100644 --- a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts +++ b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts @@ -39,7 +39,7 @@ describe('Namespace picker', { testIsolation: 'off' }, () => { WorkloadsPodsListPagePo.navTo(); workloadsPodPage.waitForPage(); - cy.wait('@getPods'); + cy.wait('@getPods').its('response.statusCode').should('eq', 200); // Filter by Namespace: Select 'cattle-fleet-local-system' namespacePicker.toggle(); From 1618a911760e48efeccf277e95b366393ef995e2 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Fri, 12 Apr 2024 13:21:41 -0700 Subject: [PATCH 5/6] clean up projects/namespace created in cluster dashboard tests and add check for filter --- .../e2e/tests/pages/explorer/cluster-dashboard.spec.ts | 10 +++++++--- .../e2e/tests/pages/explorer/namespace-picker.spec.ts | 4 +--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/tests/pages/explorer/cluster-dashboard.spec.ts b/cypress/e2e/tests/pages/explorer/cluster-dashboard.spec.ts index 60cf85eece2..6cc07c6748e 100644 --- a/cypress/e2e/tests/pages/explorer/cluster-dashboard.spec.ts +++ b/cypress/e2e/tests/pages/explorer/cluster-dashboard.spec.ts @@ -190,10 +190,12 @@ describe('Cluster Dashboard', { testIsolation: 'off', tags: ['@explorer', '@admi // create project cy.createProject(projName, 'local', userId).then((resp: Cypress.Response) => { - const projId = resp.body.id.trim(); + cy.wrap(resp.body.id.trim()).as('projId'); // create ns - cy.createNamespace(nsName, projId); + cy.get('@projId').then((projId) => { + cy.createNamespace(nsName, projId); + }); // create pod // eslint-disable-next-line no-return-assign @@ -217,9 +219,11 @@ describe('Cluster Dashboard', { testIsolation: 'off', tags: ['@explorer', '@admi .should('have.length.gte', 2); }); - after(() => { + after(function() { if (removePod) { cy.deleteRancherResource('v1', `pods/${ nsName }`, `pod-${ podName }`); + cy.deleteRancherResource('v1', 'namespaces', `${ nsName }`); + cy.deleteRancherResource('v3', 'projects', this.projId); } }); }); diff --git a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts index ce11b2c9f6f..e3a58c04357 100644 --- a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts +++ b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts @@ -35,14 +35,12 @@ describe('Namespace picker', { testIsolation: 'off' }, () => { const workloadsPodPage = new WorkloadsPodsListPagePo('local'); - cy.intercept('GET', '/v1/pods?exclude=metadata.managedFields').as('getPods'); - WorkloadsPodsListPagePo.navTo(); workloadsPodPage.waitForPage(); - cy.wait('@getPods').its('response.statusCode').should('eq', 200); // Filter by Namespace: Select 'cattle-fleet-local-system' namespacePicker.toggle(); + namespacePicker.getOptions().find('#ns_cattle-fleet-local-system').should('exist'); namespacePicker.clickOptionByLabel('cattle-fleet-local-system'); namespacePicker.isChecked('cattle-fleet-local-system'); namespacePicker.closeDropdown(); From 86daed3b964ebb7c9e7939d747a8696cd068f8f6 Mon Sep 17 00:00:00 2001 From: Yonas Berhe Date: Tue, 16 Apr 2024 12:49:56 -0700 Subject: [PATCH 6/6] update test to select cattle-fleet-system --- .../tests/pages/explorer/namespace-picker.spec.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts index e3a58c04357..c1feea3d1af 100644 --- a/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts +++ b/cypress/e2e/tests/pages/explorer/namespace-picker.spec.ts @@ -23,7 +23,7 @@ describe('Namespace picker', { testIsolation: 'off' }, () => { }); it('can filter workloads by project/namespace from the picker dropdown', { tags: ['@explorer', '@adminUser'] }, () => { - // Verify 'Namespace: cattle-fleet-local-system' appears once when filtering by Namespace + // Verify 'Namespace: cattle-fleet-system' appears once when filtering by Namespace // Verify multiple namespaces within Project: System display when filtering by Project // group workloads by namespace @@ -38,14 +38,14 @@ describe('Namespace picker', { testIsolation: 'off' }, () => { WorkloadsPodsListPagePo.navTo(); workloadsPodPage.waitForPage(); - // Filter by Namespace: Select 'cattle-fleet-local-system' + // Filter by Namespace: Select 'cattle-fleet-system' namespacePicker.toggle(); - namespacePicker.getOptions().find('#ns_cattle-fleet-local-system').should('exist'); - namespacePicker.clickOptionByLabel('cattle-fleet-local-system'); - namespacePicker.isChecked('cattle-fleet-local-system'); + namespacePicker.getOptions().find('#ns_cattle-fleet-system').should('exist'); + namespacePicker.clickOptionByLabel('cattle-fleet-system'); + namespacePicker.isChecked('cattle-fleet-system'); namespacePicker.closeDropdown(); workloadsPodPage.sortableTable() - .groupElementWithName('cattle-fleet-local-system') + .groupElementWithName('cattle-fleet-system') .scrollIntoView().should('be.visible') .and('have.length', 1); @@ -60,7 +60,7 @@ describe('Namespace picker', { testIsolation: 'off' }, () => { namespacePicker.isChecked('Project: System'); namespacePicker.closeDropdown(); workloadsPodPage.sortableTable().groupElementWithName('kube-system').scrollIntoView().should('be.visible'); - workloadsPodPage.sortableTable().groupElementWithName('cattle-fleet-local-system').scrollIntoView().should('be.visible'); + workloadsPodPage.sortableTable().groupElementWithName('cattle-fleet-system').scrollIntoView().should('be.visible'); }); it('can select only one of the top 5 resource filters at a time', { tags: ['@explorer', '@adminUser', '@standardUser'] }, () => {