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

Inital cypress test and github action for CCMNet #1152

Merged
merged 2 commits into from
Apr 22, 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
15 changes: 14 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ jobs:
LANDO_ENV: ${{ secrets.LANDO_ENV }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
REPO: "${{ github.server_url }}/${{ github.repository }}"
ccmnet:
name: Run cypress tests in 'ccmnet' directory
uses: necyberteam/reusable_actions/.github/workflows/cypress.yml@v3
if: contains(github.event.inputs.sites, 'ccmnet') || github.event_name == 'pull_request'
secrets:
slack_token: ${{ secrets.SLACK_TOKEN }}
site: "ccmnet"
database: ${{ github.event.inputs.database }}
prnum: ${{ github.event.inputs.prnum }}
gh_token: ${{ secrets.GH_TOKEN_REPO }}
LANDO_ENV: ${{ secrets.LANDO_ENV }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
REPO: "${{ github.server_url }}/${{ github.repository }}"

# success:
# name: Actions to run on success
Expand All @@ -56,7 +69,7 @@ jobs:

fail:
name: Actions to run on fail
needs: [asp]
needs: [asp, ccmnet]
if: ${{ failure() }}
runs-on: ubuntu-latest
steps:
Expand Down
15 changes: 15 additions & 0 deletions tests/cypress/cypress/e2e/ccmnet/home.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
CCMnet Homepage for an unauthenticated user.
*/
describe("Unauthenticated user tests the CCMNet Homepage", () => {
it("Should test the CCMNet Homepage for unauthenticated user", () => {
cy.visit("/");

// Site heading
cy.get(".site-heading").contains(
"A peer-to-peer program for CI professionals to make connections and exchange knowledge"
);

});
});

36 changes: 36 additions & 0 deletions tests/cypress/cypress/e2e/ccmnet/mentorships/add-mentorship.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Authenticated user creates a new Mentorship Engagement.
*/
describe("Authenticated user creates a Mentorship Engagement", () => {
it("Authenticated user creates a Mentorship Engagement", () => {
cy.loginWith("[email protected]", "Pecan")
cy.visit("/node/add/mentorship_engagement")

// check the box for "I am looking for a mentor"
cy.get("#edit-field-me-looking-for-mentor").check()

cy.get("#edit-title-0-value").type("Mentorship Title")

cy.get("#edit-body-0-summary").type("Mentorship Summary")

cy.get('.form-item-body-0-value .ck-content').then(el => {
const editor = el[0].ckeditorInstance
editor.setData('Mentoring supports the growth of a vibrant HPC community by connecting students with experienced mentors. Matches are based on multiple factors, including research interests, career goals, long-term plans, and general interests. Providing valuable professional advice and resources that will benefit mentees which might include: sharing expertise in your specific research domain/discipline, sharing personal experiences and advice that might benefit your student mentee, encouraging students to stay abreast of scholarly literature and cutting-edge ideas in their field, Encouraging the open exchange of ideas, Facilitating networking opportunities with other faculty or professionals on campus or within the broader research community as appropriate.')
})

// get tag suggestions
// cy.get("#field-tags-replace input[type='submit']").click()

cy.get("details.tags summary").click()
cy.get("#tag-ai").click()

cy.get('.form-item-field-me-preferred-attributes-0-value .ck-content').then(el => {
const editor = el[0].ckeditorInstance
editor.setData('Be nice.')
})

cy.get('#edit-field-me-state').select('Recruiting')

cy.get(".node-mentorship-engagement-form #edit-submit").click()
});
});
20 changes: 20 additions & 0 deletions tests/cypress/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ Cypress.Commands.add("loginAs", (username, password) => {
cy.get(".form-submit").contains("Log in").click();
});

/**
* User login command for default /user/login route.
*
* Requires valid username and password.
*
* @param {string} username
* The username with which to log in.
* @param {string} password
* The password for the user's account.
*/
Cypress.Commands.add("loginWith", (username, password) => {
cy.drupalLogout();
cy.visit("/user/login");
cy.get("#edit-name").type(username);
cy.get("#edit-pass").type(password, {
log: false,
});
cy.get(".form-submit").contains("Log in").click();
});

/**
* Logs a user in by their uid via drush uli.
*/
Expand Down
Loading