mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Standarize e2e for addDashbaord e2e flow
This commit is contained in:
parent
ae70cd953d
commit
6b9ea9d5a4
@ -2540,9 +2540,6 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||||
],
|
],
|
||||||
"public/app/features/dashboard-scene/saving/shared.tsx:5381": [
|
|
||||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
|
||||||
],
|
|
||||||
"public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx:5381": [
|
"public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx:5381": [
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||||
|
@ -143,9 +143,9 @@ function copyExistingDashboard() {
|
|||||||
|
|
||||||
e2e.pages.Dashboard.Settings.General.saveAsDashBoard().should('be.visible').click();
|
e2e.pages.Dashboard.Settings.General.saveAsDashBoard().should('be.visible').click();
|
||||||
|
|
||||||
e2e.pages.SaveDashboardAsModal.newName().should('be.visible').type(`${Date.now()}`);
|
e2e.pages.SaveDashboardModal.newName().should('be.visible').type(`${Date.now()}`);
|
||||||
|
|
||||||
e2e.pages.SaveDashboardAsModal.save().should('be.visible').click();
|
e2e.pages.SaveDashboardModal.saveDashboardToolbar().should('be.visible').click();
|
||||||
|
|
||||||
cy.wait('@save-dash');
|
cy.wait('@save-dash');
|
||||||
cy.wait('@load-dash');
|
cy.wait('@load-dash');
|
||||||
|
@ -139,9 +139,11 @@ export const addDashboard = (config?: Partial<AddDashboardConfig>) => {
|
|||||||
|
|
||||||
setDashboardTimeRange(timeRange);
|
setDashboardTimeRange(timeRange);
|
||||||
|
|
||||||
e2e.components.PageToolbar.item('Save dashboard').click();
|
//Use different selectors if dashboardScene feature flag is enabled
|
||||||
e2e.pages.SaveDashboardAsModal.newName().clear().type(title, { force: true });
|
|
||||||
e2e.pages.SaveDashboardAsModal.save().click();
|
e2e.components.PageToolbar.itemButton('Save dashboard').click();
|
||||||
|
e2e.pages.SaveDashboardModal.newName().clear().type(title, { force: true });
|
||||||
|
e2e.pages.SaveDashboardModal.saveButtonDrawer().click();
|
||||||
e2e.flows.assertSuccessNotification();
|
e2e.flows.assertSuccessNotification();
|
||||||
e2e.pages.AddDashboard.itemButton('Create new panel button').should('be.visible');
|
e2e.pages.AddDashboard.itemButton('Create new panel button').should('be.visible');
|
||||||
|
|
||||||
|
@ -222,7 +222,10 @@ export const Pages = {
|
|||||||
save: 'Save dashboard button',
|
save: 'Save dashboard button',
|
||||||
},
|
},
|
||||||
SaveDashboardModal: {
|
SaveDashboardModal: {
|
||||||
|
newName: 'Save dashboard title field',
|
||||||
save: 'Dashboard settings Save Dashboard Modal Save button',
|
save: 'Dashboard settings Save Dashboard Modal Save button',
|
||||||
|
saveDashboardToolbar: 'data-testid Save dashboard',
|
||||||
|
saveButtonDrawer: 'data-testid Save dashboard button',
|
||||||
saveVariables: 'Dashboard settings Save Dashboard Modal Save variables checkbox',
|
saveVariables: 'Dashboard settings Save Dashboard Modal Save variables checkbox',
|
||||||
saveTimerange: 'Dashboard settings Save Dashboard Modal Save timerange checkbox',
|
saveTimerange: 'Dashboard settings Save Dashboard Modal Save timerange checkbox',
|
||||||
},
|
},
|
||||||
|
@ -141,8 +141,8 @@ export const addDashboard = (config?: Partial<AddDashboardConfig>) => {
|
|||||||
setDashboardTimeRange(timeRange);
|
setDashboardTimeRange(timeRange);
|
||||||
|
|
||||||
e2e.components.PageToolbar.item('Save dashboard').click();
|
e2e.components.PageToolbar.item('Save dashboard').click();
|
||||||
e2e.pages.SaveDashboardAsModal.newName().clear().type(title, { force: true });
|
e2e.pages.SaveDashboardModal.newName().clear().type(title, { force: true });
|
||||||
e2e.pages.SaveDashboardAsModal.save().click();
|
e2e.pages.SaveDashboardModal.saveButtonDrawer().click();
|
||||||
e2e.flows.assertSuccessNotification();
|
e2e.flows.assertSuccessNotification();
|
||||||
e2e.pages.AddDashboard.itemButton('Create new panel button').should('be.visible');
|
e2e.pages.AddDashboard.itemButton('Create new panel button').should('be.visible');
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import debounce from 'debounce-promise';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { UseFormSetValue, useForm } from 'react-hook-form';
|
import { UseFormSetValue, useForm } from 'react-hook-form';
|
||||||
|
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Dashboard } from '@grafana/schema';
|
import { Dashboard } from '@grafana/schema';
|
||||||
import { Button, Input, Switch, Field, Label, TextArea, Stack, Alert, Box } from '@grafana/ui';
|
import { Button, Input, Switch, Field, Label, TextArea, Stack, Alert, Box } from '@grafana/ui';
|
||||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||||
@ -66,7 +67,13 @@ export function SaveDashboardAsForm({ dashboard, drawer, changeInfo }: Props) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const saveButton = (overwrite: boolean) => (
|
const saveButton = (overwrite: boolean) => (
|
||||||
<SaveButton isValid={isValid} isLoading={state.loading} onSave={onSave} overwrite={overwrite} />
|
<SaveButton
|
||||||
|
isValid={isValid}
|
||||||
|
isLoading={state.loading}
|
||||||
|
onSave={onSave}
|
||||||
|
overwrite={overwrite}
|
||||||
|
testId={selectors.pages.SaveDashboardModal.saveButtonDrawer}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
function renderFooter(error?: Error) {
|
function renderFooter(error?: Error) {
|
||||||
|
@ -45,7 +45,13 @@ export function SaveDashboardForm({ dashboard, drawer, changeInfo }: Props) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const saveButton = (overwrite: boolean) => (
|
const saveButton = (overwrite: boolean) => (
|
||||||
<SaveButton isValid={hasChanges} isLoading={state.loading} onSave={onSave} overwrite={overwrite} />
|
<SaveButton
|
||||||
|
isValid={hasChanges}
|
||||||
|
isLoading={state.loading}
|
||||||
|
onSave={onSave}
|
||||||
|
overwrite={overwrite}
|
||||||
|
testId={selectors.pages.SaveDashboardModal.saveButtonDrawer}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
function renderFooter(error?: Error) {
|
function renderFooter(error?: Error) {
|
||||||
|
@ -56,14 +56,16 @@ export interface SaveButtonProps {
|
|||||||
onSave: (overwrite: boolean) => void;
|
onSave: (overwrite: boolean) => void;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
isValid?: boolean;
|
isValid?: boolean;
|
||||||
|
testId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SaveButton({ overwrite, isLoading, isValid, onSave }: SaveButtonProps) {
|
export function SaveButton({ overwrite, isLoading, isValid, onSave, testId }: SaveButtonProps) {
|
||||||
|
const testIdSelector = testId ? testId : selectors.pages.SaveDashboardModal.save;
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
disabled={!isValid || isLoading}
|
disabled={!isValid || isLoading}
|
||||||
icon={isLoading ? 'spinner' : undefined}
|
icon={isLoading ? 'spinner' : undefined}
|
||||||
aria-label={selectors.pages.SaveDashboardModal.save}
|
data-testid={testIdSelector}
|
||||||
onClick={() => onSave(overwrite)}
|
onClick={() => onSave(overwrite)}
|
||||||
variant={overwrite ? 'destructive' : 'primary'}
|
variant={overwrite ? 'destructive' : 'primary'}
|
||||||
>
|
>
|
||||||
|
@ -417,6 +417,7 @@ export function ToolbarActions({ dashboard }: Props) {
|
|||||||
key="save"
|
key="save"
|
||||||
size="sm"
|
size="sm"
|
||||||
variant={'primary'}
|
variant={'primary'}
|
||||||
|
data-testid={selectors.pages.SaveDashboardModal.saveDashboardToolbar}
|
||||||
>
|
>
|
||||||
Save dashboard
|
Save dashboard
|
||||||
</Button>
|
</Button>
|
||||||
@ -474,6 +475,7 @@ export function ToolbarActions({ dashboard }: Props) {
|
|||||||
tooltip="Save changes"
|
tooltip="Save changes"
|
||||||
size="sm"
|
size="sm"
|
||||||
variant={isDirty ? 'primary' : 'secondary'}
|
variant={isDirty ? 'primary' : 'secondary'}
|
||||||
|
data-testid={selectors.pages.SaveDashboardModal.saveDashboardToolbar}
|
||||||
>
|
>
|
||||||
Save dashboard
|
Save dashboard
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -315,6 +315,7 @@ export const DashNav = React.memo<Props>((props) => {
|
|||||||
onDismiss: hideModal,
|
onDismiss: hideModal,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
data-testid={e2eSelectors.pages.SaveDashboardModal.saveDashboardToolbar}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ModalsController>
|
</ModalsController>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { ChangeEvent } from 'react';
|
import React, { ChangeEvent } from 'react';
|
||||||
|
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { Button, Input, Switch, Form, Field, InputControl, HorizontalGroup, Label, TextArea } from '@grafana/ui';
|
import { Button, Input, Switch, Form, Field, InputControl, HorizontalGroup, Label, TextArea } from '@grafana/ui';
|
||||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||||
@ -188,7 +189,12 @@ export const SaveDashboardAsForm = ({
|
|||||||
<Button type="button" variant="secondary" onClick={onCancel} fill="outline">
|
<Button type="button" variant="secondary" onClick={onCancel} fill="outline">
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button disabled={isLoading} type="submit" aria-label="Save dashboard button">
|
<Button
|
||||||
|
disabled={isLoading}
|
||||||
|
type="submit"
|
||||||
|
aria-label="Save dashboard button"
|
||||||
|
data-testid={selectors.pages.SaveDashboardModal.saveButtonDrawer}
|
||||||
|
>
|
||||||
{isLoading ? 'Saving...' : 'Save'}
|
{isLoading ? 'Saving...' : 'Save'}
|
||||||
</Button>
|
</Button>
|
||||||
</HorizontalGroup>
|
</HorizontalGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user