Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed Aug 24, 2021
1 parent d302db4 commit d6fd6eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('Overview - Fix deprecation logs step', () => {
httpRequestsMockHelpers.setLoadDeprecationLoggingResponse(getLoggingResponse(true));
});

test('X deprecation warnings', async () => {
test('Has deprecation warnings', async () => {
httpRequestsMockHelpers.setLoadDeprecationLogsCountResponse({
count: 10,
});
Expand All @@ -163,12 +163,12 @@ describe('Overview - Fix deprecation logs step', () => {
testBed = await setupOverviewPage();
});

const { exists, component } = testBed;
const { find, exists, component } = testBed;

component.update();

expect(exists('hasWarningsCallout')).toBe(true);
expect(exists('noWarningsCallout')).toBe(false);
expect(find('hasWarningsCallout').text()).toContain('10');
});

test('No deprecation warnings', async () => {
Expand All @@ -180,15 +180,15 @@ describe('Overview - Fix deprecation logs step', () => {
testBed = await setupOverviewPage();
});

const { exists, component } = testBed;
const { find, exists, component } = testBed;

component.update();

expect(exists('noWarningsCallout')).toBe(true);
expect(exists('hasWarningsCallout')).toBe(false);
expect(find('noWarningsCallout').text()).toContain('No deprecation warnings');
});

test('Handles errors and has a way to retry', async () => {
test('Handles errors and can retry', async () => {
const error = {
statusCode: 500,
error: 'Internal server error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const i18nTexts = {
),
};

const getPreviousCheck = () => {
const getPreviousCheckpointDate = () => {
const storedValue = moment(localStorage.get(LOCALSTORAGE_KEY));

if (storedValue.isValid()) {
Expand All @@ -68,7 +68,7 @@ const getPreviousCheck = () => {

export const VerifyChanges: FunctionComponent = () => {
const { api } = useAppContext();
const [previousCheck, setPreviousCheck] = useState(getPreviousCheck());
const [previousCheck, setPreviousCheck] = useState(getPreviousCheckpointDate());
const { data, error, isLoading, resendRequest } = api.getDeprecationLogsCount(previousCheck);

const warningsCount = data?.count || 0;
Expand All @@ -87,7 +87,7 @@ export const VerifyChanges: FunctionComponent = () => {
localStorage.set(LOCALSTORAGE_KEY, now);
};

if (isLoading) {
if (!data && isLoading) {
return (
<EuiFlexGroup>
<EuiFlexItem>
Expand Down

0 comments on commit d6fd6eb

Please sign in to comment.