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

Added Graphql tests #237

Conversation

OliverGeneser
Copy link
Contributor

No description provided.

@OliverGeneser
Copy link
Contributor Author

@prasadtalasila Here are the two Graphql tests with Apollo 😃

@@ -41,14 +47,29 @@ describe("End to End test for the application", () => {
expect(response.body).toEqual(expectedListDirectoryResponse);
}, 10000);

it("should return the content of a file given in the query ", async () => {
it("should return the filename corresponding to the directory given in the query |GraphQL|", async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

const query = e2eReadFile;

const response = await request("http://localhost:4001")
.post(process.env.APOLLO_PATH)
.send({ query });
expect(response.body).toEqual(expectedFileContentResponse);
}, 10000);

it("should return the content of a file given in the query |GraphQL|", async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@codecov-commenter
Copy link

Codecov Report

Merging #237 (3fdfc47) into feature/distributed-demo (04b6e4e) will decrease coverage by 34.07%.
Report is 2 commits behind head on feature/distributed-demo.
The diff coverage is n/a.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@                      Coverage Diff                      @@
##           feature/distributed-demo     #237       +/-   ##
=============================================================
- Coverage                     93.02%   58.95%   -34.07%     
=============================================================
  Files                             4        8        +4     
  Lines                            43      134       +91     
  Branches                          3        7        +4     
=============================================================
+ Hits                             40       79       +39     
- Misses                            0       49       +49     
- Partials                          3        6        +3     

see 12 files with indirect coverage changes

Components Coverage Δ
Website ∅ <ø> (∅)
Lib Microservice 58.95% <ø> (∅)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the following:

  1. import of child_process
  2. execSync("test/starttraefik.bash");
  3. execSync("test/stoptraefik.bash");

The suggested names for the tests:

  1. Should return the directory contents requested with HTTP POST query
  2. Should return the filecontent requested with HTTP POST query
  3. Should return the directory contents requested with GraphQL query
  4. Should return the filecontent requested with GraphQL query

A quick question: how are the environment variables supplied to this test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When yarn test -e is run, the tests fail with the following log:

$ script/test.bash -e
README.md file created with 'content123'
 FAIL  test/e2e/app.e2e.spec.ts
  ● Test suite failed to run

    Cannot find module 'react' from '../node_modules/@apollo/client/react/context/context.cjs'

    Require stack:
      /home/prasad/git/prasadtalasila/DTaaS/servers/lib/node_modules/@apollo/client/react/context/context.cjs
      /home/prasad/git/prasadtalasila/DTaaS/servers/lib/node_modules/@apollo/client/react/react.cjs
      /home/prasad/git/prasadtalasila/DTaaS/servers/lib/node_modules/@apollo/client/main.cjs
      e2e/app.e2e.spec.ts

      10 |   expectedListDirectoryResponse,
      11 | } from "../testUtil";
    > 12 | import { ApolloClient, InMemoryCache, gql } from "@apollo/client";
         | ^
      13 |
      14 | const client = new ApolloClient({
      15 |   uri: `http://localhost:4001${process.env.APOLLO_PATH}`,

      at Resolver._throwModNotFoundError (../node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.<anonymous> (../node_modules/@apollo/client/react/context/context.cjs:6:13)
      at Object.<anonymous> (../node_modules/@apollo/client/react/react.cjs:6:15)
      at Object.<anonymous> (../node_modules/@apollo/client/main.cjs:6:13)
      at Object.<anonymous> (e2e/app.e2e.spec.ts:12:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.552 s

@prasadtalasila
Copy link
Contributor

@OliverGeneser please check the comments

@prasadtalasila
Copy link
Contributor

@OliverGeneser Further changes:

  1. Please also delete test/starttraefik.bash and test/stoptraefik.bash scripts.
  2. If you can fix the unit and integration tests, that would be fantastic. Lets finish the end-to-end tests and then we can you can look into these tests.

@@ -41,14 +44,29 @@ describe("End to End test for the application", () => {
expect(response.body).toEqual(expectedListDirectoryResponse);
}, 10000);

it("should return the content of a file given in the query ", async () => {
it("should return the directory contents requested with GraphQL query", async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

const query = e2eReadFile;

const response = await request("http://localhost:4001")
.post(process.env.APOLLO_PATH)
.send({ query });
expect(response.body).toEqual(expectedFileContentResponse);
}, 10000);

it("should return the filecontent requested with GraphQL query", async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

await app.close();
}, 10000);

it("should return the filename corresponding to the directory given in the query", async () => {
it("should return the directory contents requested with HTTP POST query", async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

expect({data}).toEqual(expectedListDirectoryResponse);
}, 10000);

it("should return the filecontent requested with HTTP POST query", async () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

Copy link

codeclimate bot commented Nov 23, 2023

Code Climate has analyzed commit 73a91ed and detected 4 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 4

View more on Code Climate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants