-
Notifications
You must be signed in to change notification settings - Fork 825
FIX: Make onboarding tour target-state aware #2310
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
Open
romanlutz
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
romanlutz:romanlutz-fix-onboarding-guidance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import { expect, test } from "@playwright/test"; | ||
|
|
||
| import { makeTarget } from "./_targets"; | ||
|
|
||
| test.describe("Onboarding tour", () => { | ||
| test("guides a user with no active target through the visible prerequisite", async ({ | ||
| page, | ||
| }) => { | ||
| await page.goto("/"); | ||
| await page.getByRole("button", { name: "Take a tour" }).click(); | ||
|
|
||
| const dialog = page.getByRole("alertdialog"); | ||
| await dialog.getByRole("button", { name: "Next", exact: true }).click(); | ||
| await dialog.getByRole("button", { name: "Next", exact: true }).click(); | ||
|
|
||
| await expect(dialog).toContainText( | ||
| "target selection happens in Configuration" | ||
| ); | ||
| await expect(dialog).toContainText("choose Configure a target"); | ||
| await expect(dialog).toContainText("use Set Active there"); | ||
| await expect(dialog).not.toContainText("come back here to select it"); | ||
| await expect(page.locator('[data-tour="target-card"]')).toBeVisible(); | ||
|
|
||
| await dialog.getByRole("button", { name: "Next", exact: true }).click(); | ||
|
|
||
| await expect(page).toHaveURL(/\/chat$/); | ||
| await expect(dialog).toContainText( | ||
| "Chat needs an active target before the message composer is available" | ||
| ); | ||
| await expect(dialog).toContainText( | ||
| "After the tour, choose Configure Target" | ||
| ); | ||
| await expect(dialog).toContainText( | ||
| "The message input and converter control appear once a target is active" | ||
| ); | ||
| await expect( | ||
| page.locator('[data-tour="chat-prerequisite"]') | ||
| ).toHaveAttribute("data-testid", "no-target-banner"); | ||
| await expect(page.locator('[data-tour="converter-toggle"]')).toHaveCount(0); | ||
| }); | ||
|
|
||
| test("guides a user with an active target to the visible converter control", async ({ | ||
| page, | ||
| }) => { | ||
| await page.route(/\/api\/targets(?:\?.*)?$/, async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: "application/json", | ||
| body: JSON.stringify({ | ||
| items: [ | ||
| makeTarget({ | ||
| target_registry_name: "tour-target", | ||
| target_type: "OpenAIChatTarget", | ||
| endpoint: "https://test.com", | ||
| model_name: "gpt-4o", | ||
| }), | ||
| ], | ||
| pagination: { | ||
| limit: 200, | ||
| has_more: false, | ||
| next_cursor: null, | ||
| prev_cursor: null, | ||
| }, | ||
| }), | ||
| }); | ||
| }); | ||
|
|
||
| await page.goto("/"); | ||
| await page | ||
| .getByRole("button", { name: "Configuration", exact: true }) | ||
| .click(); | ||
| await expect( | ||
| page.getByRole("heading", { name: "Target Configuration" }) | ||
| ).toBeVisible(); | ||
| await page.getByRole("button", { name: "Set Active", exact: true }).click(); | ||
| await page.getByRole("button", { name: "Home", exact: true }).click(); | ||
| await expect(page.getByTestId("home-target-active")).toContainText("gpt-4o"); | ||
|
|
||
| await page.getByRole("button", { name: "Take a tour" }).click(); | ||
| const dialog = page.getByRole("alertdialog"); | ||
| await dialog.getByRole("button", { name: "Next", exact: true }).click(); | ||
| await dialog.getByRole("button", { name: "Next", exact: true }).click(); | ||
|
|
||
| await expect(dialog).toContainText("target currently active for Chat"); | ||
| await expect(dialog).toContainText("use Set Active in Configuration"); | ||
| await expect(page.locator('[data-tour="target-card"]')).toBeVisible(); | ||
|
|
||
| await dialog.getByRole("button", { name: "Next", exact: true }).click(); | ||
|
|
||
| await expect(page).toHaveURL(/\/chat$/); | ||
| await expect(dialog).toContainText("Chat shows the message composer"); | ||
| await expect(dialog).toContainText("Toggle converter panel"); | ||
| await expect(page.getByRole("textbox")).toBeVisible(); | ||
| await expect(page.locator('[data-tour="converter-toggle"]')).toHaveAttribute( | ||
| "aria-label", | ||
| "Toggle converter panel" | ||
| ); | ||
| await expect(page.getByTestId("no-target-banner")).toHaveCount(0); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,50 +11,62 @@ export interface TourStep extends Step { | |||||
| readonly viewRequired: ViewName | ||||||
| } | ||||||
|
|
||||||
| export const TOUR_STEPS: readonly TourStep[] = [ | ||||||
| { | ||||||
| target: '[data-tour="sidebar-nav"]', | ||||||
| content: | ||||||
| 'Ahoy! Welcome to Co-PyRIT! This is your main navigation panel. Home is your dashboard, Chat is where you send prompts, ' + | ||||||
| 'History tracks past attacks, and Configuration is where you set up targets. Feel free to try clicking between these views!', | ||||||
| placement: 'right-start', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'home', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="labels-card"]', | ||||||
| content: | ||||||
| 'Labels like "operator" and "operation" tag every attack you run, making them easy to find later. ' + | ||||||
| 'Update the defaults before you start!', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'home', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="target-card"]', | ||||||
| content: | ||||||
| 'Targets are the AI endpoints you\'re testing. Head to Configuration to set one up, ' + | ||||||
| 'then come back here to select it before chatting.', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'home', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="chat-area"]', | ||||||
| content: | ||||||
| 'This is where you send prompts and view assistant responses. Use the converter panel toggle on the ' + | ||||||
| 'left of the message input box to transform your text before sending — like Base64 encoding or translation.', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'chat', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="history-filters"]', | ||||||
| content: | ||||||
| 'Every attack is logged here. Filter by different criteria like outcome, converter type, or labels to ' + | ||||||
| 'find exactly what you need!', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'history', | ||||||
| }, | ||||||
| ] | ||||||
| /** Builds tour guidance for the controls available in the current target state. */ | ||||||
| export function createTourSteps(hasActiveTarget: boolean): TourStep[] { | ||||||
| return [ | ||||||
| { | ||||||
| target: '[data-tour="sidebar-nav"]', | ||||||
| content: | ||||||
| 'Ahoy! Welcome to Co-PyRIT! This is your main navigation panel. Home is your dashboard, Chat is where you send prompts, ' + | ||||||
| 'History tracks past attacks, and Configuration is where you set up targets. Feel free to try clicking between these views!', | ||||||
| placement: 'right-start', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'home', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="labels-card"]', | ||||||
| content: | ||||||
| 'Labels like "operator" and "operation" tag every attack you run, making them easy to find later. ' + | ||||||
| 'Update the defaults before you start!', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'home', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="target-card"]', | ||||||
| content: hasActiveTarget | ||||||
| ? 'This card shows the target currently active for Chat. To switch targets after the tour, choose Manage targets ' + | ||||||
| 'and use Set Active in Configuration.' | ||||||
| : 'Targets are the AI endpoints you\'re testing. This card only shows the current target; target selection happens ' + | ||||||
| 'in Configuration. After the tour, choose Configure a target, then create or choose one and use Set Active there.', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'home', | ||||||
| }, | ||||||
| { | ||||||
| target: hasActiveTarget | ||||||
| ? '[data-tour="converter-toggle"]' | ||||||
| : '[data-tour="chat-prerequisite"]', | ||||||
| content: hasActiveTarget | ||||||
| ? 'With a target active, Chat shows the message composer. Use this Toggle converter panel button to transform text ' + | ||||||
| 'before sending, such as Base64 encoding or translation.' | ||||||
| : 'Chat needs an active target before the message composer is available. After the tour, choose Configure Target to ' + | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 'create or activate one in Configuration, then return to Chat. The message input and converter control appear once ' + | ||||||
| 'a target is active.', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'chat', | ||||||
| }, | ||||||
| { | ||||||
| target: '[data-tour="history-filters"]', | ||||||
| content: | ||||||
| 'Every attack is logged here. Filter by different criteria like outcome, converter type, or labels to ' + | ||||||
| 'find exactly what you need!', | ||||||
| placement: 'bottom', | ||||||
| skipBeacon: true, | ||||||
| viewRequired: 'history', | ||||||
| }, | ||||||
| ] | ||||||
| } | ||||||
|
|
||||||
| export const TOUR_STEPS = createTourSteps(false) | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line contains the old text and likely not needed?