Skip to content

Commit

Permalink
wip dashboard access restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
lndrtrbn committed May 29, 2024
1 parent 61a191c commit b931c48
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import DashboardPage from '../model/dashboard.pageModel';
import DashboardDetailsPage from '../model/dashboardDetails.pageModel';
import DashboardFormPage from '../model/form/dashboardForm.pageModel';
import DashboardWidgetsPageModel from '../model/DashboardWidgets.pageModel';
import TopMenuProfilePage from '../model/menu/topMenuProfile.pageModel';
import LoginFormPageModel from '../model/form/loginForm.pageModel';
import LeftBarPage from '../model/menu/leftBar.pageModel';

/**
Expand Down Expand Up @@ -139,3 +141,29 @@ test('TMP DASHBOARD WIDGETS', async ({ page }) => {

await widgetsPage.createNumberOfMalwaresWidget();
});

test('TMP DASHBOARD RESTRICTION', async ({ page }) => {
const dashboardPage = new DashboardPage(page);
const dashboardForm = new DashboardFormPage(page);
const widgetsPage = new DashboardWidgetsPageModel(page);
const leftBar = new LeftBarPage(page);
const topBar = new TopMenuProfilePage(page);
const loginForm = new LoginFormPageModel(page);

await page.goto('/dashboard/workspaces/dashboards');
await leftBar.open();

await dashboardPage.openButtonModal().hover();
await dashboardPage.addNewDashboard().click();
const dashboardName = `Dashboard - ${uuid()}`;
await dashboardForm.nameField.fill(dashboardName);
await dashboardForm.getCreateButton().click();
await dashboardPage.getItemFromList(dashboardName).click();
await widgetsPage.createNumberOfMalwaresWidget();

await leftBar.clickOnMenu('Dashboards');
await topBar.logout();
await loginForm.login('jean.michel@filigran.test', 'jeamichel');

await expect(dashboardPage.getItemFromList(dashboardName)).toBeVisible();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Page } from '@playwright/test';
import TextFieldPageModel from '../field/TextField.pageModel';

export default class LoginFormPageModel {
nameField = new TextFieldPageModel(this.page, 'Login', 'text');
passwordField = new TextFieldPageModel(this.page, 'Password', 'text');

constructor(private page: Page) {}

getPage() {
return this.page.getByTestId('login-page');
}

getSignInButton() {
return this.page.getByRole('button', { name: 'Sign in' });
}

async login(name?: string, pwd?: string) {
await this.nameField.fill(name ?? 'admin@opencti.io');
await this.passwordField.fill(pwd ?? 'admin');
return this.getSignInButton().click();
}
}

0 comments on commit b931c48

Please sign in to comment.