Merge branch 'main' into minimum-booking-notice-will-allow-hours-and-days

This commit is contained in:
Jeroen Reumkens 2022-11-14 10:00:25 +01:00 committed by GitHub
commit 825418eeb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 10 deletions

View File

@ -1367,5 +1367,6 @@
"test_routing_form": "Test Routing Form",
"test_preview": "Test Preview",
"route_to": "Route to",
"test_preview_description": "Test your routing form without submitting any data"
"test_preview_description": "Test your routing form without submitting any data",
"test_routing": "Test Routing"
}

View File

@ -50,7 +50,7 @@ export default function FormInputFields(props: Props) {
/* @ts-ignore */
required={!!field.required}
listValues={options}
data-testid="field"
data-testid="form-field"
setValue={(value) => {
setResponse((response) => {
response = response || {};

View File

@ -283,7 +283,10 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
/>
</div>
<div className="mt-6">
<Button color="secondary" onClick={() => setIsTestPreviewOpen(true)}>
<Button
color="secondary"
data-testid="test-preview"
onClick={() => setIsTestPreviewOpen(true)}>
{t("test_preview")}
</Button>
</div>
@ -326,16 +329,19 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
<div className="mt-2">
{RoutingPages.map((page) => {
if (page.value === decidedAction.type) {
return <>{page.label}</>;
return <div data-testid="test-routing-result-type">{page.label}</div>;
}
})}
:{" "}
{decidedAction.type === "customPageMessage" ? (
<span className="text-gray-700">{decidedAction.value}</span>
<span className="text-gray-700" data-testid="test-routing-result">
{decidedAction.value}
</span>
) : decidedAction.type === "externalRedirectUrl" ? (
<span className="text-gray-700 underline">
<a
target="_blank"
data-testid="test-routing-result"
href={
decidedAction.value.includes("https://") ||
decidedAction.value.includes("http://")
@ -348,7 +354,11 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
</span>
) : (
<span className="text-gray-700 underline">
<a target="_blank" href={`/${decidedAction.value}`} rel="noreferrer">
<a
target="_blank"
href={`/${decidedAction.value}`}
rel="noreferrer"
data-testid="test-routing-result">
{decidedAction.value}
</a>
</span>
@ -369,7 +379,9 @@ function SingleForm({ form, appUrl, Page }: SingleFormComponentProps) {
{t("close")}
</Button>
</DialogClose>
<Button type="submit">{t("Test Routing")}</Button>
<Button type="submit" data-testid="test-routing">
{t("test_routing")}
</Button>
</DialogFooter>
</form>
</div>

View File

@ -283,11 +283,50 @@ test.describe("Routing Forms", () => {
expect(firstInputMissingValue).toBe(true);
expect(await page.locator('button[type="submit"][disabled]').count()).toBe(0);
});
test("Test preview should return correct route", async ({ page, users }) => {
const user = await createUserAndLoginAndInstallApp({ users, page });
const routingForm = user.routingForms[0];
page.goto(`apps/routing-forms/form-edit/${routingForm.id}`);
await page.click('[data-testid="test-preview"]');
// //event redirect
await page.fill('[data-testid="form-field"]', "event-routing");
await page.click('[data-testid="test-routing"]');
let routingType = await page.locator('[data-testid="test-routing-result-type"]').innerText();
let route = await page.locator('[data-testid="test-routing-result"]').innerText();
await expect(routingType).toBe("Event Redirect");
await expect(route).toBe("pro/30min");
//custom page
await page.fill('[data-testid="form-field"]', "custom-page");
await page.click('[data-testid="test-routing"]');
routingType = await page.locator('[data-testid="test-routing-result-type"]').innerText();
route = await page.locator('[data-testid="test-routing-result"]').innerText();
await expect(routingType).toBe("Custom Page");
await expect(route).toBe("Custom Page Result");
//external redirect
await page.fill('[data-testid="form-field"]', "external-redirect");
await page.click('[data-testid="test-routing"]');
routingType = await page.locator('[data-testid="test-routing-result-type"]').innerText();
route = await page.locator('[data-testid="test-routing-result"]').innerText();
await expect(routingType).toBe("External Redirect");
await expect(route).toBe("https://google.com");
//fallback route
await page.fill('[data-testid="form-field"]', "fallback");
await page.click('[data-testid="test-routing"]');
routingType = await page.locator('[data-testid="test-routing-result-type"]').innerText();
route = await page.locator('[data-testid="test-routing-result"]').innerText();
await expect(routingType).toBe("Custom Page");
await expect(route).toBe("Fallback Message");
});
});
});
async function fillSeededForm(page: Page, routingFormId: string) {
await gotoRoutingLink(page, routingFormId);
await page.fill('[data-testid="field"]', "event-routing");
await page.fill('[data-testid="form-field"]', "event-routing");
page.click('button[type="submit"]');
await page.waitForNavigation({
url(url) {
@ -296,7 +335,7 @@ async function fillSeededForm(page: Page, routingFormId: string) {
});
await gotoRoutingLink(page, routingFormId);
await page.fill('[data-testid="field"]', "external-redirect");
await page.fill('[data-testid="form-field"]', "external-redirect");
page.click('button[type="submit"]');
await page.waitForNavigation({
url(url) {
@ -305,7 +344,7 @@ async function fillSeededForm(page: Page, routingFormId: string) {
});
await gotoRoutingLink(page, routingFormId);
await page.fill('[data-testid="field"]', "custom-page");
await page.fill('[data-testid="form-field"]', "custom-page");
await page.click('button[type="submit"]');
await page.isVisible("text=Custom Page Result");
}