Skip to content

Commit

Permalink
Merge branch 'main' into IrKa/ontology-class-item-requests
Browse files Browse the repository at this point in the history
* main:
  fix: multi-language form default language (#1353)
  test: dashboard e2e tests for users and admin (#1355)
  fix: delete failing e2e test
  fix: add tooltip on non accessible list (#1345)
  fix: close dialog after update (#1352)
  • Loading branch information
irmastnt committed Jan 18, 2024
2 parents 65b5425 + e5fb2fe commit 6909ffc
Show file tree
Hide file tree
Showing 28 changed files with 236 additions and 216 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tmp/

# Ignore certain project files
docs/assets/js/
apps/dsp-app/cypress/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ Thumbs.db

#E2E
/.nx
apps/dsp-app-e2e/cypress/screenshots
apps/dsp-app/cypress/screenshots

This file was deleted.

5 changes: 0 additions & 5 deletions apps/dsp-app-e2e/cypress/fixtures/example.json

This file was deleted.

44 changes: 0 additions & 44 deletions apps/dsp-app-e2e/cypress/support/commands/login.ts

This file was deleted.

29 changes: 0 additions & 29 deletions apps/dsp-app-e2e/project.json

This file was deleted.

9 changes: 0 additions & 9 deletions apps/dsp-app-e2e/tsconfig.json

This file was deleted.

File renamed without changes.
15 changes: 15 additions & 0 deletions apps/dsp-app/cypress/e2e/logged-out-user/dashboard.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Visual Check for Projects on Home Page', () => {
it.skip('should load clickable projects on the home page', () => {
cy.visit('/');

cy.get('[data-cy=accept-cookies]').click();

const projectTileSelector = '[data-cy=tile]';

cy.get(projectTileSelector).should('be.visible').should('have.length.greaterThan', 0);

cy.get(projectTileSelector).first().find('[data-cy=navigate-to-project-button]').click();

cy.url().should('include', '/project'); // Update with the expected URL
});
});
15 changes: 15 additions & 0 deletions apps/dsp-app/cypress/e2e/system-admin/dashboard.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const MY_TOKEN = '';
localStorage.setItem('ACCESS_TOKEN', MY_TOKEN);

describe('ADMIN TEST', () => {
it('should load clickable projects on the home page', () => {
cy.visit('/');
const projectTileSelector = '[data-cy=tile]';

cy.get(projectTileSelector).should('be.visible').should('have.length.greaterThan', 0);

cy.get(projectTileSelector).first().find('[data-cy=navigate-to-project-button]').click();

cy.url().should('include', '/project'); // Update with the expected URL
});
});
File renamed without changes.
25 changes: 25 additions & 0 deletions apps/dsp-app/cypress/support/commands/login.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { User } from '../../models/user-profiles';

Cypress.Commands.add('login', (user: User) => {
cy.session(
user,
() => {
cy.request({
method: 'POST',
url: `${Cypress.env('apiUrl')}/v2/authentication`,
body: {
username: user.username,
password: user.password,
},
}).then(response => {
localStorage.setItem('cookieBanner', 'false');
localStorage.setItem('ACCESS_TOKEN', response.body.token);
});
},
{
validate: () => {
expect(localStorage.getItem('ACCESS_TOKEN')).to.exist;
},
}
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ beforeEach(() => {
// read JSON data file
users = json;

if (Cypress.spec.relative.startsWith('cypress/e2e/System_Admin')) {
if (Cypress.spec.relative.startsWith('cypress/e2e/system-admin')) {
cy.login({
username: users.systemAdmin_username_root,
password: users.systemAdmin_password_root,
});
}

if (Cypress.spec.relative.startsWith('cypress/e2e/Project_Member')) {
if (Cypress.spec.relative.startsWith('cypress/e2e/project-member')) {
cy.login({
username: users.projectMember_username,
password: users.projectMember_password,
Expand Down
13 changes: 13 additions & 0 deletions apps/dsp-app/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"include": [
"**/*.ts"
],
"exclude": [],
"compilerOptions": {
"sourceMap": false,
"types": [
"cypress"
]
}
}
24 changes: 22 additions & 2 deletions apps/dsp-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/dsp-app/**/*.ts", "apps/dsp-app/**/*.html"]
}
"lintFilePatterns": ["apps/dsp-app/**/*.{ts,html}"]
}
},
"test": {
"executor": "@angular-devkit/build-angular:karma",
Expand Down Expand Up @@ -221,6 +221,26 @@
"browsers": "ChromeHeadless"
}
}
},
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/dsp-app/cypress.config.ts"
},
"configurations": {
"production": {
"devServerTarget": "dsp-app:serve:production",
"env": {
"API_URL": "http://0.0.0.0:3333/api"
}
},
"development": {
"devServerTarget": "dsp-app:serve:development",
"env": {
"API_URL": "http://0.0.0.0:3333/api"
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion apps/dsp-app/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<span class="link" (click)="goToCookiePolicy()">use of cookies</span>.
</p>
<div class="action">
<button mat-flat-button color="primary" (click)="closeCookieBanner()">ACCEPT</button>
<button mat-flat-button color="primary" (click)="closeCookieBanner()" data-cy="accept-cookies">ACCEPT</button>
</div>
</div>
</div>
75 changes: 34 additions & 41 deletions apps/dsp-app/src/app/project/data-models/data-models.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,37 @@
</mat-icon>
</div>
<div *ngIf="isAdmin$ | async" class="action-buttons">
<button color="primary" mat-raised-button class="create" (click)="open('add-ontology')">
<a color="primary" mat-raised-button class="create" [routerLink]="['..', RouteConstants.addOntology]">
<mat-icon class="v-align-middle">add_circle</mat-icon>
<span class="v-align-middle">Create New</span>
</button>
<button color="primary" mat-stroked-button class="docs" (click)="open('docs')">
</a>
<a
color="primary"
mat-stroked-button
class="docs"
href="https://docs.dasch.swiss/latest/DSP-APP/user-guide/project/#data-model"
target="_blank">
Read Documentation About How To Create Data Models
<mat-icon>chevron_right</mat-icon>
</button>
</a>
</div>
<div *ngIf="ontologiesMetadata$ | async" class="projectOntos">
<div class="list" [class.top-padding]="isAdmin$ | async">
<ng-container *ngIf="(isLoggedIn$ | async) === true">
<div
class="list-item ontos"
*ngFor="let onto of ontologiesMetadata$ | async; trackBy: trackByOntologyMetaFn"
(click)="open('ontology', onto.id)">
<mat-icon class="icon-prefix">bubble_chart</mat-icon>
<p
class="label"
matTooltip="You must be logged in to view data models"
matTooltipPosition="right"
[matTooltipDisabled]="true">
{{onto.label}}
</p>
<span class="fill-remaining-space"></span>
<mat-icon class="icon-suffix">chevron_right</mat-icon>
</div>
</ng-container>
<ng-container *ngIf="(isLoggedIn$ | async) === false">
<div
class="list-item ontos no-click"
*ngFor="let onto of ontologiesMetadata$ | async; trackBy: trackByOntologyMetaFn">
<mat-icon class="icon-prefix">bubble_chart</mat-icon>
<p
class="label"
matTooltip="You must be logged in to view data models"
matTooltipPosition="right"
[matTooltipDisabled]="false">
{{onto.label}}
</p>
<span class="fill-remaining-space"></span>
<mat-icon class="icon-suffix">chevron_right</mat-icon>
</div>
</ng-container>
<div
class="list-item ontos"
*ngFor="let onto of ontologiesMetadata$ | async; trackBy: trackByOntologyMetaFn"
(click)="navigateToOntology(onto.id)">
<mat-icon class="icon-prefix">bubble_chart</mat-icon>
<p
class="label"
matTooltip="You must be logged in to view data models"
matTooltipPosition="right"
[matTooltipDisabled]="(isLoggedIn$ | async)">
{{onto.label}}
</p>
<span class="fill-remaining-space"></span>
<mat-icon class="icon-suffix">chevron_right</mat-icon>
</div>
</div>
</div>
<div class="header">
Expand All @@ -67,19 +54,25 @@
</mat-icon>
</div>
<div *ngIf="isAdmin$ | async" class="action-buttons">
<button color="primary" mat-raised-button class="create" (click)="open('add-list')">
<a color="primary" mat-raised-button class="create" [routerLink]="['..', RouteConstants.addList]">
<mat-icon class="v-align-middle">add_circle</mat-icon>
<span class="v-align-middle">Create New</span>
</button>
</a>
</div>
<div *ngIf="(listsInProject$ | async)?.length > 0" class="projectLists">
<div class="list" [class.top-padding]="isAdmin$ | async">
<div
class="list-item"
*ngFor="let list of (listsInProject$ | async); trackBy: trackByFn"
(click)="open('list', list.id)">
(click)="navigateToList(list.id)">
<mat-icon class="icon-prefix">list</mat-icon>
<p class="label">{{list.labels | appStringifyStringLiteral}}</p>
<p
class="label"
matTooltip="You must be logged in to view data models"
matTooltipPosition="right"
[matTooltipDisabled]="(isLoggedIn$ | async)">
{{list.labels | appStringifyStringLiteral}}
</p>
<span class="fill-remaining-space"></span>
<mat-icon class="icon-suffix">chevron_right</mat-icon>
</div>
Expand Down

0 comments on commit 6909ffc

Please sign in to comment.