Skip to content

Commit

Permalink
Add routing headless test
Browse files Browse the repository at this point in the history
  • Loading branch information
infomiho committed Aug 27, 2024
1 parent 6ac1c85 commit 5ef793d
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 15 deletions.
15 changes: 9 additions & 6 deletions waspc/data/Generator/templates/react-app/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const routeNameToRouteComponent = {
} as const;

export function RouterRoutes() {
const waspDefinedRoutes = [
{=# isExternalAuthEnabled =}
{
path: "{= oAuthCallbackPath =}",
element: <OAuthCallbackPage />
},
{=/ isExternalAuthEnabled =}
]
const userDefinedRoutes = Object.entries(routes).map(([routeKey, route]) => {
const Component = routeNameToRouteComponent[routeKey]
return {
Expand All @@ -34,17 +42,12 @@ export function RouterRoutes() {
}
})
const routerRoutes = useRoutes([
{=# isExternalAuthEnabled =}
/*
Wasp specific routes *must* go first to prevent user
defined routes from overriding them.
Details in https://github.com/wasp-lang/wasp/issues/2029
*/
{
path: "{= oAuthCallbackPath =}",
element: <OAuthCallbackPage />
},
{=/ isExternalAuthEnabled =}
...waspDefinedRoutes,
...userDefinedRoutes,
])

Expand Down

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

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

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

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

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

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

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

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

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

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

6 changes: 6 additions & 0 deletions waspc/headless-test/tests/simple.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test.describe("signup and login", () => {

await page.goto("/");

// Create a new task
const randomTask = `New Task ${Math.random().toString(36).substring(7)}`;
await page.locator("input[type='text']").fill(randomTask);
await page.getByText("Create new task").click();
Expand All @@ -61,5 +62,10 @@ test.describe("signup and login", () => {
await page.waitForSelector(`text=${fullTaskText}`);

await expect(page.locator("body")).toContainText(fullTaskText);

// Navigate to task page
await page.locator(`text=${fullTaskText}`).click();
const taskPageText = `description: ${randomTask}`;
await page.waitForSelector(`text=${taskPageText}`);
});
});

0 comments on commit 5ef793d

Please sign in to comment.