Skip to content

Commit

Permalink
Merge pull request #107 from formkiq/formkiq/v3.2.3
Browse files Browse the repository at this point in the history
v3.2.3

- bug fixes (folder encoding, info pane scroll, no empty documents message before load is complete)
- adds copy id to document id on info pane
- adds API Key config
  • Loading branch information
reganwolfrom authored Aug 13, 2023
2 parents 7011fd8 + 3ebe744 commit d8ae7c3
Show file tree
Hide file tree
Showing 26 changed files with 2,095 additions and 411 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test as base } from '@playwright/test';
import { ApiExplorerPage } from './page-objects/ApiExplorerPage';
import { ApiKeysPage } from './page-objects/ApiKeysPage';
import { FavoritesPage } from './page-objects/FavoritesPage';
import { LoginPage } from './page-objects/LoginPage';
import { MyDocumentsPage } from './page-objects/MyDocumentsPage';
Expand All @@ -16,6 +17,7 @@ type Fixture = {
Trash: TrashPage;
Favorites: FavoritesPage;
ApiExplorer: ApiExplorerPage;
ApiKeys: ApiKeysPage;
Webhooks: WebhooksPage;
};

Expand Down Expand Up @@ -49,6 +51,10 @@ export const test = base.extend<Fixture>({
const apiExplorer = new ApiExplorerPage(page);
await use(apiExplorer);
},
ApiKeys: async ({ page }, use) => {
const apiKeys = new ApiKeysPage(page);
await use(apiKeys);
},
Webhooks: async ({ page }, use) => {
const webhooks = new WebhooksPage(page);
await use(webhooks);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Locator, Page } from '@playwright/test';

export class ApiKeysPage {
readonly page: Page;
readonly navigateLink: Locator;
readonly integrationDropdown: Locator;
readonly createButton: Locator;
readonly newModal: NewApiKeyModalObject;
readonly deleteModal: DeleteApiKeyModalObject;

constructor(page: Page) {
this.page = page;
this.integrationDropdown = page.getByTestId('expand-integrations');
this.navigateLink = page.getByTestId('nav-api-keys');
this.createButton = page.getByTestId('create-api-key').first();
this.newModal = new NewWebhookModalObject(page);
this.deleteModal = new DeleteWebhookModalObject(page);
}

async openPage() {
await this.integrationDropdown.click();
await this.navigateLink.click();
}

async openNewModal() {
await this.createButton.click();
}

async openDeleteModal(name: string) {
await this.page
.getByTestId(`api-key-${name}`)
.getByTestId('delete-api-key')
.click();
}
}

class DeleteApiKeyModalObject {
readonly page: Page;
readonly ok: Locator;
readonly cancel: Locator;
readonly body: Locator;

constructor(page: Page) {
this.page = page;
this.ok = page.getByTestId('global-modal-ok');
this.cancel = page.getByTestId('global-modal-cancel');
this.body = page.getByTestId('global-confirm-body');
}

async cancelDeletion() {
await this.cancel.click();
}

async confirmDeletion() {
await this.ok.click();
}
}

class NewApiKeyModalObject {
readonly page: Page;
readonly confirm: Locator;
readonly close: Locator;
readonly cancel: Locator;
readonly nameInput: Locator;
readonly body: Locator;

constructor(page: Page) {
this.page = page;
this.confirm = page.getByTestId('confirm-api-key-creation');
this.close = page.getByTestId('close-api-key-creation');
this.cancel = page.getByTestId('cancel-api-key-creation');
this.nameInput = page.getByTestId('api-key-name-input');
this.body = page.getByTestId('api-key-creation-modal');
}

async enterName(name: string) {
await this.nameInput.type(name);
}

async cancelCreation() {
await this.cancel.click();
}

async closeModal() {
await this.close.click();
}

async confirmCreation() {
await this.confirm.click();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { expect } from '@playwright/test';
import { test } from '../fixtures';

test.beforeEach(async ({ LoginPage }) => {
await LoginPage.login();
});

test('can navigate to the api keys page', async ({ page, ApiKeys }) => {
await ApiKeys.openPage();

await page.waitForURL('/integrations/apiKeys');
});

test('can add and delete a new api key', async ({ page, ApiKeys }) => {
await ApiKeys.openPage();

const apiKey = page.getByTestId(`api-key-my-new-api-key`);

await ApiKeys.openNewModal();
await ApiKeys.newModal.enterName('my-new-api-key');
await ApiKeys.newModal.confirmCreation();

await expect(apiKey).toBeVisible();

await ApiKeys.openDeleteModal('my-new-api-key');
await ApiKeys.deleteModal.confirmDeletion();

await expect(apiKey).not.toBeVisible();

await page.waitForTimeout(1000); //brief pause before the end of the test to ensure deletion action resolves
});

test('can cancel out of creating an api key', async ({ ApiKeys }) => {
await ApiKeys.openPage();

await ApiKeys.openNewModal();
await ApiKeys.newModal.enterName('my-new-api-key');
await ApiKeys.newModal.cancelCreation();

await expect(ApiKeys.newModal.body).not.toBeVisible();

await ApiKeys.openNewModal();
await ApiKeys.newModal.enterName('my-new-api-key');
await ApiKeys.newModal.closeModal();

await expect(ApiKeys.newModal.body).not.toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ function GlobalNotificationDialog() {
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<Dialog.Panel className="w-full max-w-md transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Panel className="w-full max-w-lg transform overflow-hidden rounded-2xl bg-white p-6 text-left align-middle shadow-xl transition-all">
<Dialog.Title
as="h3"
data-test-id="modal-title"
className="text-lg font-medium text-center leading-6 pb-2 text-gray-900"
className="text-base font-medium text-center leading-6 pb-2 text-gray-900 pr-2"
>
{dialogTitle}
</Dialog.Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default function DocumentActionsPopover({
{line.lineType === 'document' &&
!isSiteReadOnly &&
line.documentInstance &&
formkiqVersion.modules.indexOf('esignature') > -1 &&
formkiqVersion.modules?.indexOf('esignature') > -1 &&
ESignatureContentTypes.indexOf(
line.documentInstance.contentType
) > -1 && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default function NewModal({
Upload a New Folder
</div>
</div>
{formkiqVersion.modules.indexOf('onlyoffice') > -1 && (
{formkiqVersion.modules?.indexOf('onlyoffice') > -1 && (
<>
<div
className={`${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default function UploadModal({
DocumentsService.getDocumentsById(ids, siteId).then(
(uploaded: []) => {
setUploadProcess([]);
if (formkiqVersion.modules.indexOf('fulltext') > -1) {
if (formkiqVersion.modules?.indexOf('fulltext') > -1) {
const actions = [{ type: 'fulltext' }];
uploaded.forEach((doc: any) => {
DocumentsService.postDocumentActions(
Expand Down Expand Up @@ -386,8 +386,8 @@ export default function UploadModal({
{formatDate(file.insertedDate)}
</td>
<td className="hidden border-b border-slate-100 nodark:border-slate-700 p-4 pr-8 text-slate-500 nodark:text-slate-400 text-center">
{formkiqVersion.modules.indexOf('ocr') > -1 &&
formkiqVersion.modules.indexOf('fulltext') > -1 &&
{formkiqVersion.modules?.indexOf('ocr') > -1 &&
formkiqVersion.modules?.indexOf('fulltext') > -1 &&
OcrContentTypes.indexOf(file.contentType) > -1 && (
<>
{file.processingOcrWorkflow && <Spinner />}
Expand Down Expand Up @@ -499,7 +499,7 @@ export default function UploadModal({
Run the following actions, when available:
</h4>
<div className="mt-2 mb-5 w-full flex text-sm">
{formkiqVersion.modules.indexOf('antivirus') > -1 && (
{formkiqVersion.modules?.indexOf('antivirus') > -1 && (
<div className="px-4">
<input
id="actionCheckboxAntivirus"
Expand All @@ -513,7 +513,7 @@ export default function UploadModal({
</label>
</div>
)}
{formkiqVersion.modules.indexOf('ocr') > -1 && (
{formkiqVersion.modules?.indexOf('ocr') > -1 && (
<div className="px-4">
<input id="actionCheckboxOcr" type="checkbox" />
<label
Expand All @@ -524,7 +524,7 @@ export default function UploadModal({
</label>
</div>
)}
{formkiqVersion.modules.indexOf('typesense') > -1 && (
{formkiqVersion.modules?.indexOf('typesense') > -1 && (
<div className="px-4">
<input
id="actionCheckboxTypesense"
Expand All @@ -538,7 +538,7 @@ export default function UploadModal({
</label>
</div>
)}
{formkiqVersion.modules.indexOf('fulltext') > -1 && (
{formkiqVersion.modules?.indexOf('fulltext') > -1 && (
<div className="px-4">
<input
id="actionCheckboxFulltext"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Tooltip } from 'react-tooltip';
import { CopyIcon } from '../Icons/icons';
import { useState } from 'react';

export type CopyButtonProps = {
value: string;
id?: string;
};

export const CopyButton = (props: CopyButtonProps) => {
const [text, setText] = useState('Copy');

const { value, id } = props;
return (
<>
<Tooltip id={id ?? 'copy-tooltip'} />
<button
data-tooltip-id={id ?? 'copy-tooltip'}
data-tooltip-content={text}
onClick={() => {
window.navigator.clipboard.writeText(value);
setText('Copied!');

setTimeout(() => {
setText('Copy');
}, 2000);
}}
>
<CopyIcon />
</button>
</>
);
};
Loading

0 comments on commit d8ae7c3

Please sign in to comment.