diff --git a/bin/savv-sh/becomes-current-environment b/bin/savv-sh/becomes-current-environment new file mode 100644 index 00000000..4edf0061 --- /dev/null +++ b/bin/savv-sh/becomes-current-environment @@ -0,0 +1,32 @@ +#!/bin/bash + +# Detect the home directory +home_dir=$(eval echo "~") + +# Source the common functions +source $home_dir/src/bin/savv-shared-functions.sh + +# Check if an environment parameter is provided +if [ $# -lt 1 ]; then + echo "Error: No environment parameter provided." + exit 1 +fi + +# Environment parameter (dev, staging, prod) +ENV_PARAM=$1 + +# Get the current project +current_project=$(get_active_project) + +# Define the source and destination paths +SOURCE_PATH="$home_dir/src/$current_project/src/app/_environments/environment.${ENV_PARAM}.ts" +DESTINATION_PATH="$home_dir/src/$current_project/src/app/_environments/environment.ts" + +# Copy the environment file +if [ -f "$SOURCE_PATH" ]; then + cp "$SOURCE_PATH" "$DESTINATION_PATH" +# echo "Environment file copied to $DESTINATION_PATH" +else + echo "Error: Source environment file $SOURCE_PATH does not exist." + exit 1 +fi diff --git a/cypress/e2e/attributes.page.cy.js b/cypress/e2e/attributes.page.cy.js index fc4d7037..4b333d29 100644 --- a/cypress/e2e/attributes.page.cy.js +++ b/cypress/e2e/attributes.page.cy.js @@ -1,18 +1,35 @@ describe('Attributes Page', () => { Cypress.Commands.add('goToAttributesPage', () => { - cy.visit('http://localhost:8100/login') - cy.get('[data-test="sign-in-btn"]').click() + cy.appLogin(); + + const userId = '12345'; + + cy.intercept('GET', 'api/attributes/' + userId, (req) => { + req.reply({ + statusCode: 200, + body: [{"phrase":{"id":3,"adverb":"","verb":"sculpts","preposition":"with","noun":"clay"},"userCount":1},{"phrase":{"id":2,"adverb":"","verb":"plays","preposition":"","noun":"chess"},"userCount":2}] + }); + }); cy.contains('ion-item', 'Attributes').click(); }); + it('navigate to attributes page', () => { + cy.goToAttributesPage(); + }); + + it('should display a list of attributes', () => { + cy.goToAttributesPage(); + cy.get('.attributeItem').should('have.length', 2); + }); + describe('Create Attributes Page', () => { Cypress.Commands.add('goToCreateAttributesPage', () => { + cy.goToAttributesPage(); cy.get('[data-test="launchHeaderPrimaryActionButton"]').click(); }); Cypress.Commands.add('fillAttributesForm', (adverb, verb, preposition, noun) => { - cy.goToAttributesPage(); cy.goToCreateAttributesPage(); if (adverb) { diff --git a/cypress/e2e/connect.page.cy.js b/cypress/e2e/connect.page.cy.js index 95ec642c..1b7dc60f 100644 --- a/cypress/e2e/connect.page.cy.js +++ b/cypress/e2e/connect.page.cy.js @@ -1,8 +1,64 @@ -it('Connect page should have accept new connection button', () => { +describe('Connections Page', () => { + Cypress.Commands.add('goToConnectionsPage', () => { + cy.appLogin(); + cy.get('[data-test="connect-menu-item"]').click(); + }); - cy.visit('http://localhost:8100/login') - cy.get('[data-test="sign-in-btn"]').click() - cy.get('[data-test="launchConnectPageButton"]').click() - cy.get('[data-test="acceptNewConnectionBtn"]').click() - cy.visit('http://localhost:8100/connect/accept-new-connection') + it('navigate to connections page', () => { + cy.goToConnectionsPage(); + }); + + it('should display connections page', () => { + cy.goToConnectionsPage(); + cy.get('.listbtn').should('have.length', 1); + cy.get('.openbtn').should('have.length', 1); + cy.get('.acceptbtn').should('have.length', 1); + }); + + describe('List Connections Page', () => { + Cypress.Commands.add('goTolistConnectionPage', () => { + cy.goToConnectionsPage(); + + // get a component with the class "listbtn" and click it + cy.get('.listbtn').click(); + }); + + const userId = '12345'; + + it('should display list connections page', () => { + cy.intercept('GET', 'api/connect/' + userId + '/all', (req) => { + req.reply({ + statusCode: 200, + body: [{ + to: { + userId: '344', + username: 'testuser1' + } + }, + { + to: { + userId: '345', + username: 'testuser2', + } + }, { + to: { + userId: '346', + username: 'testuser3', + } + }] + }); + }).as('getAllConnections'); + + cy.goTolistConnectionPage(); + cy.get('[data-test="connectionListItem"]').should('have.length', 3); + }); + }); + + describe('Accept New Connection Page', () => { + + }); + + describe('Open Connection Page', () => { + + }); }) diff --git a/cypress/e2e/review-attributes.page.cy.js b/cypress/e2e/review-attributes.page.cy.js index c2abf8f9..ef9a2dfe 100644 --- a/cypress/e2e/review-attributes.page.cy.js +++ b/cypress/e2e/review-attributes.page.cy.js @@ -1,29 +1,61 @@ -describe('check for inputs and buttons on review attributes page', () => { +describe('Review Attributes page', () => { + Cypress.Commands.add('goToReviewAttributesPage', () => { + cy.appLogin(); + + cy.intercept('GET', 'http://localhost:8080/api/review', (req) => { + req.reply({ + statusCode: 200, + body: [{"id":5,"hasBeenGroomed":true,"adverb":"1never","verb":"converts","preposition":"from","noun":"mac"}] + }); + }); - // get to review attributes page - it('navigate to review attributes page', () => { - cy.visit('http://localhost:8100/login') - cy.get('[data-test="sign-in-btn"]').click() + cy.contains('ion-item', 'Review Attributes').click(); - cy.get('[data-test="review-attributes-menu-item"]').should('have.length', 1) - cy.get('[data-test="review-attributes-menu-item"]').click() - }) + cy.get('[data-test="launchGetNextPhraseBtn"]').should('have.length', 1) + }); + + Cypress.Commands.add('getNextPhrase', (obj) => { + cy.goToReviewAttributesPage(); + + cy.intercept('GET', 'http://localhost:8080/api/review', (req) => { + req.reply({ + statusCode: 200, + body: [{ + "id":obj['id'] || 5, + "hasBeenGroomed":obj['hasBeenGroomed'] || true, + "adverb":obj['adverb'],"verb":obj['verb'], + "preposition":obj['preposition'],"noun":obj['noun']}] + }); + }).as('getReview'); + cy.wait('@getReview') + + // click get next phrase button + cy.get('[data-test="launchGetNextPhraseBtn"]').should('have.length', 1) + cy.get('[data-test="launchGetNextPhraseBtn"]').click() + }); + + it('navigate to review attributes page', () => { + cy.goToReviewAttributesPage(); + }); // display placeholder text in input field (expect: Click get next phrase to review) it('should display placeholder text in input field', () => { + cy.goToReviewAttributesPage(); cy.get('input[placeholder*="Click get next phrase to review"]') }) - // display mock phrase in input field when get next phrase button clicked (expect: competitively writes nullvalue code) it('check to see if the get next review button displays mock data in input field', () => { - cy.get('[data-test="launchGetNextPhraseBtn"]').should('have.length', 1) - cy.get('[data-test="launchGetNextPhraseBtn"]').click() - cy.get('[data-test="inputPhraseToBeReviewed"]').should('have.value', "competitively writes nullvalue code") + cy.getNextPhrase({"id": 5, "hasBeenGroomed": true, "adverb": "never", "verb": "converts", "preposition": "from", "noun": "mac"}); + // cy.wait('@getReview').its('response.body').should('have.length', 1) + + cy.get('[data-test="launchApproveBtn"]').should('have.length', 1) + cy.get('[data-test="inputPhraseToBeReviewed"]').should('have.value', "never converts from mac") }) // display alert after approve button clicked it('should display an alert after approve button clicked', () => { + cy.getNextPhrase({"id": 5, "hasBeenGroomed": true, "adverb": "never", "verb": "converts", "preposition": "from", "noun": "mac"}); // click approve button cy.get('[data-test="launchApproveBtn"]').should('have.length', 1) @@ -40,15 +72,11 @@ describe('check for inputs and buttons on review attributes page', () => { // Assert that the alert is no longer visible (it has been dismissed) cy.get('ion-alert').should('not.exist'); - }) // display alert after reject button clicked (expect: mock data option "doesn't make sense") it('should display an alert after reject button clicked', () => { - - // click get next phrase button - cy.get('[data-test="launchGetNextPhraseBtn"]').should('have.length', 1) - cy.get('[data-test="launchGetNextPhraseBtn"]').click() + cy.getNextPhrase({"id": 5, "hasBeenGroomed": true, "adverb": "never", "verb": "converts", "preposition": "from", "noun": "mac"}); // click reject button cy.get('[data-test="launchRejectBtn"]').should('have.length', 1) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 698b01a4..31c3f096 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -34,4 +34,32 @@ // visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable // } // } -// } \ No newline at end of file +// } + +Cypress.Commands.add('appLogin', () => { + cy.intercept('POST', 'http://localhost:8080/api/public/login', (req) => { + req.reply({ + statusCode: 200, + headers: { + "Authorization": "Bearer ey", + }, + body: { + "id": 12345, + "name": "testuser", + "password": "$2a$10$wGcNuV0Kodg7uz6qI/l/1uz1mMcpmAGZqfuZ3JxY9cAeejtYXUbWC", + "phone": "3035551213", + "email": "testuser@tribeapp.com", + "enabled": 1, + "roles": [{"id": 2, "name": "ROLE_accountholder"}], + "created": 1724528143000, + "lastUpdated": 1724528143000 + } + }); + }).as('login'); + + cy.visit('http://localhost:8100/login') + cy.get('[data-test="sign-in-btn"]').click() + + cy.wait('@login'); +}); + diff --git a/src/app/pages/attributes-page/attributes.page.html b/src/app/pages/attributes-page/attributes.page.html index 8657167c..59806a81 100644 --- a/src/app/pages/attributes-page/attributes.page.html +++ b/src/app/pages/attributes-page/attributes.page.html @@ -2,7 +2,7 @@ [primaryActionButtonText]="headerPagePrimaryActionButtonText" [primaryActionButtonFunc]="getCreateBtnClickFunc()"> - + {{attr['phrase']['adverb'] || ''}} {{attr['phrase']['verb'] || ''}} {{attr['phrase']['preposition'] || ''}} {{attr['phrase']['noun'] || ''}} ({{attr['userCount'] || '0'}} users) diff --git a/src/app/pages/connect-page/connect.page.html b/src/app/pages/connect-page/connect.page.html index ef95472a..0a8d030c 100644 --- a/src/app/pages/connect-page/connect.page.html +++ b/src/app/pages/connect-page/connect.page.html @@ -5,7 +5,7 @@ - List Connections - Open Connection - Accept New Connection + List Connections + Open Connection + Accept New Connection diff --git a/src/app/pages/connect-page/list-connections/list-connections.page.html b/src/app/pages/connect-page/list-connections/list-connections.page.html index 3686cc46..e447e3d8 100644 --- a/src/app/pages/connect-page/list-connections/list-connections.page.html +++ b/src/app/pages/connect-page/list-connections/list-connections.page.html @@ -6,7 +6,7 @@ - +

{{connection['to']['username']}}

{{connection['message']}}

diff --git a/src/app/pages/review-attributes/_services/review-attributes.model.service.ts b/src/app/pages/review-attributes/_services/review-attributes.model.service.ts index 42b5d66e..62c52f42 100644 --- a/src/app/pages/review-attributes/_services/review-attributes.model.service.ts +++ b/src/app/pages/review-attributes/_services/review-attributes.model.service.ts @@ -28,6 +28,6 @@ export class ReviewAttributesModelService { } getNextReviewEligiblePhrase() { - return this.model["nextReviewPhrase"]; + return this.model["nextReviewPhrase"] && this.model["nextReviewPhrase"][0]; } } diff --git a/src/app/pages/review-attributes/review-attributes.page.ts b/src/app/pages/review-attributes/review-attributes.page.ts index ff52b4dd..d0b2f31f 100644 --- a/src/app/pages/review-attributes/review-attributes.page.ts +++ b/src/app/pages/review-attributes/review-attributes.page.ts @@ -19,11 +19,10 @@ export class ReviewAttributesPage implements OnInit { private _reviewAttributesModelService: ReviewAttributesModelService ) {} - ngOnInit() {} - - ionViewWillEnter() { + ngOnInit() { this._reviewAttributesModelService.init(); } + onRejectPhraseBtnClick() { //mock data const reasons = [ @@ -81,10 +80,6 @@ export class ReviewAttributesPage implements OnInit { } onGetNextPhraseBtnClick() { - this.getNextPhraseToBeReviewed(); - } - - getNextPhraseToBeReviewed() { const self = this; const phraseTBR = this._reviewAttributesModelService.getNextReviewEligiblePhrase(); @@ -120,8 +115,4 @@ export class ReviewAttributesPage implements OnInit { return rtn; } - - getListOfReviewDecisionReasons() { - return; - } }