Skip to content

Commit

Permalink
Add sypress test to contact component
Browse files Browse the repository at this point in the history
  • Loading branch information
Sulton88Mehron90 committed Oct 21, 2023
1 parent 8c5c943 commit a47a858
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 31 deletions.
39 changes: 39 additions & 0 deletions cypress/e2e/contactSection.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
describe('ContactSection Component - Happy Path', () => {

beforeEach(() => {
cy.visit('http://localhost:3000/');
});

it('should display the main elements of the homepage', () => {
cy.get('.home-header').should('be.visible');
cy.get('.nav-bar').should('be.visible');
cy.get('[href="/contact"]').should('contain', 'helpful resources');
cy.get('[href="/contact"]').click();
});

it('should render the component correctly', () => {
cy.visit('http://localhost:3000/contact');

cy.location('pathname').should('eq', '/contact');
cy.viewport(1280, 720);
cy.get('.weallhuman-img').should('be.visible');
});

it('should navigate to the contact page from the homepage', () => {
cy.visit('http://localhost:3000');
cy.get('.nav-bar').should('be.visible');
cy.get('[href="/contact"]').click();
cy.url().should('include', '/contact');
});
});

describe('ContactSection Component - Sad Path', () => {

it('should handle missing image gracefully', () => {
cy.intercept('GET', '**/usa-custom.jpeg', { statusCode: 404 });
cy.visit('http://localhost:3000/contact');
cy.reload();
cy.viewport(1280, 720);
cy.get('img[alt="usa-custom"]').should('be.visible');
});
});
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"cypress": "^13.3.1"
"cypress": "^13.3.2"
}
}
2 changes: 1 addition & 1 deletion src/Components/Contact/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ContactSection = () => {
<div className="top-section">
<div className="left-side">
<div className="weallhuman-container">
<img src={weAllHuman} alt="Refugees" className="wehalluman-img" />
<img src={weAllHuman} alt="usa-custom" className="weallhuman-img" />
</div>
</div>
<div className="right-side">
Expand Down
46 changes: 24 additions & 22 deletions src/Components/Homepage/Homepage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ $netflix-red: #E50914;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
justify-content: flex-start;
}

.content-section {
padding-top: 30px;
padding-top: 30px;
display: flex;
align-items: flex-start;
justify-content: space-between;
Expand All @@ -44,23 +44,23 @@ $netflix-red: #E50914;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
flex-direction: column;

button.play-video,
button.play-video,
button.hide-video {
margin-top: 15px;
}
margin-top: 15px;
}

.media-content {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

.video-controls {
margin-top: 20px;
text-align: center;
text-align: center;
}

.refugee-image-container {
Expand All @@ -72,16 +72,16 @@ $netflix-red: #E50914;
overflow: hidden;
position: relative;
}

.refugees-img {
margin-top: 30px;
top: 0;
left: 0;
right: 0;
bottom: 0;
max-width: 100%;
max-width: 100%;
height: auto;
margin: auto;
margin: auto;
display: block;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.1);
border-radius: 8px;
Expand All @@ -95,22 +95,22 @@ $netflix-red: #E50914;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
align-items: center;
padding: 40px;

.title-container {
margin-bottom: 20px;
background: linear-gradient(135deg, #e9f5fc, #fff);
padding: 10px 20px;
border-radius: 8px;
border-radius: 10px;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.05);

h2 {
color: $primary-color;
letter-spacing: 1px;
text-transform: uppercase;
text-align: center;
font-weight: 600;
font-weight: 600;
font-size: 2.2rem;
line-height: 1.3;
}
Expand All @@ -121,16 +121,18 @@ $netflix-red: #E50914;
line-height: 1.6;
color: rgba(0, 0, 0, 0.7);
text-align: justify;
max-width: 80%;
font-size: 1.1rem;
color: #555;
max-width: 85%;
margin-bottom: 10px;
font-weight: 400;
}
}

.play-video, .hide-video {
.play-video,
.hide-video {
margin-top: 15px;
background-color: $netflix-red;
// background-color: #37b3fe;
border-radius: 30px;
color: #FFFFFF;
border: none;
Expand All @@ -154,9 +156,9 @@ $netflix-red: #E50914;
position: relative;
width: 100%;
padding-bottom: 56.25%;
border-radius: 15px;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

iframe {
Expand All @@ -172,9 +174,9 @@ iframe {
.content-section {
flex-direction: column;

.media-side, .text-side {
.media-side,
.text-side {
width: 100%;
}
}
}

}
File renamed without changes

0 comments on commit a47a858

Please sign in to comment.