mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-07 13:07:22 +00:00
UI : Roles and Policy Cypress Test (#7418)
This commit is contained in:
parent
a633085eb9
commit
84c36dc57d
@ -25,14 +25,15 @@ const policies = {
|
||||
teamOnlyAccessPolicy: 'Team only access Policy',
|
||||
};
|
||||
|
||||
const ruledetails = {
|
||||
const ruleDetails = {
|
||||
resources: 'All',
|
||||
operations: 'All',
|
||||
effect: 'Allow',
|
||||
condition: 'isOwner()',
|
||||
inValidCondition:'isOwner('
|
||||
};
|
||||
|
||||
const errormessageValidation = {
|
||||
const errorMessageValidation = {
|
||||
lastPolicyCannotBeRemoved: 'At least one policy is required in a role',
|
||||
lastRuleCannotBeRemoved: 'At least one rule is required in a policy',
|
||||
};
|
||||
@ -41,7 +42,7 @@ const policyName = `Policy-test-${uuid()}`;
|
||||
const description = `This is ${policyName} description`;
|
||||
|
||||
const ruleName = `Rule-test-${uuid()}`;
|
||||
const ruledescription = `This is ${ruleName} description`;
|
||||
const ruleDescription = `This is ${ruleName} description`;
|
||||
const updatedDescription = 'This is updated description';
|
||||
|
||||
const newRuleName = `New-Rule-test-${uuid()}`;
|
||||
@ -49,13 +50,13 @@ const newRuledescription = `This is ${newRuleName} description`;
|
||||
|
||||
const updatedRuleName = `New-Rule-test-${uuid()}-updated`;
|
||||
|
||||
const addRule = (rulename, ruledescription, descriptionIndex) => {
|
||||
const addRule = (rulename, ruleDescription, descriptionIndex) => {
|
||||
cy.get('[data-testid="rule-name"]').should('be.visible').type(rulename);
|
||||
//Enter rule description
|
||||
cy.get('.toastui-editor-md-container > .toastui-editor > .ProseMirror')
|
||||
.eq(descriptionIndex)
|
||||
.scrollIntoView()
|
||||
.type(ruledescription);
|
||||
.type(ruleDescription);
|
||||
//Select resource dropdown
|
||||
cy.get('[data-testid="resuorces"]')
|
||||
.scrollIntoView()
|
||||
@ -70,10 +71,15 @@ const addRule = (rulename, ruledescription, descriptionIndex) => {
|
||||
|
||||
cy.get('.ant-select-tree-checkbox-inner').eq(1).should('be.visible').click();
|
||||
//Click on condition combobox
|
||||
|
||||
cy.get('[id*=rc_select]').scrollIntoView().should('be.visible').click();
|
||||
|
||||
cy.get(`[title="${ruledetails.condition}"]`).should('be.visible').click();
|
||||
cy.get(`[title="${ruleDetails.condition}"]`).should('be.visible').click();
|
||||
|
||||
cy.get('.ant-card-body').should('be.visible').click();
|
||||
|
||||
cy.get('[data-testid="condition-success"]').contains('✅ Valid condition')
|
||||
|
||||
cy.wait(500);
|
||||
//Submit
|
||||
cy.get('[data-testid="submit-btn"]')
|
||||
@ -82,7 +88,7 @@ const addRule = (rulename, ruledescription, descriptionIndex) => {
|
||||
.click();
|
||||
};
|
||||
|
||||
describe('Roles page should work properly', () => {
|
||||
describe('Policy page should work properly', () => {
|
||||
beforeEach(() => {
|
||||
cy.goToHomePage();
|
||||
cy.intercept('GET', '*api/v1/policies*').as('getPolicies');
|
||||
@ -128,7 +134,7 @@ describe('Roles page should work properly', () => {
|
||||
.eq(0)
|
||||
.type(description);
|
||||
//Enter rule name
|
||||
addRule(ruleName, ruledescription, 1);
|
||||
addRule(ruleName, ruleDescription, 1);
|
||||
|
||||
cy.wait(1000);
|
||||
//Validate the added policy
|
||||
@ -149,26 +155,26 @@ describe('Roles page should work properly', () => {
|
||||
//verify rule description
|
||||
cy.get('[data-testid="viewer-container"] > [data-testid="markdown-parser"]')
|
||||
.should('be.visible')
|
||||
.should('contain', ruledescription);
|
||||
.should('contain', ruleDescription);
|
||||
|
||||
//Verify other details
|
||||
cy.get('[data-testid="rule-name"]').should('be.visible').click();
|
||||
|
||||
cy.get('[data-testid="resources"]')
|
||||
.should('be.visible')
|
||||
.should('contain', ruledetails.resources);
|
||||
.should('contain', ruleDetails.resources);
|
||||
|
||||
cy.get('[data-testid="operations"]')
|
||||
.should('be.visible')
|
||||
.should('contain', ruledetails.operations);
|
||||
.should('contain', ruleDetails.operations);
|
||||
|
||||
cy.get('[data-testid="effect"]')
|
||||
.should('be.visible')
|
||||
.should('contain', ruledetails.effect);
|
||||
.should('contain', ruleDetails.effect);
|
||||
|
||||
cy.get('[data-testid="condition"]')
|
||||
.should('be.visible')
|
||||
.should('contain', ruledetails.condition);
|
||||
.should('contain', ruleDetails.condition);
|
||||
});
|
||||
|
||||
it('Edit policy description', () => {
|
||||
@ -214,19 +220,19 @@ describe('Roles page should work properly', () => {
|
||||
|
||||
cy.get('[data-testid="resources"]').last().scrollIntoView()
|
||||
.should("exist")
|
||||
.should('contain', ruledetails.resources);
|
||||
.should('contain', ruleDetails.resources);
|
||||
|
||||
cy.get('[data-testid="operations"]').last().scrollIntoView()
|
||||
.should("exist")
|
||||
.should('contain', ruledetails.operations);
|
||||
.should('contain', ruleDetails.operations);
|
||||
|
||||
cy.get('[data-testid="effect"]').last().scrollIntoView()
|
||||
.should("exist")
|
||||
.should('contain', ruledetails.effect);
|
||||
.should('contain', ruleDetails.effect);
|
||||
|
||||
cy.get('[data-testid="condition"]').last().scrollIntoView()
|
||||
.should("exist")
|
||||
.should('contain', ruledetails.condition);
|
||||
.should('contain', ruleDetails.condition);
|
||||
});
|
||||
|
||||
it('Edit rule name for created Rule', () => {
|
||||
@ -296,7 +302,7 @@ describe('Roles page should work properly', () => {
|
||||
|
||||
cy.get('.Toastify__toast-body')
|
||||
.should('be.visible')
|
||||
.should('contain', errormessageValidation.lastRuleCannotBeRemoved);
|
||||
.should('contain', errorMessageValidation.lastRuleCannotBeRemoved);
|
||||
});
|
||||
|
||||
it('Delete created policy', () => {
|
||||
|
||||
@ -24,7 +24,7 @@ const policies = {
|
||||
organizationPolicy: 'Organization Policy',
|
||||
};
|
||||
|
||||
const errormessageValidation = {
|
||||
const errorMessageValidation = {
|
||||
ifPolicyNotSelected: 'At least one policy is required!',
|
||||
ifNameNotEntered: 'invalid name',
|
||||
lastPolicyCannotBeRemoved: 'At least one policy is required in a role',
|
||||
@ -83,7 +83,7 @@ describe('Roles page should work properly', () => {
|
||||
.should('be.visible');
|
||||
});
|
||||
|
||||
it('Add new role', () => {
|
||||
it('Add new role and check all tabs data', () => {
|
||||
cy.get('[data-testid="add-role"]').contains('Add Role').should('be.visible').click();
|
||||
|
||||
//Asserting navigation
|
||||
@ -122,20 +122,43 @@ describe('Roles page should work properly', () => {
|
||||
`http://localhost:8585/settings/access/roles/${roleName}`
|
||||
);
|
||||
cy.get('[data-testid="inactive-link"]').should('contain', roleName);
|
||||
|
||||
//Verify added description
|
||||
cy.get('[data-testid="description"] > [data-testid="viewer-container"]')
|
||||
.should('be.visible')
|
||||
.should('contain', description);
|
||||
|
||||
// click on the policies tab
|
||||
cy.get('[role="tab"]').contains("Policies").should("be.visible").click()
|
||||
|
||||
//Verifying the added policies
|
||||
cy.get('.ant-table-cell')
|
||||
.should('contain', policies.dataConsumerPolicy)
|
||||
.should('be.visible')
|
||||
.and('contain', policies.dataStewardPolicy)
|
||||
.should('be.visible');
|
||||
//Verify added description
|
||||
cy.get('[data-testid="description"] > [data-testid="viewer-container"]')
|
||||
.should('be.visible')
|
||||
.should('contain', description);
|
||||
|
||||
// click on the teams tab
|
||||
cy.get('[role="tab"]').contains("Teams").should("be.visible").click()
|
||||
|
||||
// check for empty table
|
||||
cy.get("table").should("be.visible")
|
||||
cy.get(".ant-empty").should("be.visible")
|
||||
|
||||
// click on the users tab
|
||||
cy.get('[role="tab"]').contains("Users").should("be.visible").click()
|
||||
|
||||
// check for empty table
|
||||
cy.get("table").should("be.visible")
|
||||
cy.get(".ant-empty").should("be.visible")
|
||||
|
||||
//Navigating to roles tab to verify the added role
|
||||
cy.get('[data-testid="breadcrumb-link"]').first().click();
|
||||
cy.get('table').should('be.visible').should('contain', roleName);
|
||||
cy.get('[data-testid="plus-more-count"]').should("be.visible").contains("+1 more").click()
|
||||
|
||||
// second policy should be visible on tooltip
|
||||
cy.get('[role="tooltip"]').should("be.visible").contains(policies.dataStewardPolicy)
|
||||
});
|
||||
|
||||
it('Add new role without selecting data', () => {
|
||||
@ -158,31 +181,11 @@ describe('Roles page should work properly', () => {
|
||||
//Verify the error message that is displayed
|
||||
cy.get('[role="alert"]').should(
|
||||
'contain',
|
||||
errormessageValidation.ifPolicyNotSelected
|
||||
errorMessageValidation.ifPolicyNotSelected
|
||||
);
|
||||
});
|
||||
|
||||
it('Verify Teams and Users naviagtion', () => {
|
||||
cy.get('[data-testid="role-name"]')
|
||||
.contains(roleName)
|
||||
.should('be.visible')
|
||||
.click();
|
||||
//Asserting navigation
|
||||
cy.get('[data-testid="inactive-link"]')
|
||||
.should('contain', roleName)
|
||||
.should('be.visible');
|
||||
|
||||
//Click on Teams tab
|
||||
cy.get('[role="tab"]').contains('Teams').should('be.visible').click();
|
||||
|
||||
cy.get('.ant-table-tbody').should('be.visible');
|
||||
//Click on Users tab
|
||||
cy.get('[role="tab"]').contains('Users').should('be.visible').click();
|
||||
|
||||
cy.get('.ant-table-tbody').should('be.visible');
|
||||
});
|
||||
|
||||
it('Edit created rule', () => {
|
||||
it('Edit created role', () => {
|
||||
//Edit description
|
||||
cy.get('[data-testid="role-name"]')
|
||||
.contains(roleName)
|
||||
@ -200,11 +203,9 @@ describe('Roles page should work properly', () => {
|
||||
cy.get('[data-testid="description"] > [data-testid="viewer-container"]')
|
||||
.should('be.visible')
|
||||
.should('contain', `${description}-updated`);
|
||||
|
||||
//Edit policies, teams and users later
|
||||
});
|
||||
|
||||
it('Add policy to created role', () => {
|
||||
it('Add new policy to created role', () => {
|
||||
cy.get('[data-testid="role-name"]')
|
||||
.contains(roleName)
|
||||
.should('be.visible')
|
||||
@ -294,7 +295,7 @@ describe('Roles page should work properly', () => {
|
||||
|
||||
cy.get('.Toastify__toast-body')
|
||||
.should('be.visible')
|
||||
.should('contain', errormessageValidation.lastPolicyCannotBeRemoved);
|
||||
.should('contain', errorMessageValidation.lastPolicyCannotBeRemoved);
|
||||
|
||||
cy.get('[data-testid="entity-name"]').should(
|
||||
'contain',
|
||||
|
||||
@ -296,7 +296,7 @@ const RuleForm: FC<RuleFormProps> = ({ ruleData, setRuleData }) => {
|
||||
onSearch={handleConditionSearch}
|
||||
/>
|
||||
{validationError && (
|
||||
<div className="tw-mt-1" role="alert">
|
||||
<div className="tw-mt-1" data-testid="condition-error" role="alert">
|
||||
{`❌ Invalid condition : ${validationError}`}
|
||||
</div>
|
||||
)}
|
||||
@ -306,7 +306,10 @@ const RuleForm: FC<RuleFormProps> = ({ ruleData, setRuleData }) => {
|
||||
</div>
|
||||
)}
|
||||
{isValidCondition && !isValidatingCondition && !validationError && (
|
||||
<div className="tw-mt-1" role="alert">
|
||||
<div
|
||||
className="tw-mt-1"
|
||||
data-testid="condition-success"
|
||||
role="alert">
|
||||
✅ Valid condition
|
||||
</div>
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user