Skip to content

Commit

Permalink
Fix LogViewerSearch styling issue and improve functionality
Browse files Browse the repository at this point in the history
Fix LogViewerSearch styling issue and improve tests

fix: pause logs while loading in pipeline topology test

fix: pause logs while loading in pipeline topology test

fix: pause logs while loading in pipeline topology test

fix: update pipeline topology test to pause logs while loading
  • Loading branch information
Gkrumbach07 committed Jul 11, 2024
1 parent 8a4261f commit a5b3a44
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 30 deletions.
7 changes: 4 additions & 3 deletions frontend/src/__mocks__/mockPipelinePodK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const mockPipelinePodK8sResource = ({
user = 'test-user',
name = 'test-pod',
namespace = 'test-project',
isPending = false,
}: MockResourceConfigType): PodKind => ({
kind: 'Pod',
apiVersion: 'project.openshift.io/v1',
Expand Down Expand Up @@ -545,21 +546,21 @@ export const mockPipelinePodK8sResource = ({
{
name: 'step-copy-artifacts',
state: {
terminated: true,
terminated: !isPending,
},
ready: false,
},
{
name: 'step-main',
state: {
terminated: true,
terminated: !isPending,
},
ready: false,
},
{
name: 'step-move-all-results-to-tekton-home',
state: {
terminated: true,
terminated: !isPending,
},
ready: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ class PipelineDetails extends PipelinesTopology {
}

selectActionDropdownItem(label: string) {
this.findActionsDropdown().click().findByRole('menuitem', { name: label }).click();
this.findActionsDropdown().click();
cy.findByRole('menuitem', { name: label }).click();
}
}

Expand Down Expand Up @@ -269,6 +270,10 @@ class PipelineRunDetails extends RunDetails {
return cy.findByTestId('logs-step-select');
}

findLogsPauseButton() {
return cy.findByTestId('logs-pause-refresh-button');
}

selectStepByName(name: string): void {
this.findStepSelect().findDropdownItem(name).click();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,7 @@ describe('Pipeline topology', () => {
});

describe('Pipelines logs', () => {
beforeEach(() => {
initIntercepts();
const navigateToLogsTab = () => {
pipelineRunDetails.visit(
projectId,
mockVersion.pipeline_id,
Expand All @@ -680,10 +679,53 @@ describe('Pipeline topology', () => {
rightDrawer.findRightDrawerDetailsTab().should('be.visible');
rightDrawer.findRightDrawerLogsTab().should('be.visible');
rightDrawer.findRightDrawerLogsTab().click();
pipelineRunDetails.findLogsSuccessAlert().should('be.visible');
};

beforeEach(() => {
initIntercepts();
navigateToLogsTab();
});

it('test logs paused while loading', () => {
cy.interceptK8s(
PodModel,
mockPipelinePodK8sResource({
namespace: projectId,
name: 'iris-training-pipeline-v4zp7-2757091352',
isPending: true,
}),
).as('podLoading');
navigateToLogsTab();

pipelineRunDetails
.findLogs()
.contains(
'sample log for namespace test-project, pod name iris-training-pipeline-v4zp7-2757091352 and for step step-main',
);

cy.wait('@podLoading');

pipelineRunDetails.findLogsPauseButton().click();

cy.interceptK8s(
PodModel,
mockPipelinePodK8sResource({
namespace: projectId,
name: 'iris-training-pipeline-v4zp7-2757091352',
isPending: false,
}),
).as('podTerminated');

cy.wait('@podTerminated', { timeout: 20000 });

pipelineRunDetails.findLogsPauseButton().should('exist');
pipelineRunDetails.findLogsPauseButton().click();
pipelineRunDetails.findLogsPauseButton().should('not.exist');
});

it('test whether the logs load in Logs tab', () => {
pipelineRunDetails.findLogsSuccessAlert().should('be.visible');

pipelineRunDetails
.findLogs()
.contains(
Expand All @@ -702,6 +744,8 @@ describe('Pipeline topology', () => {
});

it('test logs of another step', () => {
pipelineRunDetails.findLogsSuccessAlert().should('be.visible');

pipelineRunDetails.findStepSelect().should('not.be.disabled');
pipelineRunDetails.selectStepByName('step-copy-artifacts');
pipelineRunDetails.findLogs().contains('No logs available');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
pipelineVersionRecurringRunsRoute,
pipelineVersionRunsRoute,
} from '~/routes';
import { getDashboardMainContainer } from '~/utilities/utils';

type PipelineDetailsActionsProps = {
onDelete: () => void;
Expand All @@ -40,6 +41,7 @@ const PipelineDetailsActions: React.FC<PipelineDetailsActionsProps> = ({
<Dropdown
data-testid="pipeline-version-details-actions"
onSelect={() => setOpen(false)}
menuAppendTo={getDashboardMainContainer}
toggle={
<DropdownToggle toggleVariant="primary" onToggle={() => setOpen(!open)}>
Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { usePipelinesAPI } from '~/concepts/pipelines/context';
import { PipelineRecurringRunKFv2, RecurringRunStatus } from '~/concepts/pipelines/kfTypes';
import { cloneRecurringRunRoute } from '~/routes';
import { useIsAreaAvailable, SupportedArea } from '~/concepts/areas';
import { getDashboardMainContainer } from '~/utilities/utils';

type PipelineRecurringRunDetailsActionsProps = {
recurringRun?: PipelineRecurringRunKFv2;
Expand Down Expand Up @@ -69,6 +70,7 @@ const PipelineRecurringRunDetailsActions: React.FC<PipelineRecurringRunDetailsAc
<Dropdown
data-testid="pipeline-recurring-run-details-actions"
onSelect={() => setOpen(false)}
menuAppendTo={getDashboardMainContainer}
toggle={
<DropdownToggle toggleVariant="primary" onToggle={() => setOpen(!open)}>
Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PipelineRunKFv2, RuntimeStateKF, StorageStateKF } from '~/concepts/pipe
import { cloneRunRoute, experimentsCompareRunsRoute } from '~/routes';
import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas';
import useExperimentById from '~/concepts/pipelines/apiHooks/useExperimentById';
import { getDashboardMainContainer } from '~/utilities/utils';

type PipelineRunDetailsActionsProps = {
run?: PipelineRunKFv2 | null;
Expand Down Expand Up @@ -55,6 +56,7 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({
<Dropdown
data-testid="pipeline-run-details-actions"
onSelect={() => setOpen(false)}
menuAppendTo={getDashboardMainContainer}
toggle={
<DropdownToggle toggleVariant="primary" onToggle={() => setOpen(!open)}>
Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,13 @@ const LogsTab: React.FC<LogsTabProps> = ({ task }) => {
scrollOffsetToBottom,
scrollUpdateWasRequested,
}) => {
if (!scrollUpdateWasRequested) {
if (scrollOffsetToBottom > 0) {
setIsPaused(true);
} else {
setIsPaused(false);
if (!podStatus?.completed && logsLoaded) {
if (!scrollUpdateWasRequested) {
if (scrollOffsetToBottom > 0) {
setIsPaused(true);
} else {
setIsPaused(false);
}
}
}
};
Expand Down Expand Up @@ -296,34 +298,37 @@ const LogsTab: React.FC<LogsTabProps> = ({ task }) => {
</ToolbarItem>
)}
<ToolbarItem spacer={{ default: 'spacerNone' }} style={{ maxWidth: '300px' }}>
<Tooltip content="Search">
<LogViewerSearch
onFocus={() => setIsPaused(true)}
placeholder="Search"
minSearchChars={0}
expandableInput={{
isExpanded: showSearchbar,
onToggleExpand,
toggleAriaLabel: 'Expandable search input toggle',
}}
/>
</Tooltip>
<LogViewerSearch
onFocus={() => {
if (!podStatus?.completed && logsLoaded) {
setIsPaused(true);
}
}}
placeholder="Search"
minSearchChars={0}
expandableInput={{
isExpanded: showSearchbar,
onToggleExpand,
toggleAriaLabel: 'Expandable search input toggle',
}}
/>
</ToolbarItem>
{!podStatus?.completed && (
{(!podStatus?.completed || isPaused) && (
<ToolbarItem spacer={{ default: 'spacerNone' }}>
<Button
variant={!logsLoaded ? 'plain' : isPaused ? 'plain' : 'link'}
onClick={() => setIsPaused(!isPaused)}
isDisabled={!!error}
data-testid="logs-pause-refresh-button"
>
{!logsLoaded || podStatus?.podInitializing ? (
<Tooltip content="Loading log">
<Spinner size="sm" />
</Tooltip>
) : isPaused ? (
{isPaused ? (
<Tooltip content="Resume refreshing">
<PlayIcon />
</Tooltip>
) : !logsLoaded || podStatus?.podInitializing ? (
<Tooltip content="Loading log">
<Spinner size="sm" />
</Tooltip>
) : (
<Tooltip content="Pause refreshing">
<PauseIcon />
Expand Down

0 comments on commit a5b3a44

Please sign in to comment.