Skip to content

Commit

Permalink
adding logging to debug e2e action
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-s-nava committed Feb 6, 2025
1 parent 309b04a commit c602b45
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci-frontend-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ jobs:
- name: Start API Server for e2e tests
run: |
cd ../api
make init db-seed-local populate-search-opportunities start
make setup-env-override-file
echo "LOGIN_FINAL_DESTINATION=http://localhost:3000/api/auth/callback" >> override.env
echo "ENABLE_OPPORTUNITY_ATTACHMENT_PIPELINE=false" >> override.env
cat override.env
make init db-seed-local populate-search-opportunities start
cd ../frontend
# Ensure the API wait script is executable
chmod +x ../api/bin/wait-for-api.sh
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/api/auth/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { NextRequest } from "next/server";
export async function GET(request: NextRequest) {
const token = request.nextUrl.searchParams.get("token");
if (!token) {
console.error("No token provided to auth callback", request.url);
return redirect("/unauthorized");
}
try {
Expand Down
8 changes: 7 additions & 1 deletion frontend/tests/e2e/playwrightUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ export async function waitForUrl(
page: Page,
url: string,
timeout = 30000, // query params get set after a debounce period
debug = false,
) {
const changeCheck = (pageUrl: string): boolean => {
if (debug) {
// eslint-disable-next-line
console.log(`~~ checking url for change: ${pageUrl} ~~`);
}
return pageUrl === url;
};
await waitForURLChange(page, changeCheck, timeout);
Expand Down Expand Up @@ -122,7 +127,8 @@ export const performSignIn = async (page: Page, project: FullProject) => {
await requiredInput.fill(randomUserName);
await submitButton.click();

await waitForUrl(page, "http://localhost:3000/");
await waitForUrl(page, "http://localhost:3000/", 30000, true);
// await waitForUrl(page, "http://localhost:3000");

if (project.name.match(/[Mm]obile/)) {
const userDropdown = page.locator(
Expand Down
4 changes: 3 additions & 1 deletion frontend/tests/e2e/saved-grants.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ test("redirects if not logged in", async ({ page }) => {
await expect(page).toHaveTitle("Unauthenticated | Simpler.Grants.gov");
});

test("shows save / search cta if logged in", async ({ page }, { project }) => {
test.only("shows save / search cta if logged in", async ({ page }, {
project,
}) => {
await page.goto("http://localhost:3000/?_ff=authOn:true");
await performSignIn(page, project);

Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
forbidOnly: false,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
Expand Down

0 comments on commit c602b45

Please sign in to comment.