Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella committed Jan 20, 2025
1 parent b6a0e5e commit 1b9d7d9
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 42 deletions.
14 changes: 5 additions & 9 deletions apps/web/public/locales/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,14 @@
"profileEmailAddress": "Email Address",
"profileEmailAddressDescription": "Your email address is used to log in to your account",
"emailAlreadyInUse": "This email address is already associated with another account. Please use a different email address.",
"terms": "Terms",
"privacyPolicy": "Privacy Policy",
"continueWith": "Continue with {provider}",
"continueWithProvider": "Continue with {{provider}}",
"loginFooter": "Don't have an account? <a>Sign up</a>",
"finishLoggingIn": "Finish logging in",
"enterCode": "Check your email for the verification code.",
"back": "Back",
"verifyEmail": "Verify your email",
"finishSigningUp": "Finish Signing Up",
"enterCodeInstruction": "Check and enter the code we sent you.",
"verificationCode": "Code",
"alreadyHaveAccount": "Already have an account? <a>Log in</a>",
"loginDescription": "Login to your account to continue",
"userDoesNotExist": "A user with this email does not exist",
"userNotFound": "A user with that email doesn't exist",
"loginTitle": "Welcome",
"registerTitle": "Create Your Account",
"registerDescription": "Streamline your scheduling process and save time",
Expand All @@ -310,5 +303,8 @@
"quickCreateGetNotifications": "Get email notifications notifications",
"quickCreateManagePollsFromAnyDevice": "Manage your polls from any device",
"registerVerifyTitle": "Finish Registering",
"registerVerifyDescription": "Check your email for the verification code"
"registerVerifyDescription": "Check your email for the verification code",
"loginVerifyTitle": "Finish Logging In",
"loginVerifyDescription": "Check your email for the verification code",
"createAccount": "Create Account"
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const LoginPage = ({ magicLink, email }: PageProps) => {
variant="primary"
className="w-full"
>
<Trans i18nKey="continue" />
<Trans i18nKey="login" defaults="Login" />
</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export function LoginWithEmailForm() {
);
} else {
form.setError("identifier", {
message: t("userDoesNotExist", {
defaultValue: "A user with this email does not exist",
message: t("userNotFound", {
defaultValue: "A user with that email doesn't exist",
}),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Button } from "@rallly/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormMessage,
Expand Down Expand Up @@ -77,6 +78,9 @@ export function OTPForm({ email }: { email: string }) {
{...field}
/>
</FormControl>
<FormDescription>
<Trans i18nKey="verificationCodeHelp" />
</FormDescription>
<FormMessage />
</FormItem>
);
Expand All @@ -91,7 +95,7 @@ export function OTPForm({ email }: { email: string }) {
form.formState.isSubmitting || form.formState.isSubmitSuccessful
}
>
<Trans i18nKey="continue" defaults="Continue" />
<Trans i18nKey="login" defaults="Login" />
</Button>
</form>
</Form>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/app/[locale]/(auth)/login/verify/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ export default async function VerifyPage() {
<Trans
t={t}
ns="app"
i18nKey="finishLoggingIn"
defaults="Finish logging in"
i18nKey="loginVerifyTitle"
defaults="Finish Logging In"
/>
</AuthPageTitle>
<AuthPageDescription>
<Trans
t={t}
ns="app"
i18nKey="enterCode"
defaults="Check your email for the verification code."
i18nKey="loginVerifyDescription"
defaults="Check your email for the verification code"
/>
</AuthPageDescription>
</AuthPageHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function OTPForm({ token }: { token: string }) {
size="lg"
disabled={form.formState.isSubmitting}
>
<Trans i18nKey="continue" defaults="Continue" />
<Trans i18nKey="createAccount" defaults="Create Account" />
</Button>
</form>
</Form>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/features/quick-create/quick-create-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export async function QuickStartWidget() {
</Button>
</div>
</div>
<div className="space-y-6">
<div className="space-y-4">
<div className="flex items-center gap-2">
<h3 className="font-medium">
<h3 className="font-semibold">
<Trans
t={t}
ns="app"
Expand Down
60 changes: 38 additions & 22 deletions apps/web/tests/authentication.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,31 @@ test.describe.serial(() => {
});

test.describe("new user", () => {
test("user registration", async ({ page }) => {
test("shows that user doesn't exist yet", async ({ page }) => {
await page.goto("/login");

await page.getByText("Login or sign up in seconds").waitFor();

// your login page test logic
await page
.getByPlaceholder("[email protected]")
.fill(testUserEmail);

await page
.getByRole("button", { name: "Continue with Email", exact: true })
.click();
await page.getByRole("button", { name: "Continue with Email" }).click();

// Make sure the user doesn't exist yet and that logging in is not possible
await expect(
page.getByText("A user with that email doesn't exist"),
).toBeVisible();
});

test("user registration", async ({ page }) => {
await page.goto("/register");

await page.getByText("Create your account").waitFor();
await page.getByText("Create Your Account").waitFor();

await page.getByPlaceholder("Jessie Smith").fill("Test User");
await page
.getByPlaceholder("[email protected]")
.fill(testUserEmail);

await page.getByRole("button", { name: "Continue", exact: true }).click();

Expand All @@ -57,12 +66,29 @@ test.describe.serial(() => {

await codeInput.fill(code);

await page.waitForURL("/");
await expect(page.getByText("Test User")).toBeVisible();
});
});

test.describe("existing user", () => {
test("can login with magic link", async ({ browser, page }) => {
test("can't register with the same email", async ({ page }) => {
await page.goto("/register");

await page.getByText("Create Your Account").waitFor();

await page.getByPlaceholder("Jessie Smith").fill("Test User");
await page
.getByPlaceholder("[email protected]")
.fill(testUserEmail);

await page.getByRole("button", { name: "Continue", exact: true }).click();

await expect(
page.getByText("A user with that email already exists"),
).toBeVisible();
});

test("can login with magic link", async ({ page }) => {
await page.goto("/login");

await page
Expand All @@ -81,17 +107,11 @@ test.describe.serial(() => {
throw new Error("Magic link not found");
}

const newPage = await browser.newPage();

await newPage.goto(magicLink);

await newPage
.getByRole("button", { name: "Continue", exact: true })
.click();
await page.goto(magicLink);

await newPage.waitForURL("/");
await page.getByRole("button", { name: "Login", exact: true }).click();

await expect(newPage.getByText("Test User")).toBeVisible();
await expect(page.getByText("Test User")).toBeVisible();
});

test("can login with verification code", async ({ page }) => {
Expand All @@ -107,8 +127,6 @@ test.describe.serial(() => {

await page.getByPlaceholder("Enter your 6-digit code").fill(code);

await page.waitForURL("/");

await expect(page.getByText("Test User")).toBeVisible();
});

Expand All @@ -125,8 +143,6 @@ test.describe.serial(() => {

await page.getByPlaceholder("Enter your 6-digit code").fill(code);

await page.waitForURL("/");

await expect(page.getByText("Test User")).toBeVisible();
});
});
Expand Down

0 comments on commit 1b9d7d9

Please sign in to comment.