[Console] Fix status badges not showing on cloud (#140873) (#140904)

* Fix status badges not showing up in cloud

* Unskip related test file

Co-authored-by: Muhammad Ibragimov <muhammad.ibragimov@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit cd52a2e641)

Co-authored-by: Muhammad Ibragimov <53621505+mibragimov@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2022-09-19 02:57:45 -06:00 committed by GitHub
parent 776e136206
commit d138ee997b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 19 deletions

View file

@ -12,8 +12,8 @@ import { addXJsonToRules } from '@kbn/ace';
const JsonHighlightRules = ace.acequire('ace/mode/json_highlight_rules').JsonHighlightRules;
export const mapStatusCodeToBadge = (value: string) => {
const regExpMatchArray = value.match(/\d+/);
export const mapStatusCodeToBadge = (value?: string) => {
const regExpMatchArray = value?.match(/\d+/);
if (regExpMatchArray) {
const status = parseInt(regExpMatchArray[0], 10);
if (status <= 199) {
@ -44,11 +44,15 @@ export class OutputJsonHighlightRules extends JsonHighlightRules {
},
{
token: 'comment',
regex: /#(.*?)(?=\d+\s(?:[\sA-Za-z]+)|$)/,
// match a comment starting with a hash at the start of the line
// ignore status codes and status texts at the end of the line (e.g. # GET _search/foo 200, # GET _search/foo 200 OK)
regex: /#(.*?)(?=[1-5][0-9][0-9]\s(?:[\sA-Za-z]+)|(?:[1-5][0-9][0-9])|$)/,
},
{
token: mapStatusCodeToBadge,
regex: /(\d+\s[\sA-Za-z]+$)/,
// match status codes and status texts at the end of the line (e.g. # GET _search/foo 200, # GET _search/foo 200 OK)
// this rule allows us to highlight them with the corresponding badge color (e.g. 200 OK -> badge.badge--success)
regex: /([1-5][0-9][0-9]\s?[\sA-Za-z]+$)/,
}
);

View file

@ -144,10 +144,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});
// Skip on cloud until issue is fixed
// Issue: https://github.com/elastic/kibana/issues/138762
describe('multiple requests output', function () {
this.tags(['skipCloudFailedTest']);
const sendMultipleRequests = async (requests: string[]) => {
await asyncForEach(requests, async (request) => {
await PageObjects.console.enterRequest(request);

View file

@ -211,21 +211,11 @@ export class ConsolePageObject extends FtrService {
}
public async hasSuccessBadge() {
try {
const responseEditor = await this.testSubjects.find('response-editor');
return Boolean(await responseEditor.findByCssSelector('.ace_badge--success'));
} catch (e) {
return false;
}
return await this.find.existsByCssSelector('.ace_badge--success');
}
public async hasWarningBadge() {
try {
const responseEditor = await this.testSubjects.find('response-editor');
return Boolean(await responseEditor.findByCssSelector('.ace_badge--warning'));
} catch (e) {
return false;
}
return await this.find.existsByCssSelector('.ace_badge--warning');
}
public async hasInvalidSyntax() {