-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(dsp-app): add cypress e2e test framework (#1161)
Co-authored-by: Rebeccasigloch <[email protected]>
- Loading branch information
1 parent
ed43e09
commit fbb77ff
Showing
28 changed files
with
3,698 additions
and
2,895 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,7 @@ Thumbs.db | |
|
||
.angular | ||
/libs/jdnconvertiblecalendar/coverage/ | ||
|
||
#E2E | ||
/.nx | ||
apps/dsp-app-e2e/cypress/screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
specPattern: 'cypress/**/**/**/*.cy.ts', | ||
excludeSpecPattern: ['*.spec.js', '*.spec.ts'], | ||
baseUrl: "http://localhost:4200", | ||
env: { | ||
apiUrl: "http://0.0.0.0:3333", | ||
} | ||
}, | ||
}); |
16 changes: 16 additions & 0 deletions
16
...press/e2e/System_Admin/System_Admin_functions/Project_administration/create_project.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe('create new project', () => { | ||
it('should create a new project', () => { | ||
cy.visit('/'); | ||
cy.get('.create-project-button button').click(); | ||
cy.get("#mat-input-0").type("0123"); | ||
cy.get("#mat-input-1").type("test"); | ||
cy.get("#mat-input-2").type("Test Project"); | ||
cy.get("#mat-input-3").type("this is a test project"); | ||
cy.get("#mat-mdc-chip-list-input-0").type("project"); | ||
cy.get("#mat-mdc-chip-list-input-0").type("{enter}"); | ||
cy.get("#mat-mdc-chip-list-input-0").type("test"); | ||
cy.get("#mat-mdc-chip-list-input-0").type("{enter}"); | ||
cy.get("div.app-content span.mdc-button__label > span").click(); | ||
cy.get('.project-longname').should('contain', 'Test Project'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"admin_username": "daschAdmin", | ||
"admin_password": "DaSCHianer1", | ||
"change_admin_password": "DaSCHianer2", | ||
"projectMember_username": "daschMember", | ||
"projectMember_password": "AMembersPassword1", | ||
"change_projectMember_password": "AMembersPassword2", | ||
"systemAdmin_username": "daschSystemAdmin", | ||
"systemAdmin_password": "IamAllowedTODoEverything1", | ||
"systemAdmin_username_root": "root", | ||
"systemAdmin_password_root": "test", | ||
"change_systemAdmin_password": "IamAllowedTODoEverything2" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
declare namespace Cypress { | ||
|
||
// I can't import User from user-profiles without the linter breaking and idk why | ||
interface User { | ||
username: string; | ||
password: string; | ||
} | ||
|
||
interface Chainable<Subject> { | ||
// logs user in via the API | ||
login(user: User): void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export interface User { | ||
username: string; | ||
password: string; | ||
} | ||
|
||
export interface UserProfiles { | ||
admin_username: string; | ||
admin_password: string; | ||
change_admin_password: string; | ||
projectMember_username: string; | ||
projectMember_password: string; | ||
change_projectMember_password: string; | ||
systemAdmin_username: string; | ||
systemAdmin_password: string; | ||
systemAdmin_username_root: string; | ||
systemAdmin_password_root: string; | ||
change_systemAdmin_password: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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) => { | ||
const session = { | ||
id: 123456789, | ||
user: { | ||
name: "root", | ||
jwt: response.body.token, | ||
lang: "de", | ||
sysAdmin: true, | ||
projectAdmin: [] | ||
} | ||
|
||
}; | ||
|
||
localStorage.setItem('session', JSON.stringify(session)); | ||
localStorage.setItem('cookieBanner', 'false'); | ||
cy.visit('/'); | ||
cy.get('rn-banner').shadow().find('.rn-close-btn').click(); | ||
}); | ||
}, | ||
{ | ||
validate: () => { | ||
const session = localStorage.getItem('session'); | ||
expect(session).to.exist; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import './commands/login'; | ||
import { UserProfiles } from '../models/user-profiles'; | ||
|
||
// do things here before each test if needed | ||
// All active session data (cookies, localStorage and sessionStorage) across all domains are cleared. | ||
beforeEach(() => { | ||
let users: UserProfiles; | ||
cy.readFile('cypress/fixtures/user_profiles.json').then( | ||
(json: UserProfiles) => { | ||
// read JSON data file | ||
users = json; | ||
|
||
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') | ||
) { | ||
cy.login({ | ||
username: users.projectMember_username, | ||
password: users.projectMember_password | ||
}); | ||
} | ||
} | ||
); | ||
}); | ||
|
||
// do things here after each test if needed | ||
// afterEach(() => { | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.