Skip to content

Commit 473a113

Browse files
committed
fix tests
1 parent a156509 commit 473a113

4 files changed

Lines changed: 24 additions & 2 deletions

File tree

x-pack/platform/plugins/shared/fleet/cypress/e2e/fleet_agent_flyout.cy.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
* 2.0.
66
*/
77

8-
import { ADD_AGENT_BUTTON, AGENT_FLYOUT } from '../screens/fleet';
8+
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
9+
10+
import { ADD_AGENT_BUTTON, ADD_AGENT_MENU_BUTTON, AGENT_FLYOUT } from '../screens/fleet';
911
import { cleanupAgentPolicies, deleteAgentDocs } from '../tasks/cleanup';
1012
import { createAgentDoc } from '../tasks/agents';
1113
import { setFleetServerHost } from '../tasks/fleet_server';
1214
import { FLEET, navigateTo } from '../tasks/navigation';
1315
import { request } from '../tasks/common';
1416

15-
import { API_VERSIONS } from '@kbn/fleet-plugin/common/constants';
1617
import { login } from '../tasks/login';
1718

1819
const FLEET_SERVER_POLICY_ID = 'fleet-server-policy';
@@ -66,6 +67,12 @@ describe('Fleet add agent flyout', () => {
6667
const AGENT_ID = 'agent' + Date.now();
6768
navigateTo(FLEET);
6869

70+
// When enableOpAMP is on, addAgentButton lives inside a popover — open it first.
71+
cy.get('body').then(($body) => {
72+
if ($body.find(`[data-test-subj="${ADD_AGENT_MENU_BUTTON}"]`).length > 0) {
73+
cy.getBySel(ADD_AGENT_MENU_BUTTON).click();
74+
}
75+
});
6976
cy.getBySel(ADD_AGENT_BUTTON).click();
7077
cy.intercept('POST', '/api/fleet/agent_policies?sys_monitoring=true').as('createAgentPolicy');
7178

x-pack/platform/plugins/shared/fleet/cypress/screens/fleet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
export const ADD_AGENT_BUTTON = 'addAgentButton';
9+
export const ADD_AGENT_MENU_BUTTON = 'addAgentMenuButton';
910
export const ADD_AGENT_BUTTON_TOP = 'addAgentBtnTop';
1011
export const LANDING_PAGE_ADD_FLEET_SERVER_BUTTON = 'fleetServerLanding.addFleetServerButton';
1112

x-pack/platform/plugins/shared/fleet/test/scout/ui/fixtures/page_objects/fleet_home.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,21 @@ export class FleetHomePage {
3333
return this.page.testSubj.locator('fleet-agents-tab');
3434
}
3535

36+
getAddAgentMenuButton() {
37+
return this.page.testSubj.locator('addAgentMenuButton');
38+
}
39+
3640
getAddAgentButton() {
3741
return this.page.testSubj.locator('addAgentButton');
3842
}
3943

44+
async openAddAgentMenu() {
45+
const menuButton = this.getAddAgentMenuButton();
46+
if ((await menuButton.count()) > 0) {
47+
await menuButton.click();
48+
}
49+
}
50+
4051
getAddFleetServerHeader() {
4152
return this.page.testSubj.locator('addFleetServerHeader');
4253
}

x-pack/platform/plugins/shared/fleet/test/scout/ui/tests/privileges_editor_role.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ test.describe('When the user has Editor built-in role', { tag: tags.stateful.cla
4242
await fleetHome.navigateTo();
4343
await fleetHome.waitForPageToLoad();
4444

45+
// When enableOpAMP is on, addAgentButton lives inside a popover — open it first.
46+
await fleetHome.openAddAgentMenu();
47+
4548
// Verify Add Agent button exists
4649
await expect(fleetHome.getAddAgentButton()).toBeVisible();
4750
});

0 commit comments

Comments
 (0)