Skip to content

Commit

Permalink
Merge pull request #144 from COS301-SE-2023/hotfix/v0.1.0
Browse files Browse the repository at this point in the history
Hotfix/v0.1.0 to Main
  • Loading branch information
PaulPilane authored Jul 5, 2023
2 parents 3e8a7f1 + d4cafaa commit ec6439d
Show file tree
Hide file tree
Showing 40 changed files with 1,612 additions and 189 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Development CI

on:
push:
branches: [ feat/* ]
branches: [ feat/*, hotfix/* ]
pull_request:
branches: [ dev, feat/* ]
branches: [ dev, feat/*, hotfix/* ]
workflow_call:

permissions:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
run: npx nx run app:lint

- name: Test Workspace
run: npm run test:app:ci
run: npm run test:workspace:ci

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
Expand All @@ -55,6 +55,9 @@ jobs:
with:
files: coverage/lcov.info

- name: e2e Test App
run: npm run e2e:app:ci

- name: Build App
run: npm run build:app:dev

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ jobs:
run: npx nx run app:lint

- name: Test Workspace
run: npm run test:app:ci
run: npm run test:workspace:ci

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: coverage/lcov.info

- name: e2e Test App
run: npm run e2e:app:prod

- name: Build App
run: npm run build:app:prod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -23,7 +22,7 @@
import com.fridgetoplate.repository.IngredientRepository;

@RestController
@CrossOrigin(origins = "*", allowedHeaders = "", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@CrossOrigin(origins = "*", allowedHeaders = "*", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@RequestMapping("/ingredients")
public class IngredientController {
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -13,14 +12,13 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fridgetoplate.model.Preference;
import com.fridgetoplate.repository.PreferenceRepository;

@RestController
@CrossOrigin(origins = "*", allowedHeaders = "", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@CrossOrigin(origins = "*", allowedHeaders = "*", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@RequestMapping("/preferences")
public class PreferenceController {
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import com.fridgetoplate.repository.ProfileRepository;

@RestController
@CrossOrigin(origins = "*", allowedHeaders = "", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@CrossOrigin(origins = "*", allowedHeaders = "", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@CrossOrigin(origins = "*", allowedHeaders = "*", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@RequestMapping("/profiles")

public class ProfileController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.fridgetoplate.model.Recipe;

@RestController
@CrossOrigin(origins = "*", allowedHeaders = "", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@CrossOrigin(origins = "*", allowedHeaders = "*", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE })
@RequestMapping("/recipes")
public class RecipeController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.fridgetoplate.model.Recipe;

@RestController
@CrossOrigin(origins = "*", allowedHeaders = "", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT,
@CrossOrigin(origins = "*", allowedHeaders = "*", methods = { RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT,
RequestMethod.DELETE })
@RequestMapping("/recommend")

Expand Down
1 change: 0 additions & 1 deletion apps/api/src/main/java/com/fridgetoplate/model/Recipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.fridgetoplate.utils.StringArrayConverter;
import com.fridgetoplate.utils.IngredientArrayConverter;
import com.fridgetoplate.utils.RecipeStepArrayConverter;
import com.fridgetoplate.utils.RecipeStepArrayConverter;

import lombok.Data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.fasterxml.jackson.annotation.JsonProperty;

public class RecipeStep {
@JsonProperty("instructionHead")
private String instructionHead;
@JsonProperty("instructionHeading")
private String instructionHeading = "N/A";

@JsonProperty("instructionBody")
private String instructionBody;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.fridgetoplate.repository;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
Expand Down
74 changes: 65 additions & 9 deletions apps/app-e2e/src/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,69 @@
import { getGreeting } from "../support/app.po";
import { data } from 'cypress/types/jquery';
import { getGreeting } from '../support/app.po';

describe("app", () => {
beforeEach(() => cy.visit("/"));
describe('login tests', () => {
beforeEach(() => cy.visit('/'));

it("should display welcome message", () => {
// Custom command example, see `../support/commands.ts` file
cy.login("my-email@something.com", "myPassword");
// it('successfully loads login', () => {
// cy.get('h1').contains('Hey, Welcome Back');
// });

// Function helper example, see `../support/app.po.ts` file
getGreeting().contains("Welcome app");
});
// it('should prevent incorrect login attempt', () => {
// cy.fixture('user-details.json').then((userData) => {
// cy.get('input[name="username"]').type(userData.username);
// cy.get('input[name="password"]').type(userData.password);
// cy.get('button').click();
// cy.url().contains('profile');
// });
// });

// it('should attempt login', () => {
// cy.get('input[name="username"]').type('smileyazola@gmail.com');
// cy.get('input[name="password"]').type('randomPassword!');
// cy.get('button').click();
// cy.url().contains('profile');
// });

// it('should navigate to signup', () => {
// cy.get('button').click();
// cy.url().contains('signup');
// });
});

describe('signup tests', () => {
beforeEach(() => cy.visit('/'));
});
// it('successfully loads signup', () => {
// cy.get('h1').contains('Hey, Welcome Back');
// });

// it('should attempt signup', () => {
// cy.fixture('user-details.json').then((userData) => {
// cy.get('input[name="username"]').type(userData.username);
// cy.get('input[name="password"]').type(userData.password);
// cy.get('button').click();
// cy.url().contains('profile');
// });
// });

// it('should navigate to login', () => {
// cy.get('button').click();
// cy.url().contains('login');
// });
// });

describe('profile tests', () => {
beforeEach(() => cy.visit('/'));
});

describe('create tests', () => {
beforeEach(() => cy.visit('/'));
});

describe('generate tests', () => {
beforeEach(() => cy.visit('/'));
});

describe('details tests', () => {
beforeEach(() => cy.visit('/'));
});
10 changes: 10 additions & 0 deletions apps/app-e2e/src/fixtures/user-details.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"username": "First",
"password": "Password1!"
},
{
"username": "Second",
"password": "Password2!"
}
]
6 changes: 5 additions & 1 deletion apps/app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["../../.eslintrc.json"],
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
Expand Down Expand Up @@ -31,6 +31,10 @@
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {}
},
{
"files": ["*.cy.{ts,js,tsx,jsx}", "cypress/**/*.{ts,js,tsx,jsx}"],
"rules": {}
}
]
}
8 changes: 8 additions & 0 deletions apps/app/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';

export default defineConfig({
e2e: nxE2EPreset(__dirname, {
cypressDir: 'cypress',
}),
});
70 changes: 70 additions & 0 deletions apps/app/cypress/e2e/app.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
describe('login tests', () => {
beforeEach(() => cy.visit('/'));

it('successfully loads login', () => {
cy.get('h1').contains('Hey, Welcome Back');
});

// it('should prevent incorrect login attempt', () => {
// cy.fixture('user-details.json').then((userData) => {
// cy.get('input[name="username"]').type(userData.username);
// cy.get('input[name="password"]').type(userData.password);
// cy.get('button').click();
// cy.url().contains('profile');
// });
// });

// it('should attempt login', () => {
// cy.get('input[name="username"]').type('smileyazola@gmail.com');
// cy.get('input[name="password"]').type('randomPassword!');
// cy.get('button').click();
// cy.url().contains('profile');
// });

// it('should navigate to signup', () => {
// cy.get('button').click();
// cy.url().contains('signup');
// });
// });

// describe('signup tests', () => {
// beforeEach(() => cy.visit('/'));

// it('successfully loads signup', () => {
// cy.get('h1').contains('Hey, Welcome Back');
// });

// it('should attempt signup', () => {
// cy.fixture('user-details.json').then((userData) => {
// cy.get('input[name="username"]').type(userData.username);
// cy.get('input[name="password"]').type(userData.password);
// cy.get('button').click();
// cy.url().contains('profile');
// });
// });

// it('should navigate to login', () => {
// cy.get('button').click();
// cy.url().contains('login');
// });
});

describe('profile tests', () => {
beforeEach(() => cy.visit('/'));
cy.get('h1').contains('Hey, Welcome Back');
});

describe('create tests', () => {
beforeEach(() => cy.visit('/'));
cy.get('h1').contains('Hey, Welcome Back');
});

describe('generate tests', () => {
beforeEach(() => cy.visit('/'));
cy.get('h1').contains('Hey, Welcome Back');
});

describe('details tests', () => {
beforeEach(() => cy.visit('/'));
cy.get('h1').contains('Hey, Welcome Back');
});
4 changes: 4 additions & 0 deletions apps/app/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}
1 change: 1 addition & 0 deletions apps/app/cypress/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get('h1');
33 changes: 33 additions & 0 deletions apps/app/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// 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
// ***********************************************

// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: 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) => { ... })
17 changes: 17 additions & 0 deletions apps/app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands';
Loading

0 comments on commit ec6439d

Please sign in to comment.