mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Run test datasource default selection when mounted (#65864)
* Run test datasource query when mounted
* Auto running test-datasource creates more query history entries
* Make exemplar query intercept more robust
* Delete unrelated query history queries
* Revert "Run test datasource query when mounted"
This reverts commit 28b37e4df9
.
* Add default query to testdata and grafana datasources
This commit is contained in:
parent
9041e7dfa6
commit
8dded022ec
@ -32,14 +32,14 @@ describe('Exemplars', () => {
|
||||
});
|
||||
|
||||
it('should be able to navigate to configured data source', () => {
|
||||
let intercept = 'prometheus';
|
||||
e2e().intercept('/api/ds/query', (req) => {
|
||||
if (intercept === 'prometheus') {
|
||||
// For second intercept, we want to send tempo response
|
||||
intercept = 'tempo';
|
||||
const datasourceType = req.body.queries[0].datasource.type;
|
||||
if (datasourceType === 'prometheus') {
|
||||
req.reply({ fixture: 'exemplars-query-response.json' });
|
||||
} else {
|
||||
} else if (datasourceType === 'tempo') {
|
||||
req.reply({ fixture: 'tempo-response.json' });
|
||||
} else {
|
||||
req.reply({});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,15 @@ e2e.scenario({
|
||||
e2e.pages.Explore.General.container().should('have.length', 1);
|
||||
e2e.components.RefreshPicker.runButtonV2().should('have.length', 1);
|
||||
|
||||
// delete query history queries that would be unrelated
|
||||
e2e.components.QueryTab.queryHistoryButton().should('be.visible').click();
|
||||
cy.get('button[title="Delete query"]').each((button) => {
|
||||
button.trigger('click');
|
||||
});
|
||||
e2e.components.QueryTab.queryHistoryButton().should('be.visible').click();
|
||||
|
||||
e2e.components.DataSource.TestData.QueryTab.scenarioSelectContainer()
|
||||
.scrollIntoView()
|
||||
.should('be.visible')
|
||||
.within(() => {
|
||||
e2e().get('input[id*="test-data-scenario-select-"]').should('be.visible').click();
|
||||
|
@ -66,6 +66,12 @@ export class GrafanaDatasource extends DataSourceWithBackend<GrafanaQuery> {
|
||||
};
|
||||
}
|
||||
|
||||
getDefaultQuery(): Partial<GrafanaQuery> {
|
||||
return {
|
||||
queryType: GrafanaQueryType.RandomWalk,
|
||||
};
|
||||
}
|
||||
|
||||
query(request: DataQueryRequest<GrafanaQuery>): Observable<DataQueryResponse> {
|
||||
const results: Array<Observable<DataQueryResponse>> = [];
|
||||
const targets: GrafanaQuery[] = [];
|
||||
|
@ -37,6 +37,13 @@ export class TestDataDataSource extends DataSourceWithBackend<TestData> {
|
||||
this.variables = new TestDataVariableSupport();
|
||||
}
|
||||
|
||||
getDefaultQuery(): Partial<TestData> {
|
||||
return {
|
||||
scenarioId: TestDataQueryType.RandomWalk,
|
||||
seriesCount: 1,
|
||||
};
|
||||
}
|
||||
|
||||
query(options: DataQueryRequest<TestData>): Observable<DataQueryResponse> {
|
||||
const backendQueries: TestData[] = [];
|
||||
const streams: Array<Observable<DataQueryResponse>> = [];
|
||||
|
Loading…
Reference in New Issue
Block a user