Commit cff6f5fe by Vicky Lee Committed by GitHub

test: update addDashboard flow for v7.4.0 changes (#31059)

* update addDashboard flow for v7.4.0 changes

* remove hide flow and if around set time range
parent ea605fde
...@@ -37,7 +37,6 @@ interface AddVariableRequired { ...@@ -37,7 +37,6 @@ interface AddVariableRequired {
export type PartialAddVariableConfig = Partial<AddVariableDefault> & AddVariableOptional & AddVariableRequired; export type PartialAddVariableConfig = Partial<AddVariableDefault> & AddVariableOptional & AddVariableRequired;
export type AddVariableConfig = AddVariableDefault & AddVariableOptional & AddVariableRequired; export type AddVariableConfig = AddVariableDefault & AddVariableOptional & AddVariableRequired;
// @todo this actually returns type `Cypress.Chainable<AddDashboardConfig>`
export const addDashboard = (config?: Partial<AddDashboardConfig>) => { export const addDashboard = (config?: Partial<AddDashboardConfig>) => {
const fullConfig: AddDashboardConfig = { const fullConfig: AddDashboardConfig = {
annotations: [], annotations: [],
...@@ -64,7 +63,7 @@ export const addDashboard = (config?: Partial<AddDashboardConfig>) => { ...@@ -64,7 +63,7 @@ export const addDashboard = (config?: Partial<AddDashboardConfig>) => {
fullConfig.variables = addVariables(variables); fullConfig.variables = addVariables(variables);
e2e.components.BackButton.backArrow().click(); e2e.components.BackButton.backArrow().should('be.visible').click({ force: true });
} }
setDashboardTimeRange(timeRange); setDashboardTimeRange(timeRange);
...@@ -152,29 +151,32 @@ const addVariable = (config: PartialAddVariableConfig, isFirst: boolean): AddVar ...@@ -152,29 +151,32 @@ const addVariable = (config: PartialAddVariableConfig, isFirst: boolean): AddVar
e2e.pages.Dashboard.Settings.Variables.List.newButton().click(); e2e.pages.Dashboard.Settings.Variables.List.newButton().click();
} }
const { constantValue, dataSource, hide, label, name, query, regex, type } = fullConfig; const { constantValue, dataSource, label, name, query, regex, type } = fullConfig;
// This field is key to many reactive changes // This field is key to many reactive changes
if (type !== VARIABLE_TYPE_QUERY) { if (type !== VARIABLE_TYPE_QUERY) {
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelect().select(type); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalTypeSelect()
} .should('be.visible')
.within(() => {
// Avoid '', which is an accepted value e2e.components.Select.singleValue().should('have.text', 'Query').click().type(`${type}{enter}`);
if (hide !== undefined) { });
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalHideSelect().select(hide);
} }
if (label) { if (label) {
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInput().type(label); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalLabelInput().type(label);
} }
e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInput().type(name); e2e.pages.Dashboard.Settings.Variables.Edit.General.generalNameInput().clear().type(name);
if ( if (
dataSource && dataSource &&
(type === VARIABLE_TYPE_AD_HOC_FILTERS || type === VARIABLE_TYPE_DATASOURCE || type === VARIABLE_TYPE_QUERY) (type === VARIABLE_TYPE_AD_HOC_FILTERS || type === VARIABLE_TYPE_DATASOURCE || type === VARIABLE_TYPE_QUERY)
) { ) {
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect().select(dataSource); e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect()
.should('be.visible')
.within(() => {
e2e.components.Select.input().should('be.visible').type(`${dataSource}{enter}`);
});
} }
if (constantValue && type === VARIABLE_TYPE_CONSTANT) { if (constantValue && type === VARIABLE_TYPE_CONSTANT) {
...@@ -193,13 +195,12 @@ const addVariable = (config: PartialAddVariableConfig, isFirst: boolean): AddVar ...@@ -193,13 +195,12 @@ const addVariable = (config: PartialAddVariableConfig, isFirst: boolean): AddVar
// Avoid flakiness // Avoid flakiness
e2e().focused().blur(); e2e().focused().blur();
e2e()
.contains('.gf-form-group', 'Preview of values') e2e.pages.Dashboard.Settings.Variables.Edit.General.previewOfValuesOption()
.within(() => { .should('exist')
.within((previewOfValues) => {
if (type === VARIABLE_TYPE_CONSTANT) { if (type === VARIABLE_TYPE_CONSTANT) {
e2e() expect(previewOfValues.text()).equals(constantValue);
.root()
.contains(constantValue as string);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment