Giter Club home page Giter Club logo

gitlab-cypress's Introduction

GitLab Cypress

main gitlab-cypess

Sample project to experiment with Cypress to test the GitLab application.

Pre-requirements

You need to have a GitLab local environment such as GDK or Docker up and running.

You also need to have Node.js and npm installed on your computer.

For this project, the following versions of Node.js and npm were used:

$ node -v
v18.13.0

$ npm -v
8.19.3

Running GitLab on Docker

Run docker run --publish 80:80 --name gitlab --hostname localhost wlsf82/gitlab-ce and wait for the environment to be up and running (this might take a minute or so).

All should be ok if, when accessing the http://localhost/ URL, a form to define the password of the root user is displayed.

โ—THERE'S NO NEED TO DEFINE THE PASSWORD MANUALLYโ—

There's an automated test for it. ๐Ÿ˜‰

Keep reading.

Installation

Run npm i to install the dev dependencies.

Tests

Before running the tests, create a file called cypress.env.json in the project root directory, based on the cypress.env.example.json file, and update the value of the user_password property with one of your choice.

By default, the tests will run against http://localhost/, but if you need to run them in a different URL (e.g.: http://localhost:3000/), change the baseUrl property in the cypress.config.js file.

Headless mode

Run npm test to run all tests in headless mode.

Run npm run test:api to run only the API tests in headless mode.

Run npm run test:gui:project:issue to run only the GUI Project-issue-related tests in headless mode.

Run npm run test:gui:project:but:issue to run only the GUI Project-but-issue-related tests in headless mode.

Run npm run test:gui:all:but:project to run only the GUI Project-not-related tests in headless mode.

Interactive mode

  1. Run npm run cy:open to open the Cypress App;
  2. Select E2E Testing;
  3. Select one of the available browsers (e.g., Electron), and click the Start button;
  4. Run the cypress/e2e/gui/profile/createAccessToken.cy.js test;
  5. Finally, click on the test file you want to run and wait for it to finish.

Important notes about the above steps

Do not skip step 4! It will authenticate the root user, create a GitLab Access Token, and make it available to all other tests while the Cypress App is kept open unless the cypress/e2e/gui/profile/deleteAccessTokens.cy.js test is run. In such a case, the cypress/e2e/gui/profile/createAccessToken.cy.js test needs to be re-run.

Also, step 4 creates a session for the root user, which will be restored by most tests. This means that login via GUI should only happens once, speeding up the execution. ๐ŸŽ๏ธ

Example

Here's an example of running all the GUI tests in interactive mode.

index.cy.js.mp4

Contributing

If you want to contribute to this project, follow the below steps.

  1. Fork the project;
  2. Clone your fork and make your changes;
  3. Test your changes locally, and move on only when all tests are green;
  4. Push your changes to GitHub and create a pull request (PR);
  5. After the GitHub Workflow of your PR is green, tag @wlsf82, ask for review and wait for feedback;
  6. If everything goes well, you should have your changes rebased and merged to the main branch. Otherwise, you will receive comments with adjustments needed before merging.

This is the commit messaging guidelines you should follow.


Developed with ๐Ÿ’š by Walmyr.

gitlab-cypress's People

Contributors

dependabot[bot] avatar wlsf82 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlab-cypress's Issues

Create GUI test for "Deploy key creation"

As a test pre-condition, the root user has to be authenticated.

Following is the page for the creation of a new public deploy key: http://localhost/admin/deploy_keys/new.

Remember to add the new test to the cypress/e2e/gui/allButProject.cy.js file, anywhere between the access token creation and deletion (preferably closer to another test of the same domain - admin/.)

If you need more information, don't hesitate to tag me (@wlsf82).

Also, remember to follow the project's contributing guidelines.

Cc. @Fabricioperrone.

Create GUI test for assigning an issue to a different user than yourself

As a test pre-condition, a user has to be created and assigned to the same project of the issue so you can assign the user to the issue.

This user creation must happen via an API call, not the GUI.

This test implementation should help you with understanding how to create a user via API, as well as how to add the user to the same project as the root user.

You can use the following test as a reference: cypress/e2e/gui/project/assignIssue.cy.js

Remember to add the new test to the cypress/e2e/gui/project/index.cy.js file, anywhere between the access token creation and deletion.

If you need more information, don't hesitate to tag me (@wlsf82).

Also, remember to follow the project's contributing guidelines.

Cc. @atilacassel.

Investigate flakiness on "shows an open issue on the issue board, closes it, and shows it closed" test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.