-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
56a1141
commit 140fb6b
Showing
7 changed files
with
201 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Cypress Tests | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
cypress-run: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run Cypress tests | ||
run: npx cypress run |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"user": { | ||
"userName": "standard_user", | ||
"password": "secret_sauce" | ||
"userName": "Admin", | ||
"password": "admin123" | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,14 +1,55 @@ | ||
Cypress.Commands.add("login", (userName, password) => { | ||
cy.session([userName, password], () => { | ||
cy.visit('/', { failOnStatusCode: false }) | ||
cy.get('#user-name') | ||
.should('be.visible') | ||
.type(userName) | ||
cy.get('#password') | ||
.should('be.visible') | ||
.type(password) | ||
cy.get('#login-button') | ||
.click() | ||
|
||
Cypress.Commands.add("loginSession", (userName, password) => { | ||
cy.session([userName, password], () => { | ||
cy.visit('/', { failOnStatusCode: false }) | ||
cy.get('input[name="username"]') | ||
.should('be.visible') | ||
.type(userName) | ||
cy.get('input[name="password"]') | ||
.should('be.visible') | ||
.type(password) | ||
cy.get('button[type="submit"]') | ||
.contains('Login') | ||
.click() | ||
}) | ||
}) | ||
|
||
Cypress.Commands.add("login", (userName, password, noWait) => { | ||
//cy.intercept("POST", "/auth/validate").as('postLogin') | ||
cy.clearCookies(); | ||
cy.clearLocalStorage(); | ||
cy.visit('/login', { failOnStatusCode: false }) | ||
cy.get('input[name="username"]') | ||
.should('be.visible') | ||
.type(userName) | ||
cy.get('input[name="password"]') | ||
.should('be.visible') | ||
.type(password) | ||
cy.get('button[type="submit"]') | ||
.contains('Login') | ||
.click() | ||
// if (!noWait) { | ||
// return cy.wait('@postLogin') | ||
// } | ||
}) | ||
|
||
|
||
Cypress.Commands.add("logoutRequest", () => { | ||
cy.getUserToken().then((token) => { | ||
cy.request({ | ||
method: "GET", | ||
url: `${Cypress.env("apiUrl")}logout`, | ||
// body: { "accessToken": token }, | ||
}).then((response) => { | ||
expect(response.status).to.equal(200) | ||
}) | ||
}) | ||
}) | ||
|
||
|
||
Cypress.Commands.add('getUserToken', () => { | ||
cy.window().then((win) => { | ||
const userToken = win.localStorage.getItem('/core/i18n/messages'); | ||
cy.log(userToken) | ||
return cy.wrap(userToken) | ||
}); | ||
}); |
Oops, something went wrong.