mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 17:06:57 -06:00
hopefully improve slate test reliability (#58171)
This commit is contained in:
parent
d131733f55
commit
871d98e550
@ -45,58 +45,65 @@ describe('Loki slate editor', () => {
|
|||||||
e2e().contains('Code').click();
|
e2e().contains('Code').click();
|
||||||
const queryField = e2e().get('.slate-query-field');
|
const queryField = e2e().get('.slate-query-field');
|
||||||
queryField.type('time(');
|
queryField.type('time(');
|
||||||
queryField.then(($el) => {
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.eq('time()');
|
expect($el.text().replace(/\uFEFF/g, '')).to.eq('time()');
|
||||||
});
|
});
|
||||||
|
|
||||||
// removes closing brace when opening brace is removed
|
// removes closing brace when opening brace is removed
|
||||||
queryField.type('{backspace}');
|
queryField.type('{backspace}');
|
||||||
queryField.then(($el) => {
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.eq('time');
|
expect($el.text().replace(/\uFEFF/g, '')).to.eq('time');
|
||||||
});
|
});
|
||||||
|
|
||||||
// keeps closing brace when opening brace is removed and inner values exist
|
// keeps closing brace when opening brace is removed and inner values exist
|
||||||
queryField.type(`{selectall}{backspace}time(test{leftArrow}{leftArrow}{leftArrow}{leftArrow}{backspace}`);
|
queryField.clear();
|
||||||
queryField.then(($el) => {
|
queryField.type('time(test{leftArrow}{leftArrow}{leftArrow}{leftArrow}{backspace}');
|
||||||
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.eq('timetest)');
|
expect($el.text().replace(/\uFEFF/g, '')).to.eq('timetest)');
|
||||||
});
|
});
|
||||||
|
|
||||||
// overrides an automatically inserted brace
|
// overrides an automatically inserted brace
|
||||||
queryField.type(`{selectall}{backspace}time()`);
|
queryField.clear();
|
||||||
queryField.then(($el) => {
|
queryField.type('time()');
|
||||||
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.eq('time()');
|
expect($el.text().replace(/\uFEFF/g, '')).to.eq('time()');
|
||||||
});
|
});
|
||||||
|
|
||||||
// does not override manually inserted braces
|
// does not override manually inserted braces
|
||||||
queryField.type(`{selectall}{backspace}))`);
|
queryField.clear();
|
||||||
queryField.then(($el) => {
|
queryField.type('))');
|
||||||
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.eq('))');
|
expect($el.text().replace(/\uFEFF/g, '')).to.eq('))');
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Clear Plugin */
|
/** Clear Plugin */
|
||||||
|
|
||||||
//does not change the empty value
|
//does not change the empty value
|
||||||
queryField.type(`{selectall}{backspace}{ctrl+k}`);
|
queryField.clear();
|
||||||
queryField.then(($el) => {
|
queryField.type('{ctrl+k}');
|
||||||
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.match(/Enter a Loki query/);
|
expect($el.text().replace(/\uFEFF/g, '')).to.match(/Enter a Loki query/);
|
||||||
});
|
});
|
||||||
|
|
||||||
// clears to the end of the line
|
// clears to the end of the line
|
||||||
queryField.type(`{selectall}{backspace}foo{leftArrow}{leftArrow}{leftArrow}{ctrl+k}`);
|
queryField.clear();
|
||||||
queryField.then(($el) => {
|
queryField.type('foo{leftArrow}{leftArrow}{leftArrow}{ctrl+k}');
|
||||||
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.match(/Enter a Loki query/);
|
expect($el.text().replace(/\uFEFF/g, '')).to.match(/Enter a Loki query/);
|
||||||
});
|
});
|
||||||
|
|
||||||
// clears from the middle to the end of the line
|
// clears from the middle to the end of the line
|
||||||
queryField.type(`{selectall}{backspace}foo bar{leftArrow}{leftArrow}{leftArrow}{leftArrow}{ctrl+k}`);
|
queryField.clear();
|
||||||
queryField.then(($el) => {
|
queryField.type('foo bar{leftArrow}{leftArrow}{leftArrow}{leftArrow}{ctrl+k}');
|
||||||
|
queryField.should(($el) => {
|
||||||
expect($el.text().replace(/\uFEFF/g, '')).to.eq('foo');
|
expect($el.text().replace(/\uFEFF/g, '')).to.eq('foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Runner plugin */
|
/** Runner plugin */
|
||||||
|
|
||||||
//should execute query when enter with shift is pressed
|
//should execute query when enter with shift is pressed
|
||||||
queryField.type(`{selectall}{backspace}{shift+enter}`);
|
queryField.clear();
|
||||||
|
queryField.type('{shift+enter}');
|
||||||
e2e().get('[data-testid="explore-no-data"]').should('be.visible');
|
e2e().get('[data-testid="explore-no-data"]').should('be.visible');
|
||||||
|
|
||||||
/** Suggestions plugin */
|
/** Suggestions plugin */
|
||||||
|
Loading…
Reference in New Issue
Block a user