diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress-pull.yml similarity index 97% rename from .github/workflows/cypress.yml rename to .github/workflows/cypress-pull.yml index 9a1b48232e..6c3986b719 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress-pull.yml @@ -1,8 +1,5 @@ -name: Cypress +name: Cypress - Pull-request on: - push: - branches-ignore: - - 'renovate/**' pull_request: jobs: diff --git a/.github/workflows/cypress-push.yml b/.github/workflows/cypress-push.yml new file mode 100644 index 0000000000..75d5988358 --- /dev/null +++ b/.github/workflows/cypress-push.yml @@ -0,0 +1,91 @@ +name: Cypress - Push +on: + push: + branches-ignore: + - 'renovate/**' + +jobs: + cypress-run: + name: Test + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: + containers: [1, 2, 3, 4, 5, 6] + browsers: [chrome, firefox] + node-version: [14.x] + services: + mongodb: + image: mongo:3.6.19 + ports: + - 27017:27017 + mailhog: + image: mailhog/mailhog + ports: + - 1025:1025 + + steps: + # We use .npmrc to set the default version to 0, and prevents download during development. + # This installs it specifically in the CI runs. + - name: Set Action Environment Variables + run: | + echo "CYPRESS_RECORD_KEY=${{ secrets.CYPRESS_RECORD_KEY }}" >> $GITHUB_ENV + echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV + echo "CYPRESS_INSTALL_BINARY=7.1.0" >> $GITHUB_ENV + + - name: Checkout Source Files + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Set freeCodeCamp Environment Variables + run: cp sample.env .env + + - name: Install Dependencies + run: | + npm ci + npm run ensure-env + npm run build:curriculum + + - name: Seed Database + run: npm run seed + + - name: Generate fixture data + run: npm run precypress:gen:fixtures + + - name: Generate Specfiles for challenges + run: npm run precypress:gen:test + + - name: Cypress run + uses: cypress-io/github-action@v2 + with: + parallel: ${{ env.CYPRESS_RECORD_KEY != 0 }} + group: ${{ matrix.browsers }} + record: ${{ env.CYPRESS_RECORD_KEY != 0 }} + build: npm run build + # this should mirror the production build, but for now we're using gatsby + # serve instead (the npm script serve:client needs updating!) + start: npm run start-ci + wait-on: http://localhost:8000 + # the site builds in about 8 minutes, so there is currently 12 minutes of time + # left for testing. + wait-on-timeout: 1200 + config: baseUrl=http://localhost:8000 + browser: ${{ matrix.browsers }} + headless: true diff --git a/.gitignore b/.gitignore index 27070638e8..e84540e57d 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,10 @@ coverage cypress/videos cypress/screenshots +### Cypress generated fixtures and tests ### +cypress/fixtures/path-data +cypress/integration/challenge-tests/blocks + # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt @@ -179,3 +183,4 @@ api-server/lib/* curriculum/dist curriculum/build client/static/_redirects + diff --git a/cypress.json b/cypress.json index b88626651a..5f604d630f 100644 --- a/cypress.json +++ b/cypress.json @@ -1,5 +1,6 @@ { "projectId": "ke77ns", "baseUrl": "http://localhost:8000", - "retries": 4 + "retries": 4, + "videoUploadOnPasses": false } diff --git a/cypress/integration/challenge-tests/blocks/.gitkeep b/cypress/integration/challenge-tests/blocks/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cypress/integration/ShowCertification.js b/cypress/integration/main-tests/ShowCertification.js similarity index 100% rename from cypress/integration/ShowCertification.js rename to cypress/integration/main-tests/ShowCertification.js diff --git a/cypress/integration/landing.js b/cypress/integration/main-tests/landing.js similarity index 100% rename from cypress/integration/landing.js rename to cypress/integration/main-tests/landing.js diff --git a/cypress/integration/learn/challenges/backend.js b/cypress/integration/main-tests/learn/challenges/backend.js similarity index 100% rename from cypress/integration/learn/challenges/backend.js rename to cypress/integration/main-tests/learn/challenges/backend.js diff --git a/cypress/integration/learn/challenges/output.js b/cypress/integration/main-tests/learn/challenges/output.js similarity index 100% rename from cypress/integration/learn/challenges/output.js rename to cypress/integration/main-tests/learn/challenges/output.js diff --git a/cypress/integration/learn/challenges/projects.js b/cypress/integration/main-tests/learn/challenges/projects.js similarity index 100% rename from cypress/integration/learn/challenges/projects.js rename to cypress/integration/main-tests/learn/challenges/projects.js diff --git a/cypress/integration/learn/coding-interview-prep/intro-page.js b/cypress/integration/main-tests/learn/coding-interview-prep/intro-page.js similarity index 100% rename from cypress/integration/learn/coding-interview-prep/intro-page.js rename to cypress/integration/main-tests/learn/coding-interview-prep/intro-page.js diff --git a/cypress/integration/learn/common-components/footer.js b/cypress/integration/main-tests/learn/common-components/footer.js similarity index 100% rename from cypress/integration/learn/common-components/footer.js rename to cypress/integration/main-tests/learn/common-components/footer.js diff --git a/cypress/integration/learn/common-components/helpButton.js b/cypress/integration/main-tests/learn/common-components/helpButton.js similarity index 100% rename from cypress/integration/learn/common-components/helpButton.js rename to cypress/integration/main-tests/learn/common-components/helpButton.js diff --git a/cypress/integration/learn/common-components/navbar.js b/cypress/integration/main-tests/learn/common-components/navbar.js similarity index 100% rename from cypress/integration/learn/common-components/navbar.js rename to cypress/integration/main-tests/learn/common-components/navbar.js diff --git a/cypress/integration/learn/common-components/searchBar.js b/cypress/integration/main-tests/learn/common-components/searchBar.js similarity index 100% rename from cypress/integration/learn/common-components/searchBar.js rename to cypress/integration/main-tests/learn/common-components/searchBar.js diff --git a/cypress/integration/learn/donate/donate-page-default.js b/cypress/integration/main-tests/learn/donate/donate-page-default.js similarity index 100% rename from cypress/integration/learn/donate/donate-page-default.js rename to cypress/integration/main-tests/learn/donate/donate-page-default.js diff --git a/cypress/integration/learn/donate/donate-page-donor.js b/cypress/integration/main-tests/learn/donate/donate-page-donor.js similarity index 100% rename from cypress/integration/learn/donate/donate-page-donor.js rename to cypress/integration/main-tests/learn/donate/donate-page-donor.js diff --git a/cypress/integration/learn/donate/donation-block-completion-modal.js b/cypress/integration/main-tests/learn/donate/donation-block-completion-modal.js similarity index 100% rename from cypress/integration/learn/donate/donation-block-completion-modal.js rename to cypress/integration/main-tests/learn/donate/donation-block-completion-modal.js diff --git a/cypress/integration/learn/index.js b/cypress/integration/main-tests/learn/index.js similarity index 100% rename from cypress/integration/learn/index.js rename to cypress/integration/main-tests/learn/index.js diff --git a/cypress/integration/learn/redirects/challenges.js b/cypress/integration/main-tests/learn/redirects/challenges.js similarity index 100% rename from cypress/integration/learn/redirects/challenges.js rename to cypress/integration/main-tests/learn/redirects/challenges.js diff --git a/cypress/integration/learn/responsive-web-design/basic-css/index.js b/cypress/integration/main-tests/learn/responsive-web-design/basic-css/index.js similarity index 100% rename from cypress/integration/learn/responsive-web-design/basic-css/index.js rename to cypress/integration/main-tests/learn/responsive-web-design/basic-css/index.js diff --git a/cypress/integration/learn/responsive-web-design/intro-page.js b/cypress/integration/main-tests/learn/responsive-web-design/intro-page.js similarity index 100% rename from cypress/integration/learn/responsive-web-design/intro-page.js rename to cypress/integration/main-tests/learn/responsive-web-design/intro-page.js diff --git a/cypress/integration/settings/certifications.js b/cypress/integration/main-tests/settings/certifications.js similarity index 100% rename from cypress/integration/settings/certifications.js rename to cypress/integration/main-tests/settings/certifications.js diff --git a/cypress/integration/settings/email-change.js b/cypress/integration/main-tests/settings/email-change.js similarity index 100% rename from cypress/integration/settings/email-change.js rename to cypress/integration/main-tests/settings/email-change.js diff --git a/cypress/integration/settings/image-picture-check.js b/cypress/integration/main-tests/settings/image-picture-check.js similarity index 100% rename from cypress/integration/settings/image-picture-check.js rename to cypress/integration/main-tests/settings/image-picture-check.js diff --git a/cypress/integration/settings/settings.js b/cypress/integration/main-tests/settings/settings.js similarity index 100% rename from cypress/integration/settings/settings.js rename to cypress/integration/main-tests/settings/settings.js diff --git a/cypress/integration/settings/username-change.js b/cypress/integration/main-tests/settings/username-change.js similarity index 100% rename from cypress/integration/settings/username-change.js rename to cypress/integration/main-tests/settings/username-change.js diff --git a/cypress/integration/tags.js b/cypress/integration/main-tests/tags.js similarity index 100% rename from cypress/integration/tags.js rename to cypress/integration/main-tests/tags.js diff --git a/cypress/integration/top-contributor.js b/cypress/integration/main-tests/top-contributor.js similarity index 100% rename from cypress/integration/top-contributor.js rename to cypress/integration/main-tests/top-contributor.js diff --git a/cypress/integration/user/report-user.js b/cypress/integration/main-tests/user/report-user.js similarity index 100% rename from cypress/integration/user/report-user.js rename to cypress/integration/main-tests/user/report-user.js diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 6b713888e4..5247fc56a4 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -1,17 +1,5 @@ -// *********************************************************** -// This example plugins/index.js can be used to load plugins -// -// You can change the location of this file or turn off loading -// the plugins file with the 'pluginsFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/plugins-guide -// *********************************************************** - -// This function is called when a project is opened or re-opened (e.g. due to -// the project's config changing) /* eslint-disable no-unused-vars */ -module.exports = (on, config) => { - // `on` is used to hook into various events Cypress emits - // `config` is the resolved Cypress config + +module.exports = function (on, config) { + // configure plugins here }; diff --git a/cypress/support/commands.js b/cypress/support/commands.js index c7e31a4757..3ff47e13d2 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,37 +1,4 @@ -/* global cy Cypress*/ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => {}); -// -// -// -- This is a child command -- -// Cypress.Commands.add( -// 'drag', -// { prevSubject: 'element' }, -// (subject, options) => {} -// ); -// -// -// -- This is a dual command -- -// Cypress.Commands.add( -// 'dismiss', -// { prevSubject: 'optional' }, -// (subject, options) => {} -// ); -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => {}); +/* global cy Cypress */ Cypress.Commands.add('login', () => { cy.visit('/'); @@ -52,3 +19,50 @@ Cypress.Commands.add('resetUsername', () => { cy.contains('Account Settings for developmentuser').should('be.visible'); }); + +Cypress.Commands.add('testChallenges', () => { + // Test Meta tags + cy.get('head meta[charset=utf-8]'); + cy.get('head meta[name=description]').should('have.attr', 'content'); + + // Test breadcrumbs + cy.get('.breadcrumb-right').should('have.attr', 'href'); + cy.get('.ellipsis').should('be.visible'); + cy.get('.breadcrumb-left').should('have.attr', 'href'); + cy.get('.breadcrumb-left').should('be.visible', 'href'); + + cy.get('body').should('be.visible'); + + // Challenge content + cy.get('.challenge-title').should('be.visible'); + cy.get('#description').should('be.visible'); + + // Monaco editor + cy.get('.react-monaco-editor-container') + .click() + .focused() + .type('