Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into 163830-enforce-data…
Browse files Browse the repository at this point in the history
…set-names
  • Loading branch information
Kerry350 committed Sep 20, 2023
2 parents 105b6bb + 8dd4323 commit 2b987f3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 44 deletions.
93 changes: 52 additions & 41 deletions x-pack/plugins/fleet/cypress/e2e/uninstall_token.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,72 @@ describe('Uninstall token page', () => {
generatePolicies();
});

beforeEach(() => {
login();

cy.visit('app/fleet/uninstall-tokens');
cy.intercept('GET', 'api/fleet/uninstall_tokens/*').as('getTokenRequest');

cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_TABLE_FIELD)
.first()
.then(($policyIdField) => $policyIdField[0].textContent)
.as('policyIdInFirstLine');
});

after(() => {
cleanupAgentPolicies();
});
[true, false].forEach((removePolicies) => {
describe(`When ${
removePolicies ? 'removing policies' : 'not removing policies'
} before checking uninstall tokens`, () => {
beforeEach(() => {
login();

cy.visit('app/fleet/uninstall-tokens');
cy.intercept('GET', 'api/fleet/uninstall_tokens/*').as('getTokenRequest');

cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_TABLE_FIELD)
.first()
.then(($policyIdField) => $policyIdField[0].textContent)
.as('policyIdInFirstLine');

if (removePolicies) {
cleanupAgentPolicies();
// Force page refresh after remove policies
cy.visit('app/fleet/uninstall-tokens');
}
});

it('should show token by clicking on the eye button', () => {
// tokens are hidden by default
cy.getBySel(UNINSTALL_TOKENS.TOKEN_FIELD).each(($tokenField) => {
expect($tokenField).to.contain.text('••••••••••••••••••••••••••••••••');
});
it('should show token by clicking on the eye button', () => {
// tokens are hidden by default
cy.getBySel(UNINSTALL_TOKENS.TOKEN_FIELD).each(($tokenField) => {
expect($tokenField).to.contain.text('••••••••••••••••••••••••••••••••');
});

// token is reveiled when clicking on eye button
cy.getBySel(UNINSTALL_TOKENS.SHOW_HIDE_TOKEN_BUTTON).first().click();
// token is reveiled when clicking on eye button
cy.getBySel(UNINSTALL_TOKENS.SHOW_HIDE_TOKEN_BUTTON).first().click();

// we should show the correct token for the correct policy ID
waitForFetchingUninstallToken().then((fetchedToken) => {
cy.get('@policyIdInFirstLine').should('equal', fetchedToken.policy_id);
// we should show the correct token for the correct policy ID
waitForFetchingUninstallToken().then((fetchedToken) => {
cy.get('@policyIdInFirstLine').should('equal', fetchedToken.policy_id);

cy.getBySel(UNINSTALL_TOKENS.TOKEN_FIELD)
.first()
.should('not.contain.text', '••••••••••••••••••••••••••••••••')
.should('contain.text', fetchedToken.token);
});
});
cy.getBySel(UNINSTALL_TOKENS.TOKEN_FIELD)
.first()
.should('not.contain.text', '••••••••••••••••••••••••••••••••')
.should('contain.text', fetchedToken.token);
});
});

it("should show flyout by clicking on 'View uninstall command' button", () => {
cy.getBySel(UNINSTALL_TOKENS.VIEW_UNINSTALL_COMMAND_BUTTON).first().click();
it("should show flyout by clicking on 'View uninstall command' button", () => {
cy.getBySel(UNINSTALL_TOKENS.VIEW_UNINSTALL_COMMAND_BUTTON).first().click();

waitForFetchingUninstallToken().then((fetchedToken) => {
cy.get('@policyIdInFirstLine').should('equal', fetchedToken.policy_id);
waitForFetchingUninstallToken().then((fetchedToken) => {
cy.get('@policyIdInFirstLine').should('equal', fetchedToken.policy_id);

cy.getBySel(UNINSTALL_TOKENS.UNINSTALL_COMMAND_FLYOUT).should('exist');
cy.getBySel(UNINSTALL_TOKENS.UNINSTALL_COMMAND_FLYOUT).should('exist');

cy.contains(`sudo elastic-agent uninstall --uninstall-token ${fetchedToken.token}`);
cy.contains(`Valid for the following agent policy: ${fetchedToken.policy_id}`);
});
});
cy.contains(`sudo elastic-agent uninstall --uninstall-token ${fetchedToken.token}`);
cy.contains(`Valid for the following agent policy: ${fetchedToken.policy_id}`);
});
});

it('should filter for policy ID by partial match', () => {
cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_TABLE_FIELD).should('have.length.at.least', 3);
it('should filter for policy ID by partial match', () => {
cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_TABLE_FIELD).should('have.length.at.least', 3);

cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_SEARCH_FIELD).type('licy-300');
cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_SEARCH_FIELD).type('licy-300');

cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_TABLE_FIELD).should('have.length', 1);
cy.getBySel(UNINSTALL_TOKENS.POLICY_ID_TABLE_FIELD).should('have.length', 1);
});
});
});

const generatePolicies = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export function LensEditConfigurationFlyout({
<EuiFlyoutBody
className="lnsEditFlyoutBody"
css={css`
// styles needed to display extra drop targets that are outside of the config panel main area while also allowing to scroll vertically
overflow-y: scroll;
// styles needed to display extra drop targets that are outside of the config panel main area
overflow-y: auto;
padding-left: ${euiThemeVars.euiFormMaxWidth};
margin-left: -${euiThemeVars.euiFormMaxWidth};
pointer-events: none !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
ensureCurrentUrl: false,
shouldLoginIfPrompted: false,
});
PageObjects.error.expectForbidden();
await PageObjects.error.expectForbidden();
});
});
});
Expand Down

0 comments on commit 2b987f3

Please sign in to comment.