Commit 51bc5946 authored by Homada.Boumedane's avatar Homada.Boumedane
Browse files

refactor(portal): cypress e2e

refactor existing test
parent abfb98ab
......@@ -9,36 +9,37 @@ describe("Admin Page", () => {
it("visit admin page", () => {
cy.get("#menu-vertical-admin").click();
cy.get("#admin-home-title").contains("Administration");
cy.get("mat-card").should("have.length", 15);
// this assert depends on the user right
cy.get("mat-card").should("have.length", 16);
});
it("visit organization unit", () => {
cy.get("#organization-unit-card").click();
cy.get("#tile-card-building").click();
cy.get("table").find("tr").its("length").should("be.gt", 1);
// go back
cy.get("#go-back-button").click();
cy.get("#btn-toolbar-navigate_before").click();
});
it("visit submission policy", () => {
cy.get("#submission-policy-card").click();
cy.get("table").find("tr").its("length").should("be", 2);
cy.get("#tile-card-user-check").click();
cy.get("table").find("tr").its("length").should("be", 1);
//go back
cy.get("#go-back-button").click();
cy.get("#btn-toolbar-navigate_before").click();
});
it("visit oauth2 client", () => {
cy.get("#oauth2-client-card").click();
cy.get("#tile-card-passport").click();
// assert that we have at least two client
cy.get("table").find("tr").its("length").should("be.gt", 2);
cy.get("table").find("tr").its("length").should("be.gt", 1);
//go back
cy.get("#go-back-button").click();
cy.get("#btn-toolbar-navigate_before").click();
});
it("visit user", () => {
cy.get("#person-card").click();
cy.get("#tile-card-user").click();
// assert that we have at least two person
cy.get("table").find("tr").its("length").should("be.gt", 1);
//go back
cy.get("#go-back-button").click();
cy.get("#btn-toolbar-navigate_before").click();
});
});
......@@ -12,37 +12,40 @@ describe("Deposit Page", () => {
});
it("should create a deposit", () => {
const createDate = Cypress.moment().format("MM/DD/YYYY");
cy.get("#add-deposit-btn").click();
cy.get("[data-test=deposit-title]").type("Deposit Test 1");
cy.get("[data-test=deposit-description]").type("Description of deposit");
cy.get("[data-test=deposit-publicationDate]").type(createDate).should("have.value", createDate);
cy.get("[data-test=deposit-publicationDate]").invoke('val').should('not.be.empty');
// simulate click event on the drop down
cy.get("[data-test=deposit-accessLevel]").first().click().get("mat-option").contains("Public").click();
cy.get("[data-test=deposit-addMeAuthor]").click();
cy.get("[data-test=deposit-licenseId]").first().click().get("li").contains("CC BY-NC 4.0 (Creative Commons Attribution-NonCommercial 4.0 International)").click();
/* cy.get("[data-test=deposit-licenseId]")
.click()
.get("#searchable-single-select-content")
.click()
.get("li")
.contains("CC BY-NC 4.0 (Creative Commons Attribution-NonCommercial 4.0 International)")
.click();*/
cy.get("[data-test=deposit-language]").first().click().get("mat-option").contains("en").click();
cy.server();
cy.route("POST", "http://localhost:4200/api/preingest/deposits").as("deposit");
//click submit button
cy.get("[data-test=deposit-submit-button]").click();
cy.url().should("include", "/upload");
// tip: log the request object to see everything it has in the console
// cy.get("@deposit").should("have.property", "status", 201);
cy.route("POST", "http://**/preingest/deposits").as("deposit");
//click submit button to save
cy.get("#toolbar-btn-save").click();
cy.wait("@deposit").then((xhr) => {
expect(xhr.status).to.eq(201);
});
// navigate to upload file tab
cy.get("#tab-upload").click();
cy.wait(2000);
//open upload file dialog
cy.get("#deposit-upload-button").click();
cy.get("#deposit-upload-primary-data").click();
// fill form
cy.get("[data-test=deposit-data-category]").first().click().get("mat-option").contains("Primary").click();
// cy.get("[data-test=deposit-data-category]").first().click().get("mat-option").contains("Primary").click();
cy.get("[data-test=deposit-data-type]").first().click().get("mat-option").contains("Reference").click();
// load mock data from a fixture or construct here
......@@ -57,18 +60,18 @@ describe("Deposit Page", () => {
cy.get("#tab-files").click();
cy.route({
url: "http://localhost:4200/**/data?size=10&page=0&relativeLocation=/",
url: "http://**/data?size=10&page=0&relativeLocation=/",
method: "GET"
}).as("listFiles");
cy.wait("@listFiles").then((xhr) => {
expect(xhr.status).to.eq(201);
expect(xhr.status).to.eq(200);
});
cy.get("[data-cy=deposit-file-data-table]").then($table => {
cy.get("[data-test=deposit-file-data-table]").then($table => {
const rowsCount = $table.find("tbody").find("tr").length;
//expect to have one rows in the table
expect(rowsCount).to.equal(1);
//expect to have at least one row with data
expect(rowsCount).to.be.greaterThan(1);
});
});
......
This diff is collapsed.
......@@ -17,7 +17,7 @@
solidifyShortCuts
(onEnter)="navigate(tile.path)"
(click)="navigate(tile.path)"
id="{{resource.selector}}"
id="tile-card-{{tile.avatarIcon}}"
>
<mat-card-header class="card-header">
<div class="avatar"
......
......@@ -22,7 +22,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
_tiles: SharedHomeTileModel[] = [
{
avatarIcon: "building",
selector: "organization-unit-card",
titleToTranslate: TRANSLATE("admin.organizationalUnit.home.title"),
subtitleToTranslate: TRANSLATE("admin.organizationalUnit.home.subtitle"),
path: RoutesEnum.adminOrganizationalUnit,
......@@ -30,7 +29,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "user-check",
selector: "submission-policy-card",
titleToTranslate: TRANSLATE("admin.submissionPolicy.home.title"),
subtitleToTranslate: TRANSLATE("admin.submissionPolicy.home.subtitle"),
path: RoutesEnum.adminSubmissionPolicy,
......@@ -38,7 +36,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "history",
selector: "preservation-policy-card",
titleToTranslate: TRANSLATE("admin.preservationPolicy.home.title"),
subtitleToTranslate: TRANSLATE("admin.preservationPolicy.home.subtitle"),
path: RoutesEnum.adminPreservationPolicy,
......@@ -46,7 +43,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "cart-arrow-down",
selector: "dissemination-policy-card",
titleToTranslate: TRANSLATE("admin.disseminationPolicy.home.title"),
subtitleToTranslate: TRANSLATE("admin.disseminationPolicy.home.subtitle"),
path: RoutesEnum.adminDisseminationPolicy,
......@@ -54,7 +50,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "copyright",
selector: "license-card",
titleToTranslate: TRANSLATE("admin.license.home.title"),
subtitleToTranslate: TRANSLATE("admin.license.home.subtitle"),
path: RoutesEnum.adminLicense,
......@@ -62,7 +57,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "university",
selector: "institution-card",
titleToTranslate: TRANSLATE("admin.institution.home.title"),
subtitleToTranslate: TRANSLATE("admin.institution.home.subtitle"),
path: RoutesEnum.adminInstitution,
......@@ -70,7 +64,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "microscope",
selector: "research-domain-card",
titleToTranslate: TRANSLATE("admin.researchDomain.home.title"),
subtitleToTranslate: TRANSLATE("admin.researchDomain.home.subtitle"),
path: RoutesEnum.adminResearchDomain,
......@@ -78,7 +71,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "user-circle",
selector: "user-card",
titleToTranslate: TRANSLATE("admin.user.home.title"),
subtitleToTranslate: TRANSLATE("admin.user.home.subtitle"),
path: RoutesEnum.adminUser,
......@@ -86,7 +78,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "id-badge",
selector: "roles-card",
titleToTranslate: TRANSLATE("admin.roles.home.title"),
subtitleToTranslate: TRANSLATE("admin.roles.home.subtitle"),
path: RoutesEnum.adminRole,
......@@ -94,7 +85,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "passport",
selector: "oai-set-card",
titleToTranslate: TRANSLATE("admin.oai-set.home.title"),
subtitleToTranslate: TRANSLATE("admin.oai-set.home.subtitle"),
path: RoutesEnum.adminOaiSet,
......@@ -102,7 +92,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "passport",
selector: "oauth2-client-card",
titleToTranslate: TRANSLATE("admin.oauth2.home.title"),
subtitleToTranslate: TRANSLATE("admin.oauth2.home.subtitle"),
path: RoutesEnum.adminOAuth2client,
......@@ -110,7 +99,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "user",
selector: "person-card",
titleToTranslate: TRANSLATE("admin.person.home.title"),
subtitleToTranslate: TRANSLATE("admin.person.home.subtitle"),
path: RoutesEnum.adminPerson,
......@@ -118,7 +106,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "hand-holding-usd",
selector: "funding-agencies-card",
titleToTranslate: TRANSLATE("admin.funding-agencies.home.title"),
subtitleToTranslate: TRANSLATE("admin.funding-agencies.home.subtitle"),
path: RoutesEnum.adminFundingAgencies,
......@@ -126,7 +113,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "language",
selector: "funding-agencies-card",
titleToTranslate: TRANSLATE("admin.language.home.title"),
subtitleToTranslate: TRANSLATE("admin.language.home.subtitle"),
path: RoutesEnum.adminLanguage,
......@@ -134,7 +120,6 @@ export class AdminHomeRoutable extends SharedAbstractHomeRoutable {
},
{
avatarIcon: "table",
selector: "metadata-card",
titleToTranslate: TRANSLATE("admin.metadataType.home.title"),
subtitleToTranslate: TRANSLATE("admin.metadataType.home.subtitle"),
path: RoutesEnum.adminMetadataType,
......
......@@ -3,7 +3,6 @@ import {
adminLanguageActionNameSpace,
} from "@admin/language/stores/admin-language.action";
import {Injectable} from "@angular/core";
import {Language} from "@models";
import {DepositStateModel} from "@deposit/stores/deposit.state";
import {Language} from "@models";
import {
......
......@@ -8,7 +8,6 @@ import {
HttpEventType,
} from "@angular/common/http";
import {Injectable} from "@angular/core";
import {MetadataType} from "@models";
import {UploadEventModel} from "@deposit/models/upload-event.model";
import {MetadataType} from "@models";
import {
......
import {AdminLicenseState} from "@admin/license/stores/admin-license.state";
import {AdminOaiSetBulkCreateRoutable} from "@admin/oai-set/components/routables/admin-oai-set-bulk-create/admin-oai-set-bulk-create.routable";
import {AdminOaiSetCreateRoutable} from "@admin/oai-set/components/routables/admin-oai-set-create/admin-oai-set-create.routable";
import {AdminOaiSetDetailEditRoutable} from "@admin/oai-set/components/routables/admin-oai-set-detail-edit/admin-oai-set-detail-edit.routable";
......
import {OrganizationalUnitDisseminationPolicy} from "@admin/models/organizational-unit-dissemination-policy.model";
import {
DisseminationPolicy,
} from "@models";
import {DisseminationPolicy} from "@models";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {
Relation2TiersAction,
......
import {
FundingAgency,
Institution,
} from "@models";
import {Institution} from "@models";
import {LocalStateEnum} from "@shared/enums/local-state.enum";
import {
AssociationAction,
......
......@@ -7,7 +7,6 @@ import {
RouterModule,
Routes,
} from "@angular/router";
import {ApplicationRolePermissionEnum} from "@shared/enums/application-role-permission.enum";
import {
AdminRoutesEnum,
AppRoutesEnum,
......
......@@ -7,7 +7,6 @@ import {
RouterModule,
Routes,
} from "@angular/router";
import {ApplicationRolePermissionEnum} from "@shared/enums/application-role-permission.enum";
import {
AdminRoutesEnum,
AppRoutesEnum,
......
......@@ -73,7 +73,8 @@
<div class="file-list-wrapper"
[dlcmSpinner]="isLoadingDataFileObs | async"
>
<dlcm-shared-data-table #dataTablePresentational
<dlcm-shared-data-table data-test="deposit-file-data-table"
#dataTablePresentational
*ngIf="columns"
[columns]="columns"
[isLoading]="isLoadingDataFileObs | async"
......
<div class="upload-button-wrapper">
<ng-template [ngIf]="mode === modeDepositTabEnum.UNDEFINED || mode === modeDepositTabEnum.FILE">
<button dlcmAlternativeButton
<button id="deposit-upload-primary-data"
dlcmAlternativeButton
solidifyShortCuts
(onEnter)="openModalUpload(dataCategoryEnum.Primary)"
(click)="openModalUpload(dataCategoryEnum.Primary)"
......@@ -11,7 +12,8 @@
</ng-template>
<ng-template [ngIf]="mode === modeDepositTabEnum.FILE">
<button mat-button
<button id="deposit-upload-secondary-data"
mat-button
color="primary"
type="button"
solidifyShortCuts
......@@ -22,7 +24,8 @@
{{'deposit.file.button.uploadSecondaryData' | translate}}
</button>
<button mat-button
<button id="deposit-upload-archive"
mat-button
color="primary"
type="button"
[matTooltip]="'deposit.file.button.uploadArchive.tooltip' | translate"
......
......@@ -3,8 +3,8 @@ import {
Component,
Input,
} from "@angular/core";
import {Deposit} from "@models";
import {SharedAbstractPresentational} from "@app/shared/components/presentationals/shared-abstract/shared-abstract.presentational";
import {Deposit} from "@models";
import {
isFalse,
isNullOrUndefined,
......
......@@ -14,7 +14,6 @@ import {
DepositStateModel,
} from "@deposit/stores/deposit.state";
import {Deposit} from "@models";
import {Deposit} from "@models";
import {
Actions,
Select,
......
......@@ -25,7 +25,8 @@
{{extraButton.labelToTranslate | translate}}
</button>
</ng-container>
<button mat-flat-button
<button id="add-deposit-btn"
mat-flat-button
#matButton
color="primary"
*ngIf="(options.canCreate | isObservable) ? (options.canCreate | async) : (options.canCreate)"
......
......@@ -26,13 +26,6 @@ import {
PreservationPolicy,
SubmissionPolicy,
} from "@models";
import {
Deposit,
Language,
Person,
PreservationPolicy,
SubmissionPolicy,
} from "@models";
import {Navigate} from "@ngxs/router-plugin";
import {
Actions,
......
import {LocalStateEnum} from "@app/shared/enums/local-state.enum";
import {StatusHistoryNamespace} from "@shared/stores/status-history/status-history-namespace.model";
import {StatusHistoryAction} from "@shared/stores/status-history/status-history.action";
import {
BaseAction,
QueryParameters,
TypeDefaultAction,
} from "solidify-frontend";
import {TypeDefaultAction} from "solidify-frontend";
const state = LocalStateEnum.deposit_dataFile_statusHistory;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment