Skip to content

Commit

Permalink
Copy and styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ersin-erdal committed May 11, 2022
1 parent ef30e4e commit 92d4dce
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const UpdateApiKeyModalConfirmation = ({
buttonColor="primary"
data-test-subj="updateApiKeyIdsConfirmation"
title={i18n.translate('xpack.triggersActionsUI.updateApiKeyConfirmModal.title', {
defaultMessage: 'Update API Key',
defaultMessage: 'Update API key',
})}
onCancel={() => {
setUpdateModalVisibility(false);
Expand All @@ -53,7 +53,7 @@ export const UpdateApiKeyModalConfirmation = ({
toasts.addSuccess(
i18n.translate('xpack.triggersActionsUI.updateApiKeyConfirmModal.successMessage', {
defaultMessage:
'API {idsToUpdate, plural, one {Key} other {Keys}} {idsToUpdate, plural, one {has} other {have}} been updated',
'API {idsToUpdate, plural, one {key} other {keys}} {idsToUpdate, plural, one {has} other {have}} been updated',
values: { idsToUpdate: idsToUpdate.length },
})
);
Expand All @@ -63,7 +63,7 @@ export const UpdateApiKeyModalConfirmation = ({
'xpack.triggersActionsUI.updateApiKeyConfirmModal.failureMessage',
{
defaultMessage:
'Failed to update the API {idsToUpdate, plural, one {Key} other {Keys}}',
'Failed to update the API {idsToUpdate, plural, one {key} other {keys}}',
values: { idsToUpdate: idsToUpdate.length },
}
),
Expand All @@ -86,7 +86,9 @@ export const UpdateApiKeyModalConfirmation = ({
)}
>
{i18n.translate('xpack.triggersActionsUI.updateApiKeyConfirmModal.description', {
defaultMessage: "You can't recover the old API Key",
defaultMessage:
'You will not be able to recover the old API {idsToUpdate, plural, one {key} other {keys}}',
values: { idsToUpdate: idsToUpdate.length },
})}
</EuiConfirmModal>
) : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.ruleActionsPopover {
.euiContextMenuItem:hover {
text-decoration: none;
}
}

button[data-test-subj='deleteRuleButton'] {
color: $euiColorDanger;
color: $euiColorDangerText;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('rule_actions_popover', () => {
const actionButton = screen.getByTestId('ruleActionsButton');
expect(actionButton).toBeInTheDocument();
fireEvent.click(actionButton);
expect(screen.getByText('Update API Key')).toBeInTheDocument();
expect(screen.getByText('Update API key')).toBeInTheDocument();
expect(screen.getByText('Delete rule')).toBeInTheDocument();
expect(screen.getByText('Disable')).toBeInTheDocument();
});
Expand Down Expand Up @@ -166,13 +166,13 @@ describe('rule_actions_popover', () => {
expect(actionButton).toBeInTheDocument();
fireEvent.click(actionButton);

const deleteButton = screen.getByText('Update API Key');
const deleteButton = screen.getByText('Update API key');
expect(deleteButton).toBeInTheDocument();
fireEvent.click(deleteButton);

expect(onApiKeyUpdateMock).toHaveBeenCalledWith('12345');
await waitFor(() => {
expect(screen.queryByText('Update API Key')).not.toBeInTheDocument();
expect(screen.queryByText('Update API key')).not.toBeInTheDocument();
});
});

Expand All @@ -195,7 +195,7 @@ describe('rule_actions_popover', () => {
fireEvent.click(actionButton);

expect(screen.getByText('Delete rule').closest('button')).toBeDisabled();
expect(screen.getByText('Update API Key').closest('button')).toBeDisabled();
expect(screen.getByText('Update API key').closest('button')).toBeDisabled();
expect(screen.getByText('Disable').closest('button')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const RuleActionsPopover: React.FunctionComponent<RuleActionsPopoverProps
},
name: i18n.translate(
'xpack.triggersActionsUI.sections.ruleDetails.updateAPIKeyButtonLabel',
{ defaultMessage: 'Update API Key' }
{ defaultMessage: 'Update API key' }
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ describe('rule_details', () => {
});
});

describe('update API Key button', () => {
describe('update API key button', () => {
it('should call update api key when clicked', async () => {
const rule = mockRule();
const requestRefresh = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.actCollapsedItemActions {
.euiContextMenuItem:hover {
text-decoration: none;
}
}

button[data-test-subj='deleteRule'] {
color: $euiColorDanger;
color: $euiColorDangerText;
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ describe('CollapsedItemActions', () => {
expect(wrapper.find(`[data-test-subj="editRule"] button`).text()).toEqual('Edit rule');
expect(wrapper.find(`[data-test-subj="deleteRule"] button`).prop('disabled')).toBeFalsy();
expect(wrapper.find(`[data-test-subj="deleteRule"] button`).text()).toEqual('Delete rule');
expect(wrapper.find(`[data-test-subj="updateApiKey"] button`).text()).toEqual('Update API Key');
expect(wrapper.find(`[data-test-subj="updateApiKey"] button`).text()).toEqual('Update API key');
});

test('handles case when rule is unmuted and enabled and mute is clicked', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const CollapsedItemActions: React.FunctionComponent<ComponentOpts> = ({
},
name: i18n.translate(
'xpack.triggersActionsUI.sections.rulesList.collapsedItemActions.updateApiKey',
{ defaultMessage: 'Update API Key' }
{ defaultMessage: 'Update API key' }
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,27 +348,29 @@ describe('Update Api Key', () => {
fireEvent.click(screen.getAllByTestId('selectActionButton')[1]);
expect(screen.getByTestId('collapsedActionPanel')).toBeInTheDocument();

fireEvent.click(screen.getByText('Update API Key'));
expect(screen.getByText("You can't recover the old API Key")).toBeInTheDocument();
fireEvent.click(screen.getByText('Update API key'));
expect(screen.getByText('You will not be able to recover the old API key')).toBeInTheDocument();

fireEvent.click(screen.getByText('Cancel'));
expect(screen.queryByText("You can't recover the old API Key")).not.toBeInTheDocument();
expect(
screen.queryByText('You will not be able to recover the old API key')
).not.toBeInTheDocument();

fireEvent.click(screen.getAllByTestId('selectActionButton')[1]);
expect(screen.getByTestId('collapsedActionPanel')).toBeInTheDocument();

fireEvent.click(screen.getByText('Update API Key'));
fireEvent.click(screen.getByText('Update API key'));

await act(async () => {
fireEvent.click(screen.getByText('Update'));
});
expect(updateAPIKey).toHaveBeenCalledWith(expect.objectContaining({ id: '2' }));
expect(loadRules).toHaveBeenCalledTimes(2);
expect(screen.queryByText("You can't recover the old API Key")).not.toBeInTheDocument();
expect(addSuccess).toHaveBeenCalledWith('API Key has been updated');
expect(screen.queryByText("You can't recover the old API key")).not.toBeInTheDocument();
expect(addSuccess).toHaveBeenCalledWith('API key has been updated');
});

it('Update Api Key fails', async () => {
it('Update API key fails', async () => {
updateAPIKey.mockRejectedValueOnce(500);
render(
<IntlProvider locale="en">
Expand All @@ -381,16 +383,18 @@ describe('Update Api Key', () => {
fireEvent.click(screen.getAllByTestId('selectActionButton')[1]);
expect(screen.getByTestId('collapsedActionPanel')).toBeInTheDocument();

fireEvent.click(screen.getByText('Update API Key'));
expect(screen.getByText("You can't recover the old API Key")).toBeInTheDocument();
fireEvent.click(screen.getByText('Update API key'));
expect(screen.getByText('You will not be able to recover the old API key')).toBeInTheDocument();

await act(async () => {
fireEvent.click(screen.getByText('Update'));
});
expect(updateAPIKey).toHaveBeenCalledWith(expect.objectContaining({ id: '2' }));
expect(loadRules).toHaveBeenCalledTimes(2);
expect(screen.queryByText("You can't recover the old API Key")).not.toBeInTheDocument();
expect(addError).toHaveBeenCalledWith(500, { title: 'Failed to update the API Key' });
expect(
screen.queryByText('You will not be able to recover the old API key')
).not.toBeInTheDocument();
expect(addError).toHaveBeenCalledWith(500, { title: 'Failed to update the API key' });
});
});

Expand Down

0 comments on commit 92d4dce

Please sign in to comment.