Files
openobserve/tests/ui-testing/playwright-tests/usersOrg.spec.js
T
Shyam Panjiyar e2b9334aa9 test: adding organizations revamp playwright (#7261)
### **PR Type**
adding organizations revamp playwright


___

### **Description**
- Enabled "Add Organization Successfully" test

- Enabled empty-name save-disabled test

- Enabled cancel prevents addition test

- Enabled blank-name error message test


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>usersOrg.spec.js</strong><dd><code>Unskip organization
add tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></summary>
<hr>

tests/ui-testing/playwright-tests/usersOrg.spec.js

<li>Removed <code>test.skip</code> on org-add success test<br> <li>
Removed skip on empty-name save-disabled test<br> <li> Removed skip on
cancel prevents addition test<br> <li> Removed skip on blank-name error
message test


</details>


  </td>
<td><a
href="https://github.com/openobserve/openobserve/pull/7261/files#diff-01a0201901f4022cf6708a20432f8a70bc20ac5ccdb9943fd5a6b41eaf0e550b">+4/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

___

> <details> <summary> Need help?</summary><li>Type <code>/help how to
...</code> in the comments thread for any questions about PR-Agent
usage.</li><li>Check out the <a
href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a>
for more information.</li></details>
2025-06-20 11:18:07 +05:30

268 lines
9.4 KiB
JavaScript

import { test, expect } from "./baseFixtures.js";
import { LoginPage } from '../pages/loginPage.js';
import { UserPage } from "../pages/userPage.js";
import { CreateOrgPage } from "../pages/createOrgPage.js";
test.describe("Users and Organizations", () => {
let loginPage, userPage, createOrgPage;
const timestamp = Date.now();
const randomSuffix = Math.floor(Math.random() * 1000);
const emailName = `email${timestamp}${randomSuffix}@gmail.com`;
const orgName = `Organ${timestamp}${randomSuffix}`;
test.beforeEach(async ({ page }) => {
loginPage = new LoginPage(page);
userPage = new UserPage(page);
createOrgPage = new CreateOrgPage(page);
await loginPage.gotoLoginPage();
await loginPage.loginAsInternalUser();
await loginPage.login();
});
test("Error Message displayed if Email Blank", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser("");
await userPage.userCreate();
await userPage.verifySuccessMessage('Please enter a valid email address');
});
test("Error Message displayed if Add user with missing role", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.userCreate();
await userPage.verifySuccessMessage('Field is required');
});
test("User created with password and first name and last name", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.verifySuccessMessage('User added successfully.');
});
test("User not created if Email already exists", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.verifySuccessMessage('User added successfully.');
await userPage.page.waitForTimeout(5000);
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.userCreate();
await userPage.verifySuccessMessage('User is already part of the organization');
});
test("User not created if Cancel clicked on first Add User Page", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await page.locator('[data-test="cancel-user-button"]').click();
await userPage.page.waitForTimeout(1000);
await userPage.gotoIamPage();
await userPage.searchUser(emailName);
await userPage.verifyUserNotExists();
});
test("User not created if Cancel clicked on second Add User Page", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.page.waitForTimeout(1000);
await page.locator('[data-test="cancel-user-button"]').click();
await userPage.page.waitForTimeout(1000);
await userPage.gotoIamPage();
await userPage.searchUser(emailName);
await userPage.verifyUserNotExists();
});
test("User Created and deleted", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.verifySuccessMessage('User added successfully.');
await userPage.page.waitForTimeout(1000);
await userPage.gotoIamPage();
await userPage.deleteUser(emailName);
await userPage.verifySuccessMessage('User deleted successfully.');
});
test("User Created and not deleted if cancel clicked", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.verifySuccessMessage('User added successfully.');
await userPage.page.waitForTimeout(1000);
await userPage.gotoIamPage();
await userPage.deleteUserCancel(emailName);
await userPage.gotoIamPage();
await userPage.searchUser(emailName);
await userPage.verifyUserExists(emailName);
});
test("User Created and updated First Name and Last Name", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.verifySuccessMessage('User added successfully.');
await userPage.page.waitForTimeout(1000);
await userPage.gotoIamPage();
await userPage.editUser(emailName);
await userPage.addUserFirstLast('c', 'd');
await userPage.userCreate();
await userPage.verifySuccessMessage('User updated successfully.');
});
test("User Created and updated Password", async ({ page }) => {
await userPage.gotoIamPage();
await userPage.addUser(emailName);
await userPage.selectUserRole('Admin');
await userPage.page.waitForTimeout(1000);
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.addUserPassword(process.env["ZO_ROOT_USER_PASSWORD"]);
await userPage.addUserFirstLast('a', 'b');
await userPage.userCreate();
await userPage.page.waitForTimeout(1000);
await userPage.verifySuccessMessage('User added successfully.');
await userPage.page.waitForTimeout(1000);
await userPage.gotoIamPage();
await userPage.editUser(emailName);
await userPage.addNewPassword('1234567890');
await userPage.userCreate();
await userPage.verifySuccessMessage('User updated successfully.');
});
test('Add Organization Successfully', async ({ page }) => {
await createOrgPage.navigateToOrg();
await createOrgPage.clickAddOrg();
await createOrgPage.fillOrgName(orgName);
await createOrgPage.clickSaveOrg();
await userPage.verifySuccessMessage('Organization added successfully.');
});
test('Save button disabled if Add Organization with Empty Name', async ({ page }) => {
await createOrgPage.navigateToOrg();
await createOrgPage.clickAddOrg();
await createOrgPage.fillOrgName('');
await createOrgPage.checkSaveEnabled();
});
test('Organization not added if Cancel clicked', async ({ page }) => {
await createOrgPage.navigateToOrg();
await createOrgPage.clickAddOrg();
await createOrgPage.fillOrgName(orgName);
await createOrgPage.clickCancelButton();
await createOrgPage.navigateToOrg();
await createOrgPage.searchOrg(orgName);
await createOrgPage.verifyOrgNotExists(expect);
});
test('Error Message displayed if Add Organization is blank', async ({ page }) => {
await createOrgPage.navigateToOrg();
await createOrgPage.clickAddOrg();
await createOrgPage.fillOrgName('');
await page.locator('.q-field__bottom').click();
await userPage.verifySuccessMessage('Name is required');
});
});