Skip to content

Commit

Permalink
Merge pull request #1047 from SciCatProject/SWAP-3180-scicat-fe-be-ad…
Browse files Browse the repository at this point in the history
…d-tests-for-access-user-settings

fix: improve e2e test for the content in settings
  • Loading branch information
nitrosx authored Apr 18, 2023
2 parents f32e448 + ef7613a commit 42fec07
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CI/ESS/e2e/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"password": "am2jf70TPNZsSan",
"secondaryUsername": "archiveManager",
"secondaryPassword": "aman",
"guestUsername":"user1",
"guestPassword":"a609316768619f154ef58db4d847b75e",
"defaultCommandTimeout": 10000,
"retries": 1
}
2 changes: 2 additions & 0 deletions CI/ESS/e2e/cypress.nestjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"password": "am2jf70TPNZsSan",
"secondaryUsername": "archiveManager",
"secondaryPassword": "aman",
"guestUsername":"user1",
"guestPassword":"a609316768619f154ef58db4d847b75e",
"defaultCommandTimeout": 10000,
"retries": 1
}
2 changes: 2 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"password": "am2jf70TPNZsSan",
"secondaryUsername": "archiveManager",
"secondaryPassword": "aman",
"guestUsername":"user1",
"guestPassword":"a609316768619f154ef58db4d847b75e",
"defaultCommandTimeout": 10000,
"retries": 1
}
74 changes: 74 additions & 0 deletions cypress/integration/users-login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
describe("Users Login", () => {
const username = Cypress.config("username");
const password = Cypress.config("password");

const guestUsername = Cypress.config("guestUsername");
const guestPassword = Cypress.config("guestPassword");

const loginEndpoint = Cypress.config("lbLoginEndpoint");

beforeEach(() => {
Expand Down Expand Up @@ -86,4 +90,74 @@ describe("Users Login", () => {

cy.url().should("include", "/login");
});

it("logs in with admin account should be able to see all the content properly from user information", ()=>{
cy.visit("/login");

cy.get('mat-tab-group [role="tab"]').contains("Local").click();

cy.get("#usernameInput").type(username).should("have.value", username);

cy.get("#passwordInput").type(password).should("have.value", password);

cy.get("button[type=submit]").click();

cy.get(".user-button").should("contain.text", username).click();

cy.get("[data-cy=setting-button]").click();

cy.get("[data-cy=user-name]").should("contain.text", username);

cy.get("[data-cy=user-email]").invoke('text').should("not.be.empty");

cy.get("[data-cy=user-id]").invoke('text').should("not.be.empty");

cy.get("[data-cy=user-accessGroup]").invoke('text').should("not.be.empty");

cy.get(".copy-button").click();

cy.get("[data-cy=user-token]").invoke('text').then((token) => {
cy.window().then((win) => {
win.navigator.clipboard.readText().then((clipboardText) => {
expect(clipboardText).to.equal(token);
});
});
});

})

it("logs in with normal user account should be able to see all the content properly from user information", ()=>{
cy.visit("/login");

cy.get('mat-tab-group [role="tab"]').contains("Local").click();

cy.get("#usernameInput").type(guestUsername).should("have.value", guestUsername);

cy.get("#passwordInput").type(guestPassword).should("have.value", guestPassword);

cy.get("button[type=submit]").click();

cy.get(".user-button").should("contain.text", guestUsername).click();

cy.get("[data-cy=setting-button]").click();

cy.get("[data-cy=user-name]").should("contain.text", guestUsername);

cy.get("[data-cy=user-email]").invoke('text').should("not.be.empty");

cy.get("[data-cy=user-id]").invoke('text').should("not.be.empty");

cy.get("[data-cy=user-accessGroup]").invoke('text').should("not.be.empty");

cy.get(".copy-button").click();

cy.get("[data-cy=user-token]").invoke('text').then((token) => {
cy.window().then((win) => {
win.navigator.clipboard.readText().then((clipboardText) => {
expect(clipboardText).to.equal(token);
});
});
});
})

});
2 changes: 1 addition & 1 deletion src/app/_layout/app-header/app-header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<span>Samples</span>
</button>

<button mat-menu-item routerLink="/user/">
<button mat-menu-item routerLink="/user/" data-cy="setting-button">
<mat-icon> settings</mat-icon>
<span>Settings</span>
</button>
Expand Down
10 changes: 5 additions & 5 deletions src/app/users/user-settings/user-settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@
</ng-template>

<table>
<tr *ngIf="vm.profile && vm.profile.displayName">
<tr *ngIf="vm.profile && vm.profile.displayName" data-cy="user-name">
<th>Name</th>
<td>{{ vm.profile.displayName }}</td>
</tr>
<tr *ngIf="vm.user && vm.user.email">
<tr *ngIf="vm.user && vm.user.email" data-cy="user-email">
<th>Email</th>
<td>{{ vm.user.email }}</td>
</tr>
<tr *ngIf="vm.user && vm.user.id">
<tr *ngIf="vm.user && vm.user.id" data-cy="user-id">
<th>Id</th>
<td>{{ vm.user.id }}</td>
</tr>
<tr *ngIf="vm.profile && vm.profile.accessGroups">
<tr *ngIf="vm.profile && vm.profile.accessGroups" data-cy="user-accessGroup">
<th>Groups</th>
<td>{{ vm.profile.accessGroups }}</td>
</tr>
<tr *ngIf="tokenValue">
<tr *ngIf="tokenValue" data-cy="user-token">
<th>SciCat Token</th>
<td>
{{ tokenValue }}
Expand Down

0 comments on commit 42fec07

Please sign in to comment.