-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
2,057 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
BLUE='\033[0;34m' | ||
NONE='\033[0m' | ||
|
||
cleanup() { | ||
echo -e "${BLUE}=== Application logs ===${NONE}" | ||
docker logs oss-contribute | ||
echo -e "${BLUE}=== Application logs ===${NONE}" | ||
docker compose down | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
health_check() { | ||
echo "Waiting for app to be ready..." | ||
|
||
start_time=$(date +%s) | ||
|
||
until curl -fsL "http://localhost:8080" > /dev/null; do | ||
sleep 2 | ||
current_time=$(date +%s) | ||
elapsed_time=$((current_time - start_time)) | ||
if [ $elapsed_time -ge 10 ]; then | ||
echo "Error: Timed out waiting for app to become healthy." | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "app is ready!" | ||
} | ||
|
||
npm --prefix ui ci | ||
npm --prefix ui run build | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/api | ||
|
||
docker compose up -d --build | ||
health_check | ||
npm --prefix ui run test:e2e |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from "cypress"; | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: "http://localhost:8080/", | ||
supportFile: false, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
describe("Check Page Title", () => { | ||
it("has title", () => { | ||
cy.visit("/"); | ||
cy.title().should("eq", "Explore Top Open Source Projects"); | ||
}); | ||
}); | ||
|
||
describe("GitHub Documentation Link", () => { | ||
it("should open the correct GitHub documentation link", () => { | ||
cy.visit("/"); | ||
cy.contains("Learn more in the GitHub documentation").invoke("removeAttr", "target").click(); | ||
// https://docs.cypress.io/app/guides/cross-origin-testing#External-Navigation | ||
cy.origin("https://docs.github.com", () => { | ||
cy.url().should( | ||
"eq", | ||
"https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/filtering-and-searching-issues-and-pull-requests#filtering-issues-and-pull-requests-by-labels" | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Navbar Link", () => { | ||
it("clicking 'osscontribute.com' in navbar takes user to top of the page", () => { | ||
cy.visit("/"); | ||
cy.scrollTo(0, 500); | ||
cy.contains("osscontribute.com").click(); | ||
cy.window().should("have.property", "scrollY", 0); | ||
}); | ||
}); | ||
|
||
describe("Filter Dropdown", () => { | ||
it("clicking each language in the filter dropdown shows at least 1 card", () => { | ||
cy.visit("/"); | ||
cy.get("#language-select").click(); | ||
cy.get('li[role="option"]').each(($language) => { | ||
cy.get("#language-select").click({ force: true }); | ||
cy.wrap($language).click(); | ||
cy.get("a.MuiCard-root").should("have.length.greaterThan", 0); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Pagination", () => { | ||
beforeEach(() => { | ||
cy.visit("/"); | ||
}); | ||
|
||
it("should navigate to the next page and show different content", () => { | ||
cy.get("a.MuiCard-root").should("have.length", 20); | ||
cy.get('button[aria-label="Go to next page"]').click(); | ||
cy.get("a.MuiCard-root").should("have.length", 20); | ||
}); | ||
|
||
it("should navigate to a specific page and show correct content", () => { | ||
cy.get('button[aria-label="Go to page 2"]').click(); | ||
cy.get("a.MuiCard-root").should("have.length", 20); | ||
}); | ||
|
||
it("should show the correct number of cards when filtering", () => { | ||
cy.get("#language-select").click({ force: true }); | ||
cy.get('li[role="option"]').contains("TypeScript").click(); | ||
cy.get("a.MuiCard-root").should("have.length.greaterThan", 0); | ||
|
||
// ensure pagination still works after filtering | ||
cy.get('button[aria-label="Go to next page"]').click(); | ||
cy.get("a.MuiCard-root").should("have.length.greaterThan", 0); | ||
}); | ||
}); |
Oops, something went wrong.