Loki: Add more assertions to loki-query-builder.spec.ts (#56044)

* Add more assertions to loki-query-builder.spec.ts

* Update assertions in loki-query-builder.spec.ts
This commit is contained in:
Gareth Dawson 2022-09-30 14:27:48 +01:00 committed by GitHub
parent 80065c47ab
commit 2338660a62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,8 @@ const addDataSource = () => {
});
};
const finalQuery = 'rate({instance=~"instance1|instance2"} | logfmt | __error__=`` [$__interval]';
describe('Loki query builder', () => {
beforeEach(() => {
e2e.flows.login('admin', 'admin');
@ -37,8 +39,6 @@ describe('Loki query builder', () => {
req.reply({ status: 'success', data: [{ instance: 'instance1' }] });
});
const finalQuery = 'rate({instance=~"instance1|instance2"} | logfmt | __error__=`` [$__interval]';
// Go to Explore and choose Loki data source
e2e.pages.Explore.visit();
e2e.components.DataSourcePicker.container().should('be.visible').click();
@ -72,13 +72,21 @@ describe('Loki query builder', () => {
e2e().contains(MISSING_LABEL_FILTER_ERROR_MESSAGE).should('not.exist');
e2e().contains(finalQuery).should('be.visible');
// Switch to code editor and check if query was parsed
for (const word of finalQuery.split(' ')) {
e2e().contains(word).should('be.visible');
}
// Toggle raw query
e2e().contains('label', 'Raw query').click();
e2e().contains('Raw query').should('have.length', 1);
// Switch to explain mode and check if query is visible
// Change to code editor
e2e().contains('label', 'Code').click();
// We need to test this manually because the final query is split into separate DOM elements using e2e().contains(finalQuery).should('be.visible'); does not detect the query.
e2e().contains('rate').should('be.visible');
e2e().contains('instance1|instance2').should('be.visible');
e2e().contains('logfmt').should('be.visible');
e2e().contains('__error__').should('be.visible');
e2e().contains('$__interval').should('be.visible');
// Checks the explain mode toggle
e2e().contains('label', 'Explain').click();
e2e().contains(finalQuery).should('be.visible');
e2e().contains('Fetch all log lines matching label filters.').should('be.visible');
});
});