test: e2e-stream-name (#6764)

Added a test to add stream name and assert if stream with uppercase
exists
add a stream with lowercase and assert if stream name with lowercase
exists
This commit is contained in:
Neha P
2025-05-08 20:16:03 +05:30
committed by GitHub
parent cb18d89e44
commit 3ff97016cf
4 changed files with 135 additions and 0 deletions
+2
View File
@@ -34,6 +34,7 @@ env:
ZO_WEBSOCKET_ENABLED: true
ZO_COLS_PER_RECORD_LIMIT: "80000"
ZO_SMTP_ENABLED: true
ZO_FORMAT_STREAM_NAME_TO_LOWERCASE: false
jobs:
build_binary:
@@ -134,6 +135,7 @@ jobs:
"schemaload.spec.js",
"websocket.spec.js",
"alertImportTDA.spec.js",
"streamname.spec.js"
# "remotepipeline.spec.js",
]
+41
View File
@@ -0,0 +1,41 @@
import { expect } from '@playwright/test';
export class StreamPage {
constructor(page) {
this.page = page;
this.streamExplorerLink = '[data-test="menu-link-/streams-item"]';
this.searchStreamInput = '[placeholder="Search Stream"]';
this.exploreButton = 'button:has-text("Explore")';
}
async navigateToStreamExplorer() {
await this.page.locator(this.streamExplorerLink).click({ force: true });
await this.page.waitForTimeout(1000);
}
async searchStream(streamName) {
await this.page.getByPlaceholder("Search Stream").click();
await this.page.getByPlaceholder("Search Stream").fill(streamName);
await this.page.waitForTimeout(3000);
}
async verifyStreamNameVisibility(streamName) {
await expect(this.page.getByText(streamName)).toBeVisible();
}
async exploreStream() {
const streamButton = this.page.getByRole("button", { name: 'Explore' });
await expect(streamButton).toBeVisible();
await streamButton.click({ force: true });
await this.page.waitForTimeout(1000);
}
async verifyStreamExploration() {
await expect(this.page.url()).toContain("logs");
}
async goBack() {
await this.page.goBack();
await this.page.waitForTimeout(1000);
}
}
@@ -0,0 +1,64 @@
import { test, expect } from "./baseFixtures";
import { LogsPage } from '../pages/logsPage.js';
import { StreamPage } from '../pages/streamPage.js';
import { getHeaders, getIngestionUrl, sendRequest } from '../utils/apiUtils.js';
test.describe.configure({ mode: "parallel" });
async function login(page) {
await page.goto(process.env["ZO_BASE_URL"]);
await page.waitForTimeout(1000);
if (await page.getByText('Login as internal user').isVisible()) {
await page.getByText('Login as internal user').click();
}
await page.locator('[data-cy="login-user-id"]').fill(process.env["ZO_ROOT_USER_EMAIL"]);
await page.locator("label").filter({ hasText: "Password *" }).click();
await page.locator('[data-cy="login-password"]').fill(process.env["ZO_ROOT_USER_PASSWORD"]);
await page.locator('[data-cy="login-sign-in"]').click();
}
test.describe("Stream multiselect testcases", () => {
let logsPage;
let streamPage;
test.beforeEach(async ({ page }) => {
await login(page);
logsPage = new LogsPage(page);
streamPage = new StreamPage(page);
await page.waitForTimeout(5000);
});
test("should preserve stream name casing after ingestion and show in stream explorer", async ({ page }) => {
const orgId = process.env["ORGNAME"];
const headers = getHeaders();
const streams = [
{ name: "MyUpperStream1" },
{ name: "mylowerstream1" },
];
// Ingest data into streams
for (const stream of streams) {
const ingestionUrl = getIngestionUrl(orgId, stream.name);
const payload = {
level: "info",
job: "test",
log: `test message for stream ${stream.name}`,
e2e: "1",
};
const response = await sendRequest(page, ingestionUrl, payload, headers);
console.log(`Ingested to ${stream.name}:`, response);
}
// Validate streams in Stream Explorer
for (const stream of streams) {
await streamPage.navigateToStreamExplorer();
await streamPage.searchStream(stream.name);
await streamPage.verifyStreamNameVisibility(stream.name);
await streamPage.exploreStream();
await streamPage.verifyStreamExploration();
await streamPage.goBack();
}
});
});
+28
View File
@@ -0,0 +1,28 @@
export const getHeaders = () => {
const basicAuthCredentials = Buffer.from(
`${process.env["ZO_ROOT_USER_EMAIL"]}:${process.env["ZO_ROOT_USER_PASSWORD"]}`
).toString("base64");
return {
Authorization: `Basic ${basicAuthCredentials}`,
"Content-Type": "application/json",
};
};
export const getIngestionUrl = (orgId, streamName) => {
return `${process.env.INGESTION_URL}/api/${orgId}/${streamName}/_json`;
};
export const sendRequest = async (page, url, payload, headers) => {
return await page.evaluate(
async ({ url, headers, payload }) => {
const response = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload),
});
return await response.json();
},
{ url, headers, payload }
);
};