Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions e2e-tests/pages/AccessPermissionsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class AccessPermissionsTab extends BasePage {
return this.page.getByRole('Button', {name: 'add'});
}

private get confirmButton() {
return this.page.getByRole('Button', {name: 'confirm'});
}

async addPermission(username: string, role: string) {
await this.usernameInput.fill(username);
await this.page.getByRole('option', { name: username }).click();
Expand All @@ -27,6 +31,11 @@ export class AccessPermissionsTab extends BasePage {


await this.addButton.click();

if (await this.confirmButton.count() > 0) {
await this.confirmButton.click();
}

await expect(this.page.getByRole("cell", {name: username})).toBeVisible();
await expect(this.page.getByRole("cell", {name: role})).toBeVisible();

Expand Down
1 change: 1 addition & 0 deletions e2e-tests/pages/ActivityPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class ActivityPage extends BasePage {

async createActivity(name: string, description: string, type: string): Promise<void> {
await this.createButton.click();
await this.waitForPageLoad();
await this.nameInput.fill(name);
await this.descriptionInput.fill(description);
await this.typeDropdown.click();
Expand Down
9 changes: 9 additions & 0 deletions e2e-tests/pages/DatasetListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ export class DatasetListPage extends BasePage {
await expect(card).toContainText(dataset.description);
}

async verifyDatasetEditable(dataset: {
name: string;
}): Promise<void> {
const card = this.datasetCardWithName(dataset.name);
await expect(card
.locator('[data-testid^="edit-button"]')
.first()).toBeVisible();
}

async useAnyDataset(): Promise<void> {
const card = this.page.locator('.dataset-card').first();
await card.locator('button:has-text("Select and proceed")').click();
Expand Down
8 changes: 8 additions & 0 deletions e2e-tests/pages/MeasurePage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {BasePage} from './BasePage';

export class MeasurePage extends BasePage {
async visit(): Promise<void> {
await this.page.goto('/measures');
await this.waitForPageLoad();
}
}
8 changes: 8 additions & 0 deletions e2e-tests/pages/ParticipantPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { BasePage } from './BasePage';

export class ParticipantPage extends BasePage {
async visit(): Promise<void> {
await this.page.goto('/participants');
await this.waitForPageLoad();
}
}
97 changes: 94 additions & 3 deletions e2e-tests/tests/process.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { RegistrationPage } from '../pages/RegistrationPage';
import {SettingsPage} from "../pages/SettingsPage";
import {AccessPermissionsTab} from "../pages/AccessPermissionsTab";
import generateDate from '../utils/generate-date-util';
import {MeasurePage} from "../pages/MeasurePage";

const hash = Math.random().toString(36).substring(2);

Expand Down Expand Up @@ -360,23 +361,24 @@ test.describe.serial('Przejście całego procesu', () => {
await registrationPage.register(usernameOther, emailOther, emailOther, firstNameOther, lastNameOther);
});

test('[12] - Użytkownik dodaje uprawnienia dostępu', async ({ userPage }) => {
test('[12] - Użytkownik dodaje uprawnienia dostępu do odczytu', async ({ userPage }) => {
await selectDataset(userPage);
await new SettingsPage(userPage).visit();
const accessPermissionsTab = new AccessPermissionsTab(userPage);
await accessPermissionsTab.visit();
await accessPermissionsTab.addPermission(usernameOther, 'Reader');
});

test('[13] - Inny użytkonik nie może tworzyć eksperymentu', async ({ otherUserPage }) => {
test('[13] - Inny użytkonik [Reader] nie może tworzyć eksperymentu', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const experimentPage = new ExperimentPage(otherUserPage);
await experimentPage.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(0);
});

test('[14] - Inny użytkonik nie może edytować składowych eksperymentu', async ({ otherUserPage }) => {
test('[14] - Inny użytkonik [Reader] nie może edytować składowych eksperymentu', async ({ otherUserPage }) => {

await selectDataset(otherUserPage);

await (new ExperimentListPage(otherUserPage)).useExperimentByName(newExperiment.name);
Expand All @@ -397,6 +399,95 @@ test.describe.serial('Przejście całego procesu', () => {
await recordingsTab.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(0);
});

test('[15] - Inny użytkonik [Reader] nie może tworzyć aktywności', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const activityPage = new ActivityPage(otherUserPage);
await activityPage.visit();
await otherUserPage.waitForTimeout(3000);
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(0);
});

test('[16] - Inny użytkonik [Reader] nie może tworzyć uczestników', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const measurePage = new MeasurePage(otherUserPage);
await measurePage.visit();
await otherUserPage.waitForTimeout(3000);
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(0);
});

test('[17] - Inny użytkonik [Reader] nie może odwiedzić ustawień', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const settingsPage = new SettingsPage(otherUserPage);
await settingsPage.visit();
await expect(otherUserPage).toHaveURL(/.*\/access-denied/);
});

test('[18] - Użytkownik dodaje uprawnienia dostępu do edycji', async ({ userPage }) => {
await selectDataset(userPage);
await new SettingsPage(userPage).visit();
const accessPermissionsTab = new AccessPermissionsTab(userPage);
await accessPermissionsTab.visit();
await accessPermissionsTab.addPermission(usernameOther, 'Editor');
});

test('[19] - Inny użytkonik [Editor] może tworzyć eksperyment', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const experimentPage = new ExperimentPage(otherUserPage);
await experimentPage.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(0);
});

test('[20] - Inny użytkonik [Editor] może edytować składowe eksperymentu', async ({ otherUserPage }) => {

await selectDataset(otherUserPage);

await (new ExperimentListPage(otherUserPage)).useExperimentByName(newExperiment.name);

const participantsTab = new ParticipantsTab(otherUserPage);
await participantsTab.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Add' }).first()).toHaveCount(1);

const scenariosTab = new ScenariosTab(otherUserPage);
await scenariosTab.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(1);

const scenariosExecutionTab = new ScenariosExecutionsTab(otherUserPage);
await scenariosExecutionTab.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(1);

const recordingsTab = new RecordingsTab(otherUserPage);
await recordingsTab.visit();
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(1);
});

test('[21] - Inny użytkonik [Editor] może tworzyć aktywności', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const activityPage = new ActivityPage(otherUserPage);
await activityPage.visit();
await otherUserPage.waitForTimeout(3000);
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(1);
});

test('[22] - Inny użytkonik [Editor] może tworzyć uczestników', async ({ otherUserPage }) => {
await selectDataset(otherUserPage);

const measurePage = new MeasurePage(otherUserPage);
await measurePage.visit();
await otherUserPage.waitForTimeout(3000);
await expect(otherUserPage.getByRole('Button', { name: 'Create' }).first()).toHaveCount(1);
});

test('[23] - Inny użytkonik [Editor] widzi ustawień', async ({ userPage }) => {
await selectDataset(userPage);
await expect(userPage.getByRole('link', { name: 'Settings' })).toHaveCount(1);
});

});

async function selectDataset(page: Page) {
Expand Down
2 changes: 2 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import datasetRoutes from '@/router/datasetRoutes';
import ClassesDescriptions from '@/const/ClassesDescriptions';
import AuthService from '@/services/AuthService';
import store from '@/store/index';
import AccessRoles from '@/const/AccessRoles';

Vue.use(VueRouter);

Expand Down Expand Up @@ -56,6 +57,7 @@ const routes = [
name: 'settings',
component: () => import('@/views/settings/SettingsView.vue'),
meta: {
canEnterRoles: [AccessRoles.EDITOR, AccessRoles.OWNER],
icon: 'mdi-cog',
order: 20,
name: 'Settings',
Expand Down
2 changes: 1 addition & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const store = new Vuex.Store({
getters: {
getUser: state => state.user,
getDataset: state => state.dataset,
getPermission: state => state.permissions.filter(permission => permission.datasetId == state.dataset.id)[0],
getPermission: state => state.permissions.filter(permission => permission.datasetId === state.dataset.id)[0],
},
plugins: [createPersistedState()],
});
Expand Down
14 changes: 6 additions & 8 deletions src/views/datasets/DatasetDetailedView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@
import DatasetAPI from '@/api/DatasetAPI';
import AppBreadcrumbs from '@/components/AppBreadcrumbs.vue';
import InfoToolTipComponent from '@/components/InfoToolTipComponent.vue';
import config from '../../../config.js';
import { mapState } from 'vuex';

import PermissionsService from '@/services/PermissionsService';
import Roles from '@/const/AccessRoles';
import router from '@/router';

export default {
name: 'DatasetDetailedView',
Expand Down Expand Up @@ -131,9 +131,6 @@ export default {
buttonText() {
return this.editMode ? 'update' : 'create';
},
tokenExpiration() {
return new Date().getTime() + config.sessionDurationMinutes * 60000;
},
},
watch: {
'$route.params.id': {
Expand All @@ -160,13 +157,14 @@ export default {
} else {
DatasetAPI.store(this.dataset)
.then(({ data }) => {
PermissionsService.add({
return PermissionsService.add({
userId: this.user.sub,
datasetId: data.id,
role: Roles.OWNER,
}).then(({ data }) => {
localStorage.setItem('token', data.token);
localStorage.setItem('tokenExpiration', this.tokenExpiration);
}).then(_ => {
PermissionsService.getUserPermissions(this.user.sub).then(data =>
router.app.$store.commit('setPermissions', data.data));
}).then(_ => {
this.$router.push('/datasets');
});
});
Expand Down
1 change: 1 addition & 0 deletions src/views/datasets/DatasetsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<v-card-actions>
<v-icon
color="primary"
data-testid="edit-button"
@click="() => {
selectCurrentDataset(dataset);
$router.push({
Expand Down
6 changes: 3 additions & 3 deletions src/views/experiment-details/tabs/RecordingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export default {
onCreation() {
const filteredData = [];
if (this.experiment.scenarioExecutions) {
this.experiment.scenarioExecutions.forEach(obj => {
obj.activityExecutions.forEach(obj2 => {
this.experiment.scenarioExecutions?.forEach(obj => {
obj.activityExecutions?.forEach(obj2 => {
if (obj2.recordings)
obj2.recordings.forEach(obj3 => {
obj2.recordings?.forEach(obj3 => {
filteredData.push({
...obj3, activityExecution: obj2, scenarioExecution: obj,
scenarioExecution_name: obj.name, activityExecution_name: obj2.name,
Expand Down
21 changes: 17 additions & 4 deletions src/views/settings/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
v-for="taba in tabs"
:key="taba.id"
ripple
:disabled="taba.disabled"
>
{{ taba.name }}
</v-tab>
Expand All @@ -43,6 +44,8 @@ import LocalStorageService from '@/storage/LocalStorageService';
import ParametersTab from '@/views/settings/tabs/ParametersTab';
import AccessPermissionsTab from '@/views/settings/tabs/AccessPermissionsTab.vue';
import AppBreadcrumbs from '@/components/AppBreadcrumbs.vue';
import AccessRoles from '@/const/AccessRoles';
import { mapGetters } from 'vuex';

export default {
name: 'SettingsView',
Expand All @@ -54,12 +57,22 @@ export default {
data() {
return {
tab: 0,
tabs: [
{ id: 1, name: 'Parameters' },
{ id: 2, name: 'Access permissions' },
],
};
},
computed: {
...mapGetters({
getPermission: 'getPermission',
}),
isOwner() {
return this.getPermission.role === AccessRoles.OWNER;
},
tabs() {
return [
{ id: 1, name: 'Parameters', disabled: false },
{ id: 2, name: 'Access permissions', disabled: !this.isOwner },
];
},
},
methods: {
resetStorage() {
LocalStorageService.clear();
Expand Down