Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new UI e2e GitHub actions workflow #1190

Merged
merged 3 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
233 changes: 233 additions & 0 deletions .github/workflows/cypress new ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
name: Cypress end to end tests

on:
workflow_dispatch:

jobs:
csv-add-affiliations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Create creds json"
id: create-creds-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: '{"adminEmail": "${{secrets.CY_ADMIN_EMAIL}}", "adminPassword": "${{secrets.CY_ADMIN_PASSWORD}}", "password": "${{secrets.CY_PASSWORD}}", "shortPassword": "${{secrets.CY_SHORT_PASSWORD}}", "shortConfirmationPassword": "${{secrets.CY_SHORT_CONFIRMATION_PASSWORD}}", "wrongConfirmationPasssword": "${{secrets.CY_WRONG_CONFIRMATION_PASSWORD}}"}'
dir: "ui/cypress/fixtures"
- name: "Create Gmail creds json"
id: create-gmail-creds-file
uses: jsdaniell/[email protected]
with:
name: "credentials_qa.json"
json: '{"installed":{"client_id":"${{secrets.CY_CREDS_CLIENT_ID}}","project_id":"${{secrets.CY_CREDS_PROJECT_ID}}","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"${{secrets.CY_CREDS_CLIENT_SECRET}}","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}'
dir: "ui/cypress/plugins"
- name: "Create Gmail token json"
id: create-gmail-token-file
uses: jsdaniell/[email protected]
with:
name: "token_qa.json"
json: '{"access_token":"${{secrets.CY_TOKEN_ACCESS}}","refresh_token":"${{secrets.CY_TOKEN_REFRESH}}","scope":"https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send","token_type":"Bearer","expiry_date":${{secrets.CY_TOKEN_EXPIRY_DATE}}}'
dir: "ui/cypress/plugins"
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command: npm install cypress --legacy-peer-deps
working-directory: ui
spec: cypress/e2e/retention/csv-add-affiliations.cy.js
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: ui/cypress/screenshots
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: ui/cypress/videos
csv-edit-affiliations:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Create creds json"
id: create-creds-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: '{"adminEmail": "${{secrets.CY_ADMIN_EMAIL}}", "adminPassword": "${{secrets.CY_ADMIN_PASSWORD}}", "password": "${{secrets.CY_PASSWORD}}", "shortPassword": "${{secrets.CY_SHORT_PASSWORD}}", "shortConfirmationPassword": "${{secrets.CY_SHORT_CONFIRMATION_PASSWORD}}", "wrongConfirmationPasssword": "${{secrets.CY_WRONG_CONFIRMATION_PASSWORD}}"}'
dir: "ui/cypress/fixtures"
- name: "Create Gmail creds json"
id: create-gmail-creds-file
uses: jsdaniell/[email protected]
with:
name: "credentials_qa.json"
json: '{"installed":{"client_id":"${{secrets.CY_CREDS_CLIENT_ID}}","project_id":"${{secrets.CY_CREDS_PROJECT_ID}}","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"${{secrets.CY_CREDS_CLIENT_SECRET}}","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}'
dir: "ui/cypress/plugins"
- name: "Create Gmail token json"
id: create-gmail-token-file
uses: jsdaniell/[email protected]
with:
name: "token_qa.json"
json: '{"access_token":"${{secrets.CY_TOKEN_ACCESS}}","refresh_token":"${{secrets.CY_TOKEN_REFRESH}}","scope":"https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send","token_type":"Bearer","expiry_date":${{secrets.CY_TOKEN_EXPIRY_DATE}}}'
dir: "ui/cypress/plugins"
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command: npm install cypress --legacy-peer-deps
working-directory: ui
spec: |
cypress/e2e/retention/csv-edit-affiliations.cy.js
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: ui/cypress/screenshots
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: ui/cypress/videos
add-affiliation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Create creds json"
id: create-creds-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: '{"adminEmail": "${{secrets.CY_ADMIN_EMAIL}}", "adminPassword": "${{secrets.CY_ADMIN_PASSWORD}}", "password": "${{secrets.CY_PASSWORD}}", "shortPassword": "${{secrets.CY_SHORT_PASSWORD}}", "shortConfirmationPassword": "${{secrets.CY_SHORT_CONFIRMATION_PASSWORD}}", "wrongConfirmationPasssword": "${{secrets.CY_WRONG_CONFIRMATION_PASSWORD}}"}'
dir: "ui/cypress/fixtures"
- name: "Create Gmail creds json"
id: create-gmail-creds-file
uses: jsdaniell/[email protected]
with:
name: "credentials_qa.json"
json: '{"installed":{"client_id":"${{secrets.CY_CREDS_CLIENT_ID}}","project_id":"${{secrets.CY_CREDS_PROJECT_ID}}","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"${{secrets.CY_CREDS_CLIENT_SECRET}}","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}'
dir: "ui/cypress/plugins"
- name: "Create Gmail token json"
id: create-gmail-token-file
uses: jsdaniell/[email protected]
with:
name: "token_qa.json"
json: '{"access_token":"${{secrets.CY_TOKEN_ACCESS}}","refresh_token":"${{secrets.CY_TOKEN_REFRESH}}","scope":"https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send","token_type":"Bearer","expiry_date":${{secrets.CY_TOKEN_EXPIRY_DATE}}}'
dir: "ui/cypress/plugins"
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command: npm install cypress --legacy-peer-deps
working-directory: ui
spec: |
cypress/e2e/retention/add-affiliation.cy.js
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: ui/cypress/screenshots
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: ui/cypress/videos
notifications:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Create creds json"
id: create-creds-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: '{"adminEmail": "${{secrets.CY_ADMIN_EMAIL}}", "adminPassword": "${{secrets.CY_ADMIN_PASSWORD}}", "password": "${{secrets.CY_PASSWORD}}", "shortPassword": "${{secrets.CY_SHORT_PASSWORD}}", "shortConfirmationPassword": "${{secrets.CY_SHORT_CONFIRMATION_PASSWORD}}", "wrongConfirmationPasssword": "${{secrets.CY_WRONG_CONFIRMATION_PASSWORD}}"}'
dir: "ui/cypress/fixtures"
- name: "Create Gmail creds json"
id: create-gmail-creds-file
uses: jsdaniell/[email protected]
with:
name: "credentials_qa.json"
json: '{"installed":{"client_id":"${{secrets.CY_CREDS_CLIENT_ID}}","project_id":"${{secrets.CY_CREDS_PROJECT_ID}}","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"${{secrets.CY_CREDS_CLIENT_SECRET}}","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}'
dir: "ui/cypress/plugins"
- name: "Create Gmail token json"
id: create-gmail-token-file
uses: jsdaniell/[email protected]
with:
name: "token_qa.json"
json: '{"access_token":"${{secrets.CY_TOKEN_ACCESS}}","refresh_token":"${{secrets.CY_TOKEN_REFRESH}}","scope":"https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send","token_type":"Bearer","expiry_date":${{secrets.CY_TOKEN_EXPIRY_DATE}}}'
dir: "ui/cypress/plugins"
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command: npm install cypress --legacy-peer-deps
working-directory: ui
spec: |
cypress/e2e/retention/notifications.cy.js
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: ui/cypress/screenshots
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: ui/cypress/videos
other-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Create creds json"
id: create-creds-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: '{"adminEmail": "${{secrets.CY_ADMIN_EMAIL}}", "adminPassword": "${{secrets.CY_ADMIN_PASSWORD}}", "password": "${{secrets.CY_PASSWORD}}", "shortPassword": "${{secrets.CY_SHORT_PASSWORD}}", "shortConfirmationPassword": "${{secrets.CY_SHORT_CONFIRMATION_PASSWORD}}", "wrongConfirmationPasssword": "${{secrets.CY_WRONG_CONFIRMATION_PASSWORD}}"}'
dir: "ui/cypress/fixtures"
- name: "Create Gmail creds json"
id: create-gmail-creds-file
uses: jsdaniell/[email protected]
with:
name: "credentials_qa.json"
json: '{"installed":{"client_id":"${{secrets.CY_CREDS_CLIENT_ID}}","project_id":"${{secrets.CY_CREDS_PROJECT_ID}}","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"${{secrets.CY_CREDS_CLIENT_SECRET}}","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}'
dir: "ui/cypress/plugins"
- name: "Create Gmail token json"
id: create-gmail-token-file
uses: jsdaniell/[email protected]
with:
name: "token_qa.json"
json: '{"access_token":"${{secrets.CY_TOKEN_ACCESS}}","refresh_token":"${{secrets.CY_TOKEN_REFRESH}}","scope":"https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send","token_type":"Bearer","expiry_date":${{secrets.CY_TOKEN_EXPIRY_DATE}}}'
dir: "ui/cypress/plugins"
- name: Cypress run
uses: cypress-io/github-action@v2
with:
install-command: npm install cypress --legacy-peer-deps
working-directory: ui
spec: |
cypress/e2e/retention/add-member.cy.js
cypress/e2e/retention/add-user.cy.js
cypress/e2e/retention/csv-invalid-affiliation.cy.js
cypress/e2e/retention/edit-affiliation.cy.js
cypress/e2e/retention/edit-member.cy.js
cypress/e2e/retention/edit-user.cy.js
cypress/e2e/retention/reset-password.cy.js
cypress/e2e/retention/restricted-access.cy.js
cypress/e2e/retention/ui-authorities.cy.js
cypress/e2e/retention/ui-login.cy.js
cypress/e2e/retention/ui-pagination.cy.js
cypress/e2e/retention/ui-homepage.cy.js
cypress/e2e/retention/ui-homepage-edit.cy.js
cypress/e2e/retention/ui-reports.cy.js
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: ui/cypress/screenshots
- uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-videos
path: ui/cypress/videos
10 changes: 5 additions & 5 deletions ui/cypress/e2e/reset-test-data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe("Add new user", () => {

it("Remove all affiliations from test group", function () {
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.visit("/assertion");
cy.visit("ui/en/affiliations");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
});
cy.visit("/user");
cy.visit("ui/en/users");
cy.get(".btn-group").each(($e) => {
cy.wrap($e)
.children()
Expand All @@ -32,7 +32,7 @@ describe("Add new user", () => {

it("Remove all affiliations from test member", function () {
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.visit("/user");
cy.visit("ui/en/users");
cy.get(".btn-group").each(($e) => {
cy.wrap($e)
.children()
Expand All @@ -52,7 +52,7 @@ describe("Add new user", () => {
data.csvMember.users.owner.email,
credentials.password,
);
cy.visit("/assertion");
cy.visit("ui/en/affiliations");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
Expand All @@ -65,7 +65,7 @@ describe("Add new user", () => {
data.notificationsMember.users.owner.email,
credentials.password,
);
cy.visit("/assertion");
cy.visit("ui/en/affiliations");
cy.get(".btn-group").each(($e) => {
cy.wrap($e).children().last().click();
cy.get("button").filter('[data-cy="confirmDeleteAffiliation"]').click();
Expand Down
4 changes: 1 addition & 3 deletions ui/cypress/e2e/retention/add-user.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ describe("Add new user", () => {

cy.processPasswordForm("#password");
// check success message
cy.get(".alert-success").within(() => {
cy.get("a").filter('[data-cy="navigateToSignIn"]').click();
});
cy.get("a").filter('[data-cy="navigateToSignIn"]').click();
// sign in and confirm the activation was successful
});

Expand Down
4 changes: 1 addition & 3 deletions ui/cypress/e2e/retention/reset-password.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ describe("Test the password reset functionality", () => {

cy.processPasswordForm("#password");

cy.get(".alert-success").within(() => {
cy.get("a").filter('data-cy="navigateToSignIn"]').click();
});
cy.get("a").filter('[data-cy="navigateToSignIn"]').click();
// sign in and confirm the activation was successful
cy.programmaticSignin(data.member.users.owner.email, credentials.password);
cy.programmaticSignout();
Expand Down
2 changes: 1 addition & 1 deletion ui/cypress/fixtures/test-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"italianLanguageCode": "4: it",
"outbox": {
"email": "[email protected]",
"updateEmail": "update@notify.orcid.org",
"updateEmail": "DoNotReply@notify.orcid.org",
"activationSubject": "ORCID Member Portal activation",
"resetPasswordSubject": "ORCID Member Portal password reset",
"ownerUpdateSubject": "ORCID Member Portal organization owner updated",
Expand Down
14 changes: 6 additions & 8 deletions ui/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,18 +205,16 @@ Cypress.Commands.add("fetchLinkAndGrantPermission", (email) => {
.children()
.last()
.within(() => {
cy.get("a").filter('[data-cy="viewDetailsButton"]').click();
cy.get("a").click();
});
cy.get("button").filter('[data-cy="copyToClipboard"]').click(),
cy.task("getClipboard").then((link) => {
cy.visit(link);
});
cy.get(".jh-entity-details").within(() =>
cy.get("button").filter('[data-cy="copyToClipboard"]').click(),
);
cy.task("getClipboard").then((link) => {
cy.visit(link);
});
// Handle cookies
cy.get("#onetrust-reject-all-handler").click();
// Grant permission
cy.get("#username").clear().type(email);
cy.get("#username-input").clear().type(email);
cy.get("#password").type(credentials.password);
cy.get("#signin-button").click();

Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/landing-page/landing-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2>
</a>
</div>
<div *ngIf="showSuccess">
<h2>
<h2 data-cy="thanksMessage">
{{ thanksMessage }}
</h2>
<p>
Expand Down
Loading