-
Notifications
You must be signed in to change notification settings - Fork 1.1k
EDU-122: Blueprints - Hero - React Gen 2 #4021
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
94cc037
hero blueprints react
uttej-vsk 65872e7
change urlpath
uttej-vsk 710f3b5
variables for reusability
uttej-vsk 359de95
removed presentation assertion
uttej-vsk 1c90b3b
Merge branch 'main' into EDU-122-hero-react
uttej-vsk 3183953
Update blueprints-hero.spec.ts
uttej-vsk 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
51 changes: 51 additions & 0 deletions
51
packages/sdks-tests/src/snippet-tests/blueprints-hero.spec.ts
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,51 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '../helpers/index.js'; | ||
|
||
test.describe('Hero Section', () => { | ||
test.beforeEach(async ({ page, packageName }) => { | ||
test.skip( | ||
[ | ||
'react-native-74', | ||
'react-native-76-fabric', | ||
'solid', | ||
'solid-start', | ||
'qwik-city', | ||
'react-sdk-next-pages', | ||
'remix', | ||
'hydrogen', | ||
'react-sdk-next-14-app', | ||
'react-sdk-next-15-app', | ||
'nextjs-sdk-next-app', | ||
'vue', | ||
'nuxt', | ||
'svelte', | ||
'sveltekit', | ||
'angular-16', | ||
'angular-16-ssr', | ||
'angular-19-ssr', | ||
'gen1-react', | ||
'gen1-remix', | ||
'gen1-next14-pages', | ||
'gen1-next15-app', | ||
].includes(packageName) | ||
); | ||
await page.goto('/marketing-event'); | ||
}); | ||
|
||
test('should display the hero section with title and call-to-action', async ({ page }) => { | ||
await page.waitForLoadState('networkidle'); | ||
|
||
const heading = page.getByText('Find the best shoes in town'); | ||
await expect(heading).toBeVisible(); | ||
|
||
const ctaButton = page.getByRole('button', { name: 'Buy now' }); | ||
await expect(ctaButton).toBeVisible(); | ||
await expect(ctaButton).toBeEnabled(); | ||
}); | ||
|
||
test('should display hero image', async ({ page }) => { | ||
const productImage = page.getByRole('presentation'); | ||
await expect(productImage).toBeVisible(); | ||
await expect(productImage).toHaveAttribute('src', /.+/); | ||
}); | ||
uttej-vsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); |
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
33 changes: 33 additions & 0 deletions
33
packages/sdks/snippets/react/src/routes/blueprints/Hero.tsx
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,33 @@ | ||
import { BuilderContent, Content, fetchOneEntry } from '@builder.io/sdk-react'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export default function ProductHero() { | ||
const [productHero, setProductHero] = useState<BuilderContent | null>(null); | ||
|
||
useEffect(() => { | ||
fetchOneEntry({ | ||
model: 'collection-hero', | ||
apiKey: 'ee9f13b4981e489a9a1209887695ef2b', | ||
userAttributes: { urlPath: window.location.pathname }, | ||
}).then((data) => { | ||
setProductHero(data); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{/* Your nav goes here */} | ||
|
||
uttej-vsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{/* Render the Hero content if available */} | ||
{productHero && ( | ||
<Content | ||
content={productHero} | ||
model="collection-hero" | ||
apiKey="ee9f13b4981e489a9a1209887695ef2b" | ||
uttej-vsk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
)} | ||
|
||
{/* The rest of your page goes here */} | ||
</> | ||
); | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.