graphql-engine/console/cypress
Varun Choudhary 3f19e8a3a8 console: allow tracking of custom SQL functions having composite type (rowtype) input arguments
Closes: https://github.com/hasura/graphql-engine/issues/6858

Description:

Following two things are done:

1. Show compatible functions in the Untracked custom functions list (i.e. even those with ROWTYPE arg)
![Screenshot from 2021-05-11 16-13-21](https://user-images.githubusercontent.com/68095256/117803100-dd606f80-b273-11eb-8d02-1ea55b31863d.png)
2. When a function with ROWTYPE argument is tracked, a confirmatory dialogue box is shown. The text reads `This function can be added as a root field or a computed field inside a table` and the buttons reflect the options: `Add as root field`, `Add as computed field` (this will take the user to the Modify -> Add a computed field section of the first-row type argument)
![Screenshot from 2021-06-03 17-28-28](https://user-images.githubusercontent.com/68095256/120641377-28dff500-c491-11eb-80ea-cc60e6f37f23.png)

Affected Component:

- [x] Console

Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com>
Co-authored-by: Abhijeet Khangarot <26903230+abhi40308@users.noreply.github.com>
GitOrigin-RevId: 089944aadba73f7a77e220a49489846ff1cb9540
2021-06-08 15:22:24 +00:00
..
fixtures add console to graphql-engine 2018-06-28 10:27:37 +05:30
helpers console: revert improve data/relationships e2e tests 2021-05-12 07:37:45 +00:00
integration console: allow tracking of custom SQL functions having composite type (rowtype) input arguments 2021-06-08 15:22:24 +00:00
plugins console: more tests (#35) 2018-07-04 18:27:56 +05:30
support console: revert improve data/relationships e2e tests 2021-05-12 07:37:45 +00:00
.eslintrc console: revert improve data/relationships e2e tests 2021-05-12 07:37:45 +00:00
global.d.ts console: migrate cypress tests to TypeScript (#4550) 2020-05-27 14:56:29 +05:30
README.md console: improve cypress testing docs 2021-03-19 08:29:56 +00:00
tsconfig.json console: migrate cypress tests to TypeScript (#4550) 2020-05-27 14:56:29 +05:30

Test

Running all tests to generate coverage

  1. Set the TEST_MODE field in cypress.json to cli
  2. Run the command npm run test from the console directory to run all the tests.

You can also run the complete tests from the cypress electron app:

  1. Set the TEST_MODE field in cypress.json to cli
  2. Run npm run cypress from the console directory.
  3. Click on test_complete.js

Running tests individually

Tests are modularized into following modules:

  • API-Explorer
  • Data
    • Migration Mode
    • Create Table
    • Insert Browse
    • Modify Table
    • Table Relationships
    • Table and View Permissions
    • Views

To run the tests for the modules individually (say for create table),

  • Go to the cypress.json and set the env > TEST_MODE variable to ui.
{
  "env": {
    "TEST_MODE": "ui"
  }
}
  • Run the command npm run cypress and click on create-table > test.js

Writing Tests

  • Read ups

    • If this is your first time with cypress, check out this getting started guide

    • Read cypress best practices

  • File Structure

    The top-level directories in console/cypress are auto-generated by cypress except helpers. To understand the use of each directory check out Folder Structure

    helpers directory is used for sharing reusable functions/constants across tests. Before adding a resubale function in this directory, consider if it will be better as a custom cypress command, if so, then add it to Support directory following this guide, preferrably to command.ts file.

  • Adding a Test

    Tests go to integration directory, where there are folders corresponding to Components in Services directory (The top-level routes on the console).

    Each of these folders contains different test folders, named after the particular feature they are testing. For example create-table folder tests the functionality of creating a table from the console UI.