Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style fixes and test updates for app tour #239

Merged
merged 7 commits into from
Oct 26, 2023
Merged
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Development version

### Minor new features and improvements

- Tour works again in website live-demo mode

# 0.5.1

### Major changes
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/editor/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Shiny UI Editor</title>
<script type="module" crossorigin src="./assets/index-11db4393.js"></script>
<script type="module" crossorigin src="./assets/index-cdb60eed.js"></script>
<link rel="stylesheet" href="./assets/index-22085128.css">
</head>

Expand Down
49 changes: 49 additions & 0 deletions inst/editor/playwright/tour-mode.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { test, expect } from "@playwright/test";

import { startupMockedApp } from "./utils/mockBackend";

test("Live Demo loads and can be navigated", async ({ page }) => {
await startupMockedApp(page, { language: "R" });

// Select a template.
await page.locator(".template-container").first().click();

// Click button to proceed with template
await page
.getByRole("button", { name: "Start editor with selected template" })
.click();

// Make sure the main view has loaded by looking for the "Elements" section
await expect(page.getByRole("heading", { name: "Elements" })).toBeVisible();

// Click "Tour App" button
await page.getByRole("button", { name: "Tour App" }).click();

// Make sure that the tour has started
await expect(page.getByRole("alertdialog")).toBeVisible();

// Get the text content of the tour alert dialog so we can check that it changes in the next step
const tourText = await page.getByRole("alertdialog").textContent();

// Click the "Next" button
await page.getByRole("button", { name: "Next" }).click();

// Make sure that the tour has advanced to the next step by checking that the
// text content of the alert dialog has changed
const tourText2 = await page.getByRole("alertdialog").textContent();
expect(tourText2).not.toBe(tourText);

// Close the tour with the X button
await page.getByLabel("Close").click();

// Make sure that the tour has closed
await expect(page.getByRole("alertdialog")).not.toBeVisible();

// Re-opening the tour will start from the left off step
await page.getByRole("button", { name: "Tour App" }).click();
expect(await page.getByRole("alertdialog").textContent()).toBe(tourText2);

// Pressing the back button will go back to the first step
await page.getByRole("button", { name: "Back" }).click();
expect(await page.getByRole("alertdialog").textContent()).toBe(tourText);
});
13 changes: 10 additions & 3 deletions inst/editor/src/AppTour/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PngIcon from "../components/Icons";
import Button from "../components/Inputs/Button/Button";
import styles from "../DragAndDropHelpers/DropWatcherPanel.module.css";
import { useMetaData } from "../state/metaData";
import { mergeClasses } from "../utils/mergeClasses";

export function AppTour() {
const [stepIndex, setStepIndex] = React.useState(0);
Expand Down Expand Up @@ -82,13 +83,19 @@ export function AppTour() {
</p>
<p>
In the app view, the areas available for the element to be dropped
in will pulse with an{" "}
in will pulse orange:{" "}
<span
className={styles.can_accept_drop}
className={mergeClasses(
styles.can_accept_drop,
"text-transparent"
)}
// Ignore for screen readers
aria-hidden="true"
style={{ padding: "2px" }}
>
orange outline.
drop
</span>
.
</p>
</div>
),
Expand Down
Binary file modified inst/vscode-extension/shinyuieditor-0.5.1.vsix
Binary file not shown.
12 changes: 12 additions & 0 deletions inst/website/src/pages/live-demo.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import "@/styles/globals.css";
import { internalLink } from "@/lib/utils";
---



<FullPageLayout title="SUE | Live Demo">
<Header showBorder={true} />
<!-- Need min-h-0 to avoid growing over the allotted size -->
Expand All @@ -24,3 +26,13 @@ import { internalLink } from "@/lib/utils";

</main>
</FullPageLayout>

<script is:inline>
// This is needed for various older packages that require the global
// object to be defined because it typically was with older bundlers like
// webpack
if (typeof global === "undefined") {
global = window;
}

</script>
13 changes: 13 additions & 0 deletions inst/website/tests/check-live-demo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,17 @@ test("Live Demo loads and can be navigated", async ({ page }) => {

// Make sure the main view has loaded by looking for the "Elements" section
await expect(page.getByRole("heading", { name: "Elements" })).toBeVisible();

// Make sure tour mode works
// Click "Tour App" button
await page.getByRole("button", { name: "Tour App" }).click();

// Make sure that the tour has started
await expect(page.getByRole("alertdialog")).toBeVisible();

// Close the tour with the X button
await page.getByLabel("Close").click();

// Make sure that the tour has closed
await expect(page.getByRole("alertdialog")).not.toBeVisible();
});