Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
762 changes: 377 additions & 385 deletions e2e/fixtures/connectionsTestCases.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions e2e/pages/orgConnections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class OrgConnectionsPage {
async goto() {
await this.page.goto("/");
await waitForLoadingOverlayGone(this.page);
await this.page.goto("/connections");
await this.page.getByRole("link", { name: "Connections" }).click();
await waitForLoadingOverlayGone(this.page);
await expect(this.page.getByRole("heading", { name: /Org Connections \(\d+\)/ })).toBeVisible();
}
Expand All @@ -27,17 +27,18 @@ export class OrgConnectionsPage {
await this.page.waitForURL("/connections/new");
}

async fillTwilioAccountSidAndAuthToken() {
async fillTwilioAccountSidAndApiTokenAndApiSecret() {
await this.page.getByRole("textbox", { name: "Account SID" }).fill("AC1234567890");
await this.page.getByRole("textbox", { name: "Auth Token" }).fill("1234567890");
await this.page.getByRole("textbox", { name: "API Token" }).fill("1234567890");
await this.page.getByRole("textbox", { name: "API Secret" }).fill("1234567899");
}

async createTwilioConnection(connectionName: string): Promise<string> {
await this.clickAddConnection();
await this.connectionsConfig.fillConnectionName(connectionName);
await this.connectionsConfig.selectIntegration(testIntegrationName);
await this.connectionsConfig.selectConnectionType("Auth Token");
await this.fillTwilioAccountSidAndAuthToken();
await this.connectionsConfig.selectConnectionType("API Token");
await this.fillTwilioAccountSidAndApiTokenAndApiSecret();

await this.connectionsConfig.clickSaveConnection();
await this.page.waitForURL(/\/connections\/.*\/edit/);
Expand Down
28 changes: 21 additions & 7 deletions e2e/pages/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ export class ProjectPage {
this.page = page;
}

async deleteProject(projectName: string, withActiveDeployment: boolean = false) {
if (!projectName?.trim()?.length) {
async deleteProject(incomingProjectName: string, withActiveDeployment: boolean = false) {
if (!incomingProjectName?.trim()?.length) {
throw new Error("Project name is required to delete a project");
}

if ((await this.page.getByRole("button", { name: "Edit project title" }).textContent()) !== projectName) {
throw new Error("Project name is not the same as the one in the page");
const currentPageProjectName = await this.page.getByTestId("project-name").textContent();

if (currentPageProjectName !== incomingProjectName) {
// eslint-disable-next-line no-console
console.error(
"Project name is not the same as the one in the page",
incomingProjectName,
currentPageProjectName
);
throw new Error(
`Project name is not the same as the one in the page: ${incomingProjectName} !== ${currentPageProjectName}`
);
}

const additionalActionsButton = this.page.locator('button[aria-label="Project additional actions"]');
Expand All @@ -39,20 +49,24 @@ export class ProjectPage {
this.page.waitForURL("/", { waitUntil: "domcontentloaded" }),
]);
} catch {
throw new Error('Neither "/welcome" nor "/" URL was reached after project deletion');
// eslint-disable-next-line no-console
console.error(`Neither "/welcome" nor "/" URL was reached after project deletion: ${incomingProjectName}`);
throw new Error(
`Neither "/welcome" nor "/" URL was reached after project deletion: ${incomingProjectName}`
);
}

const loaders = this.page.locator(".loader-cycle-disks").all();
const loadersArray = await loaders;
await Promise.all(loadersArray.map((loader) => loader.waitFor({ state: "detached" })));

const deletedProjectNameCell = this.page.getByRole("cell", { name: projectName });
const deletedProjectNameCell = this.page.getByRole("cell", { name: incomingProjectName });

await expect(deletedProjectNameCell).toHaveCount(0);

await this.page.locator('button[aria-label="System Log"]').click();

const deletedProjectLogText = `Project deletion completed successfully, project name: ${projectName}`;
const deletedProjectLogText = `Project deletion completed successfully, project name: ${incomingProjectName}`;

const deletedProjectLog = this.page.getByText(deletedProjectLogText);
await expect(deletedProjectLog).toBeVisible();
Expand Down
2 changes: 1 addition & 1 deletion e2e/project/connections/orgConnections.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test.describe("Org Connections Suite", () => {
await orgConnectionsPage.goto();
await orgConnectionsPage.clickAddConnection();
await connectionsConfig.selectIntegration(testIntegrationName);
await orgConnectionsPage.fillTwilioAccountSidAndAuthToken();
await orgConnectionsPage.fillTwilioAccountSidAndApiTokenAndApiSecret();
await page.getByRole("button", { name: "Save Connection" }).click();

const nameError = page.getByText("Name is required");
Expand Down
5 changes: 1 addition & 4 deletions scripts/generateConnectionTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ const microsoftTeamsIntegrationAuthMethods: SelectOption[] = [
{ label: "Private daemon application", value: ConnectionAuthType.DaemonApp },
];

const selectIntegrationTwilio: SelectOption[] = [
{ label: "Auth Token", value: ConnectionAuthType.AuthToken },
{ label: "API Key", value: ConnectionAuthType.ApiKey },
];
const selectIntegrationTwilio: SelectOption[] = [{ label: "API Token", value: ConnectionAuthType.ApiToken }];

const selectIntegrationJira: SelectOption[] = [
{ label: "OAuth 2.0 App", value: ConnectionAuthType.Oauth },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { formsPerIntegrationsMapping } from "@src/constants/connections/formsPer
import { Integrations } from "@src/enums/components";
import { useConnectionForm } from "@src/hooks";
import { getDefaultAuthType } from "@src/utilities";
import { legacyOauthSchema, twilioApiKeyIntegrationSchema, twilioTokenIntegrationSchema } from "@validations";
import { legacyOauthSchema, twilioApiTokenIntegrationSchema } from "@validations";

import { Select } from "@components/molecules";

Expand All @@ -33,13 +33,8 @@ export const TwilioIntegrationAddForm = ({
if (!connectionType?.value) {
return;
}
if (connectionType.value === ConnectionAuthType.AuthToken) {
setValidationSchema(twilioTokenIntegrationSchema);

return;
}
if (connectionType.value === ConnectionAuthType.ApiKey) {
setValidationSchema(twilioApiKeyIntegrationSchema);
if (connectionType.value === ConnectionAuthType.ApiToken) {
setValidationSchema(twilioApiTokenIntegrationSchema);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Accordion } from "@components/molecules";

import { ExternalLinkIcon, FloppyDiskIcon } from "@assets/image/icons";

export const ApiKeyTwilioForm = ({
export const ApiTokenTwilioForm = ({
control,
errors,
isLoading,
Expand Down Expand Up @@ -75,7 +75,7 @@ export const ApiKeyTwilioForm = ({
<SecretInput
type="password"
{...register("api_key")}
aria-label={t("twilio.placeholders.key")}
aria-label={t("twilio.placeholders.token")}
disabled={isLoading}
handleInputChange={(newKeyValue) => setValue("api_key", newKeyValue)}
handleLockAction={(newLockState: boolean) =>
Expand All @@ -84,18 +84,18 @@ export const ApiKeyTwilioForm = ({
isError={!!errors.api_key}
isLocked={lockState.api_key}
isRequired
label={t("twilio.placeholders.key")}
label={t("twilio.placeholders.token")}
value={apiKey}
/>
) : (
<Input
{...register("api_key")}
aria-label={t("twilio.placeholders.key")}
aria-label={t("twilio.placeholders.token")}
disabled={isLoading}
isError={!!errors.api_key}
isRequired
isSensitive
label={t("twilio.placeholders.key")}
label={t("twilio.placeholders.token")}
/>
)}
<ErrorMessage>{errors.api_key?.message as string}</ErrorMessage>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { ApiKeyTwilioForm } from "@components/organisms/configuration/connections/integrations/twilio/authMethods/apiKey";
export { AuthTokenTwilioForm } from "@components/organisms/configuration/connections/integrations/twilio/authMethods/authToken";
export { ApiTokenTwilioForm } from "@components/organisms/configuration/connections/integrations/twilio/authMethods/apiToken";
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import React from "react";
import { selectIntegrationTwilio } from "@constants/lists/connections";
import { ConnectionAuthType } from "@enums";
import { Integrations } from "@src/enums/components";
import { twilioApiKeyIntegrationSchema, twilioTokenIntegrationSchema } from "@validations";
import { twilioApiTokenIntegrationSchema } from "@validations";

import { IntegrationEditForm } from "@components/organisms/configuration/connections/integrations";

export const TwilioIntegrationEditForm = () => (
<IntegrationEditForm
integrationType={Integrations.twilio}
schemas={{
[ConnectionAuthType.ApiKey]: twilioApiKeyIntegrationSchema,
[ConnectionAuthType.AuthToken]: twilioTokenIntegrationSchema,
[ConnectionAuthType.ApiToken]: twilioApiTokenIntegrationSchema,
}}
selectOptions={selectIntegrationTwilio}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/organisms/topbar/project/projectName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const ProjectTopbarName = () => {
<EditIcon className="absolute -left-4 size-4 bg-gray-1250 fill-white p-0.5 opacity-0 transition group-hover:opacity-100" />
<span
className="max-w-240 truncate text-xl font-bold maxScreenWidth-1600:max-w-160"
data-testid="project-name"
title={project?.name}
>
{project?.name}
Expand Down
16 changes: 12 additions & 4 deletions src/components/templates/descopeMiddleware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const routes = [
{ path: "/intro" },
{ path: "/projects/*" },
{ path: "/settings/*" },
{ path: "/connections/*" },
{ path: "/events/*" },
{ path: "/template/*" },
{ path: "/chat" },
Expand Down Expand Up @@ -260,8 +261,17 @@ export const DescopeMiddleware = ({ children }: { children: ReactNode }) => {
}
}, [trackUserLogin, setTrackUserLoginFunction]);

const matches = matchRoutes(routes, location);
const isLoggedIn = user && Cookies.get(systemCookies.isLoggedIn);
if ((playwrightTestsAuthBearer || apiToken || isLoggedIn) && !isLoggingIn) {
const shouldShowApp = (playwrightTestsAuthBearer || apiToken || isLoggedIn) && !isLoggingIn;

useEffect(() => {
if (!shouldShowApp && !matches && location.pathname !== "/404") {
navigate("/404");
}
}, [matches, navigate, shouldShowApp, location.pathname]);

if (shouldShowApp) {
const isCliLogin = handleCliLoginRedirect();
if (isCliLogin) {
return <Loader isCenter />;
Expand All @@ -273,9 +283,7 @@ export const DescopeMiddleware = ({ children }: { children: ReactNode }) => {
return <External404 />;
}

const matches = matchRoutes(routes, location);
if (!matches) {
navigate("/404");
if (!matches && !shouldShowApp) {
return null;
}

Expand Down
Loading
Loading