0f2f25c5d9
* update drone to use cypress 12 image * upgrade cypress to 12 in core * cypress config actually valid * update @grafana/e2e imports and add lint rule * ignore grafana-e2e from betterer now it's deprecated * fix remaining type errors * fix failing tests * remove unnecessary tsconfig * remove unnecessary comment * update enterprise suite commands to work * add cypress config to CODEOWNERS * export setTimeRange in utils * remove @grafana/e2e from core deps * try running the command through yarn * move CMD to scripts * Update cloud-data-sources e2e image * Update paths --------- Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { e2e } from '../index';
|
|
import { fromBaseUrl } from '../support/url';
|
|
|
|
export interface DeleteDataSourceConfig {
|
|
id: string;
|
|
name: string;
|
|
quick?: boolean;
|
|
}
|
|
|
|
export const deleteDataSource = ({ id, name, quick = false }: DeleteDataSourceConfig) => {
|
|
e2e().logToConsole('Deleting data source with name:', name);
|
|
|
|
if (quick) {
|
|
quickDelete(name);
|
|
} else {
|
|
uiDelete(name);
|
|
}
|
|
|
|
e2e().logToConsole('Deleted data source with name:', name);
|
|
|
|
e2e.getScenarioContext().then(({ addedDataSources }: any) => {
|
|
e2e.setScenarioContext({
|
|
addedDataSources: addedDataSources.filter((dataSource: DeleteDataSourceConfig) => {
|
|
return dataSource.id !== id && dataSource.name !== name;
|
|
}),
|
|
});
|
|
});
|
|
};
|
|
|
|
const quickDelete = (name: string) => {
|
|
e2e().request('DELETE', fromBaseUrl(`/api/datasources/name/${name}`));
|
|
};
|
|
|
|
const uiDelete = (name: string) => {
|
|
e2e.pages.DataSources.visit();
|
|
e2e.pages.DataSources.dataSources(name).click();
|
|
e2e.pages.DataSource.delete().click();
|
|
e2e.pages.ConfirmModal.delete().click();
|
|
|
|
e2e.pages.DataSources.visit();
|
|
|
|
// @todo replace `e2e.pages.DataSources.dataSources` with this when argument is empty
|
|
e2e()
|
|
.get('[aria-label^="Data source list item "]')
|
|
.each((item) => e2e().wrap(item).should('not.contain', name));
|
|
};
|