Skip to content

Commit

Permalink
Merge branch 'develop' into trib-104
Browse files Browse the repository at this point in the history
  • Loading branch information
haxwell authored Sep 7, 2024
2 parents 18f9c84 + e30d9bb commit 6e2fa05
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 44 deletions.
32 changes: 32 additions & 0 deletions bin/savv-sh/becomes-current-environment
Original file line number Diff line number Diff line change
@@ -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
23 changes: 20 additions & 3 deletions cypress/e2e/attributes.page.cy.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
68 changes: 62 additions & 6 deletions cypress/e2e/connect.page.cy.js
Original file line number Diff line number Diff line change
@@ -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', () => {

});
})
62 changes: 45 additions & 17 deletions cypress/e2e/review-attributes.page.cy.js
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
30 changes: 29 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,32 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }

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": "[email protected]",
"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');
});

2 changes: 1 addition & 1 deletion src/app/pages/attributes-page/attributes.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[primaryActionButtonText]="headerPagePrimaryActionButtonText" [primaryActionButtonFunc]="getCreateBtnClickFunc()"></app-header>

<ion-content>
<ion-card color="warning" *ngFor="let attr of getAttributes()">
<ion-card class="attributeItem" color="warning" *ngFor="let attr of getAttributes()">
<ion-card-content>
<ion-card-title>{{attr['phrase']['adverb'] || ''}} {{attr['phrase']['verb'] || ''}} {{attr['phrase']['preposition'] || ''}} {{attr['phrase']['noun'] || ''}}
<span class="user-count">({{attr['userCount'] || '0'}} users)</span>
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/connect-page/connect.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</ion-header>

<ion-content>
<ion-button (click)="onGoToListConnectionsBtnClick()" data-test="launchListConnectionsPageButton" fill="clear">List Connections</ion-button>
<ion-button (click)="onGoToOpenConnectionBtnClick()" data-test="launchOpenConnectionPageButton" fill="clear">Open Connection</ion-button>
<ion-button (click)="onGoToOpenAcceptNewConnectionBtnClick()" data-test="acceptNewConnectionBtn" fill="clear">Accept New Connection</ion-button>
<ion-button class="listbtn" (click)="onGoToListConnectionsBtnClick()" data-test="launchListConnectionsPageButton" fill="clear">List Connections</ion-button>
<ion-button class="openbtn" (click)="onGoToOpenConnectionBtnClick()" data-test="launchOpenConnectionPageButton" fill="clear">Open Connection</ion-button>
<ion-button class="acceptbtn" (click)="onGoToOpenAcceptNewConnectionBtnClick()" data-test="acceptNewConnectionBtn" fill="clear">Accept New Connection</ion-button>
</ion-content>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ion-content>
<ion-list>
<ion-item *ngFor="let connection of getAllConnections()" routerLink="../connection-details/{{connection['to']['userId']}}">
<ion-item data-test="connectionListItem" *ngFor="let connection of getAllConnections()" routerLink="../connection-details/{{connection['to']['userId']}}">
<ion-label>
<h2>{{connection['to']['username']}}</h2>
<p>{{connection['message']}}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export class ReviewAttributesModelService {
}

getNextReviewEligiblePhrase() {
return this.model["nextReviewPhrase"];
return this.model["nextReviewPhrase"] && this.model["nextReviewPhrase"][0];
}
}
13 changes: 2 additions & 11 deletions src/app/pages/review-attributes/review-attributes.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ export class ReviewAttributesPage implements OnInit {
private _reviewAttributesModelService: ReviewAttributesModelService
) {}

ngOnInit() {}

ionViewWillEnter() {
ngOnInit() {
this._reviewAttributesModelService.init();
}

onRejectPhraseBtnClick() {
//mock data
const reasons = [
Expand Down Expand Up @@ -81,10 +80,6 @@ export class ReviewAttributesPage implements OnInit {
}

onGetNextPhraseBtnClick() {
this.getNextPhraseToBeReviewed();
}

getNextPhraseToBeReviewed() {
const self = this;
const phraseTBR =
this._reviewAttributesModelService.getNextReviewEligiblePhrase();
Expand Down Expand Up @@ -120,8 +115,4 @@ export class ReviewAttributesPage implements OnInit {

return rtn;
}

getListOfReviewDecisionReasons() {
return;
}
}

0 comments on commit 6e2fa05

Please sign in to comment.