Skip to content

Commit

Permalink
fixed feature cypress test
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed May 16, 2024
1 parent 2c42bb3 commit f423236
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
37 changes: 19 additions & 18 deletions cypress/e2e/03_features.cy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { User, HostName, Workspaces, Repositories, Features } from '../support/objects/objects';
import { User, HostName, Features } from '../support/objects/objects';



describe('Create Features for Workspace', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 2; i++) {
for (let i = 0; i <= 2; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features`,
Expand All @@ -25,7 +25,7 @@ describe('Create Features for Workspace', () => {
describe('Modify name for Feature', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 2; i++) {
for (let i = 0; i <= 2; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features`,
Expand All @@ -48,7 +48,7 @@ describe('Modify name for Feature', () => {
describe('Modify brief for Feature', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 2; i++) {
for (let i = 0; i <= 2; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features`,
Expand All @@ -71,7 +71,7 @@ describe('Modify brief for Feature', () => {
describe('Modify requirements for Feature', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 2; i++) {
for (let i = 0; i <= 2; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features`,
Expand All @@ -94,7 +94,7 @@ describe('Modify requirements for Feature', () => {
describe('Modify architecture for Feature', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 2; i++) {
for (let i = 0; i <= 2; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features`,
Expand All @@ -121,30 +121,31 @@ describe('Get Features for Workspace', () => {
cy.request({
method: 'GET',
url: `${HostName}/features/forworkspace/` + Features[0].workspace_uuid,
headers: { 'x-jwt': `${ value }` },
body: {}
headers: { 'x-jwt': `${value}` },
body: {}
}).then((resp) => {
expect(resp.status).to.eq(200)
for(let i = 0; i <= 2; i++) {
expect(resp.body[i]).to.have.property('name', Features[i].name.trim() + " _addtext")
expect(resp.body[i]).to.have.property('brief', Features[i].brief.trim() + " _addtext")
expect(resp.body[i]).to.have.property('requirements', Features[i].requirements.trim() + " _addtext")
expect(resp.body[i]).to.have.property('architecture', Features[i].architecture.trim() + " _addtext")
expect(resp.status).to.eq(200);
const body = resp.body.reverse();
for (let i = 0; i <= 2; i++) {
expect(body[i]).to.have.property('name', Features[i].name.trim() + " _addtext")
expect(body[i]).to.have.property('brief', Features[i].brief.trim() + " _addtext")
expect(body[i]).to.have.property('requirements', Features[i].requirements.trim() + " _addtext")
expect(body[i]).to.have.property('architecture', Features[i].architecture.trim() + " _addtext")
}
})
});
})
})
})

describe('Get Feature by uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 2; i++) {
for (let i = 0; i <= 2; i++) {
cy.request({
method: 'GET',
url: `${HostName}/features/` + Features[i].uuid,
headers: { 'x-jwt': `${ value }` },
body: {}
headers: { 'x-jwt': `${value}` },
body: {}
}).then((resp) => {
expect(resp.status).to.eq(200)
expect(resp.body).to.have.property('name', Features[i].name.trim() + " _addtext")
Expand Down
18 changes: 9 additions & 9 deletions cypress/e2e/04_user_stories.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { User, HostName, UserStories } from '../support/objects/objects';
describe('Create user stories for Feature', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 5; i++) {
for (let i = 0; i <= 5; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features/story`,
Expand All @@ -23,7 +23,7 @@ describe('Create user stories for Feature', () => {
describe('Modify user story description', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 5; i++) {
for (let i = 0; i <= 5; i++) {
cy.request({
method: 'POST',
url: `${HostName}/features/story`,
Expand All @@ -49,11 +49,11 @@ describe('Get user stories for feature', () => {
cy.request({
method: 'GET',
url: `${HostName}/features/${UserStories[0].feature_uuid}/story`,
headers: { 'x-jwt': `${ value }` },
body: {}
headers: { 'x-jwt': `${value}` },
body: {}
}).then((resp) => {
expect(resp.status).to.eq(200)
for(let i = 0; i <= 5; i++) {
for (let i = 0; i <= 5; i++) {
expect(resp.body[i]).to.have.property('uuid').and.equal(UserStories[i].uuid.trim());
expect(resp.body[i]).to.have.property('feature_uuid').and.equal(UserStories[i].feature_uuid.trim());
expect(resp.body[i]).to.have.property('description').and.equal(UserStories[i].description.trim() + " _addtext");
Expand All @@ -67,7 +67,7 @@ describe('Get user stories for feature', () => {
describe('Get story by uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 5; i++) {
for (let i = 0; i <= 5; i++) {
cy.request({
method: 'GET',
url: `${HostName}/features/${UserStories[0].feature_uuid}/story/${UserStories[i].uuid}`,
Expand All @@ -91,8 +91,8 @@ describe('Delete story by uuid', () => {
cy.request({
method: 'DELETE',
url: `${HostName}/features/${UserStories[0].feature_uuid}/story/${UserStories[0].uuid}`,
headers: { 'x-jwt': `${ value }` },
body: {}
headers: { 'x-jwt': `${value}` },
body: {}
}).then((resp) => {
expect(resp.status).to.eq(200)
})
Expand All @@ -106,7 +106,7 @@ describe('Check delete by uuid', () => {
cy.request({
method: 'DELETE',
url: `${HostName}/features/${UserStories[0].feature_uuid}/story/${UserStories[0].uuid}`,
headers: { 'x-jwt': `${ value }` },
headers: { 'x-jwt': `${value}` },
body: {},
failOnStatusCode: false
}).then((resp) => {
Expand Down
4 changes: 2 additions & 2 deletions db/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ func (db database) CreateOrEditFeature(m WorkspaceFeatures) (WorkspaceFeatures,
db.db.Create(&m)
}

db.db.Model(&WorkspaceFeatures{}).Where("uuid = ?", m.Uuid).Find(&m)

return m, nil
}

Expand All @@ -80,11 +82,9 @@ func (db database) CreateOrEditFeatureStory(story FeatureStory) (FeatureStory, e
result := db.db.Model(&FeatureStory{}).Where("uuid = ?", story.Uuid).First(&existingStory)

if result.RowsAffected == 0 {

story.Created = &now
db.db.Create(&story)
} else {

db.db.Model(&FeatureStory{}).Where("uuid = ?", story.Uuid).Updates(story)
}

Expand Down
5 changes: 3 additions & 2 deletions handlers/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package handlers
import (
"encoding/json"
"fmt"
"io"
"net/http"

"github.com/go-chi/chi"
"github.com/rs/xid"
"github.com/stakwork/sphinx-tribes/auth"
"github.com/stakwork/sphinx-tribes/db"
"io"
"net/http"
)

type featureHandler struct {
Expand Down

0 comments on commit f423236

Please sign in to comment.