Skip to content

Commit

Permalink
Fix tests + don't call upgrade API when saving
Browse files Browse the repository at this point in the history
  • Loading branch information
kpollich committed Oct 19, 2021
1 parent 61bea60 commit eb0c5bc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
sendGetOneAgentPolicy,
sendGetOnePackagePolicy,
sendGetPackageInfoByKey,
sendUpgradePackagePolicy,
sendUpgradePackagePolicyDryRun,
} from '../../../hooks';
import {
Expand Down Expand Up @@ -364,29 +363,6 @@ export const EditPackagePolicyForm = memo<{

const { error } = await savePackagePolicy();
if (!error) {
if (isUpgrade) {
const { error: upgradeError } = await sendUpgradePackagePolicy([packagePolicyId]);

if (upgradeError) {
notifications.toasts.addError(upgradeError, {
title: i18n.translate('xpack.fleet.upgradePackagePolicy.failedNotificationTitle', {
defaultMessage: 'Error upgrading {packagePolicyName}',
values: {
packagePolicyName: packagePolicy.name,
},
}),
toastMessage: i18n.translate(
'xpack.fleet.editPackagePolicy.failedConflictNotificationMessage',
{
defaultMessage: `Data is out of date. Refresh the page to get the latest policy.`,
}
),
});

return;
}
}

application.navigateToUrl(successRedirectPath);
notifications.toasts.addSuccess({
title: i18n.translate('xpack.fleet.editPackagePolicy.updatedNotificationTitle', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,15 @@ export default function (providerContext: FtrProviderContext) {

describe('upgrade', function () {
it('should respond with an error when "dryRun: false" is provided', async function () {
const { body }: { body: UpgradePackagePolicyResponse } = await supertest
await supertest
.post(`/api/fleet/package_policies/upgrade`)
.set('kbn-xsrf', 'xxxx')
.send({
packagePolicyIds: [packagePolicyId],
dryRun: false,
packageVersion: '0.2.0-add-non-required-test-var',
})
.expect(200);

expect(body.length).to.be(1);
expect(body[0].success).to.be(false);
.expect(400);
});
});
});
Expand Down

0 comments on commit eb0c5bc

Please sign in to comment.