Revert "Upgrade linter and formatter to Ultracite" (#1226)
This commit is contained in:
parent
0e320b391d
commit
1aff7d9868
177 changed files with 8334 additions and 6943 deletions
|
|
@ -1,23 +1,23 @@
|
|||
import { getMessageByErrorCode } from "@/lib/errors";
|
||||
import { expect, test } from "../fixtures";
|
||||
import { generateRandomTestUser } from "../helpers";
|
||||
import { AuthPage } from "../pages/auth";
|
||||
import { ChatPage } from "../pages/chat";
|
||||
import { expect, test } from '../fixtures';
|
||||
import { AuthPage } from '../pages/auth';
|
||||
import { generateRandomTestUser } from '../helpers';
|
||||
import { ChatPage } from '../pages/chat';
|
||||
import { getMessageByErrorCode } from '@/lib/errors';
|
||||
|
||||
test.describe
|
||||
.serial("Guest Session", () => {
|
||||
test("Authenticate as guest user when a new session is loaded", async ({
|
||||
.serial('Guest Session', () => {
|
||||
test('Authenticate as guest user when a new session is loaded', async ({
|
||||
page,
|
||||
}) => {
|
||||
const response = await page.goto("/");
|
||||
const response = await page.goto('/');
|
||||
|
||||
if (!response) {
|
||||
throw new Error("Failed to load page");
|
||||
throw new Error('Failed to load page');
|
||||
}
|
||||
|
||||
let request = response.request();
|
||||
|
||||
const chain: string[] = [];
|
||||
const chain = [];
|
||||
|
||||
while (request) {
|
||||
chain.unshift(request.url());
|
||||
|
|
@ -25,185 +25,185 @@ test.describe
|
|||
}
|
||||
|
||||
expect(chain).toEqual([
|
||||
"http://localhost:3000/",
|
||||
"http://localhost:3000/api/auth/guest?redirectUrl=http%3A%2F%2Flocalhost%3A3000%2F",
|
||||
"http://localhost:3000/",
|
||||
'http://localhost:3000/',
|
||||
'http://localhost:3000/api/auth/guest?redirectUrl=http%3A%2F%2Flocalhost%3A3000%2F',
|
||||
'http://localhost:3000/',
|
||||
]);
|
||||
});
|
||||
|
||||
test("Log out is not available for guest users", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
test('Log out is not available for guest users', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
const sidebarToggleButton = page.getByTestId("sidebar-toggle-button");
|
||||
const sidebarToggleButton = page.getByTestId('sidebar-toggle-button');
|
||||
await sidebarToggleButton.click();
|
||||
|
||||
const userNavButton = page.getByTestId("user-nav-button");
|
||||
const userNavButton = page.getByTestId('user-nav-button');
|
||||
await expect(userNavButton).toBeVisible();
|
||||
|
||||
await userNavButton.click();
|
||||
const userNavMenu = page.getByTestId("user-nav-menu");
|
||||
const userNavMenu = page.getByTestId('user-nav-menu');
|
||||
await expect(userNavMenu).toBeVisible();
|
||||
|
||||
const authMenuItem = page.getByTestId("user-nav-item-auth");
|
||||
await expect(authMenuItem).toContainText("Login to your account");
|
||||
const authMenuItem = page.getByTestId('user-nav-item-auth');
|
||||
await expect(authMenuItem).toContainText('Login to your account');
|
||||
});
|
||||
|
||||
test("Do not authenticate as guest user when an existing non-guest session is active", async ({
|
||||
test('Do not authenticate as guest user when an existing non-guest session is active', async ({
|
||||
adaContext,
|
||||
}) => {
|
||||
const response = await adaContext.page.goto("/");
|
||||
const response = await adaContext.page.goto('/');
|
||||
|
||||
if (!response) {
|
||||
throw new Error("Failed to load page");
|
||||
throw new Error('Failed to load page');
|
||||
}
|
||||
|
||||
let request = response.request();
|
||||
|
||||
const chain: string[] = [];
|
||||
const chain = [];
|
||||
|
||||
while (request) {
|
||||
chain.unshift(request.url());
|
||||
request = request.redirectedFrom();
|
||||
}
|
||||
|
||||
expect(chain).toEqual(["http://localhost:3000/"]);
|
||||
expect(chain).toEqual(['http://localhost:3000/']);
|
||||
});
|
||||
|
||||
test("Allow navigating to /login as guest user", async ({ page }) => {
|
||||
await page.goto("/login");
|
||||
await page.waitForURL("/login");
|
||||
await expect(page).toHaveURL("/login");
|
||||
test('Allow navigating to /login as guest user', async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
await page.waitForURL('/login');
|
||||
await expect(page).toHaveURL('/login');
|
||||
});
|
||||
|
||||
test("Allow navigating to /register as guest user", async ({ page }) => {
|
||||
await page.goto("/register");
|
||||
await page.waitForURL("/register");
|
||||
await expect(page).toHaveURL("/register");
|
||||
test('Allow navigating to /register as guest user', async ({ page }) => {
|
||||
await page.goto('/register');
|
||||
await page.waitForURL('/register');
|
||||
await expect(page).toHaveURL('/register');
|
||||
});
|
||||
|
||||
test("Do not show email in user menu for guest user", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
test('Do not show email in user menu for guest user', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
|
||||
const sidebarToggleButton = page.getByTestId("sidebar-toggle-button");
|
||||
const sidebarToggleButton = page.getByTestId('sidebar-toggle-button');
|
||||
await sidebarToggleButton.click();
|
||||
|
||||
const userEmail = page.getByTestId("user-email");
|
||||
await expect(userEmail).toContainText("Guest");
|
||||
const userEmail = page.getByTestId('user-email');
|
||||
await expect(userEmail).toContainText('Guest');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe
|
||||
.serial("Login and Registration", () => {
|
||||
.serial('Login and Registration', () => {
|
||||
let authPage: AuthPage;
|
||||
|
||||
const testUser = generateRandomTestUser();
|
||||
|
||||
test.beforeEach(({ page }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
authPage = new AuthPage(page);
|
||||
});
|
||||
|
||||
test("Register new account", async () => {
|
||||
test('Register new account', async () => {
|
||||
await authPage.register(testUser.email, testUser.password);
|
||||
await authPage.expectToastToContain("Account created successfully!");
|
||||
await authPage.expectToastToContain('Account created successfully!');
|
||||
});
|
||||
|
||||
test("Register new account with existing email", async () => {
|
||||
test('Register new account with existing email', async () => {
|
||||
await authPage.register(testUser.email, testUser.password);
|
||||
await authPage.expectToastToContain("Account already exists!");
|
||||
await authPage.expectToastToContain('Account already exists!');
|
||||
});
|
||||
|
||||
test("Log into account that exists", async ({ page }) => {
|
||||
test('Log into account that exists', async ({ page }) => {
|
||||
await authPage.login(testUser.email, testUser.password);
|
||||
|
||||
await page.waitForURL("/");
|
||||
await expect(page.getByPlaceholder("Send a message...")).toBeVisible();
|
||||
await page.waitForURL('/');
|
||||
await expect(page.getByPlaceholder('Send a message...')).toBeVisible();
|
||||
});
|
||||
|
||||
test("Display user email in user menu", async ({ page }) => {
|
||||
test('Display user email in user menu', async ({ page }) => {
|
||||
await authPage.login(testUser.email, testUser.password);
|
||||
|
||||
await page.waitForURL("/");
|
||||
await expect(page.getByPlaceholder("Send a message...")).toBeVisible();
|
||||
await page.waitForURL('/');
|
||||
await expect(page.getByPlaceholder('Send a message...')).toBeVisible();
|
||||
|
||||
const userEmail = await page.getByTestId("user-email");
|
||||
const userEmail = await page.getByTestId('user-email');
|
||||
await expect(userEmail).toHaveText(testUser.email);
|
||||
});
|
||||
|
||||
test("Log out as non-guest user", async () => {
|
||||
test('Log out as non-guest user', async () => {
|
||||
await authPage.logout(testUser.email, testUser.password);
|
||||
});
|
||||
|
||||
test("Do not force create a guest session if non-guest session already exists", async ({
|
||||
test('Do not force create a guest session if non-guest session already exists', async ({
|
||||
page,
|
||||
}) => {
|
||||
await authPage.login(testUser.email, testUser.password);
|
||||
await page.waitForURL("/");
|
||||
await page.waitForURL('/');
|
||||
|
||||
const userEmail = await page.getByTestId("user-email");
|
||||
const userEmail = await page.getByTestId('user-email');
|
||||
await expect(userEmail).toHaveText(testUser.email);
|
||||
|
||||
await page.goto("/api/auth/guest");
|
||||
await page.waitForURL("/");
|
||||
await page.goto('/api/auth/guest');
|
||||
await page.waitForURL('/');
|
||||
|
||||
const updatedUserEmail = await page.getByTestId("user-email");
|
||||
const updatedUserEmail = await page.getByTestId('user-email');
|
||||
await expect(updatedUserEmail).toHaveText(testUser.email);
|
||||
});
|
||||
|
||||
test("Log out is available for non-guest users", async ({ page }) => {
|
||||
test('Log out is available for non-guest users', async ({ page }) => {
|
||||
await authPage.login(testUser.email, testUser.password);
|
||||
await page.waitForURL("/");
|
||||
await page.waitForURL('/');
|
||||
|
||||
authPage.openSidebar();
|
||||
|
||||
const userNavButton = page.getByTestId("user-nav-button");
|
||||
const userNavButton = page.getByTestId('user-nav-button');
|
||||
await expect(userNavButton).toBeVisible();
|
||||
|
||||
await userNavButton.click();
|
||||
const userNavMenu = page.getByTestId("user-nav-menu");
|
||||
const userNavMenu = page.getByTestId('user-nav-menu');
|
||||
await expect(userNavMenu).toBeVisible();
|
||||
|
||||
const authMenuItem = page.getByTestId("user-nav-item-auth");
|
||||
await expect(authMenuItem).toContainText("Sign out");
|
||||
const authMenuItem = page.getByTestId('user-nav-item-auth');
|
||||
await expect(authMenuItem).toContainText('Sign out');
|
||||
});
|
||||
|
||||
test("Do not navigate to /register for non-guest users", async ({
|
||||
test('Do not navigate to /register for non-guest users', async ({
|
||||
page,
|
||||
}) => {
|
||||
await authPage.login(testUser.email, testUser.password);
|
||||
await page.waitForURL("/");
|
||||
await page.waitForURL('/');
|
||||
|
||||
await page.goto("/register");
|
||||
await expect(page).toHaveURL("/");
|
||||
await page.goto('/register');
|
||||
await expect(page).toHaveURL('/');
|
||||
});
|
||||
|
||||
test("Do not navigate to /login for non-guest users", async ({ page }) => {
|
||||
test('Do not navigate to /login for non-guest users', async ({ page }) => {
|
||||
await authPage.login(testUser.email, testUser.password);
|
||||
await page.waitForURL("/");
|
||||
await page.waitForURL('/');
|
||||
|
||||
await page.goto("/login");
|
||||
await expect(page).toHaveURL("/");
|
||||
await page.goto('/login');
|
||||
await expect(page).toHaveURL('/');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Entitlements", () => {
|
||||
test.describe('Entitlements', () => {
|
||||
let chatPage: ChatPage;
|
||||
|
||||
test.beforeEach(({ page }) => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
chatPage = new ChatPage(page);
|
||||
});
|
||||
|
||||
test("Guest user cannot send more than 20 messages/day", async () => {
|
||||
test('Guest user cannot send more than 20 messages/day', async () => {
|
||||
test.fixme();
|
||||
await chatPage.createNewChat();
|
||||
|
||||
for (let i = 0; i <= 20; i++) {
|
||||
await chatPage.sendUserMessage("Why is the sky blue?");
|
||||
await chatPage.sendUserMessage('Why is the sky blue?');
|
||||
await chatPage.isGenerationComplete();
|
||||
}
|
||||
|
||||
await chatPage.sendUserMessage("Why is the sky blue?");
|
||||
await chatPage.sendUserMessage('Why is the sky blue?');
|
||||
await chatPage.expectToastToContain(
|
||||
getMessageByErrorCode("rate_limit:chat")
|
||||
getMessageByErrorCode('rate_limit:chat'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue