-
Notifications
You must be signed in to change notification settings - Fork 19
W-19881690 e2e testing #626
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
jhefferman-sfdc
wants to merge
12
commits into
main
Choose a base branch
from
jhefferman/dev-preview-e2e
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.
+912
−366
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
28803c1
feat: e2e dev preview tests
jhefferman-sfdc a03354e
fix: revert changes
jhefferman-sfdc 8d2d350
chore: merged main
jhefferman-sfdc 01478da
chore: fix yarn lock
jhefferman-sfdc 562eac3
chore: readme
jhefferman-sfdc 4c4444c
chore: cleanup
jhefferman-sfdc 6684347
feat: test against scratch orgs
jhefferman-sfdc 66ccc25
chore: readme expand
jhefferman-sfdc 6f13411
chore: readme expand
jhefferman-sfdc 0fe90b6
fix: user credential issue in windows
jhefferman-sfdc fd666ba
fix: post install
jhefferman-sfdc eb4d528
fix: post install
jhefferman-sfdc 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
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 was deleted.
Oops, something went wrong.
104 changes: 104 additions & 0 deletions
104
test/commands/lightning/dev/component-preview/browserMenu.nut.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,104 @@ | ||
| /* | ||
| * Copyright 2026, Salesforce, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { ChildProcessByStdio } from 'node:child_process'; | ||
| import type { Readable, Writable } from 'node:stream'; | ||
| import { TestSession } from '@salesforce/cli-plugins-testkit'; | ||
| import { expect } from 'chai'; | ||
| import { type Browser, type Page } from 'playwright'; | ||
| import { getSession } from '../helpers/sessionUtils.js'; | ||
| import { startLightningDevServer, getPreviewURL, killServerProcess } from '../helpers/devServerUtils.js'; | ||
| import { getPreview } from '../helpers/browserUtils.js'; | ||
|
|
||
| const COMPONENT_NAME = 'helloWorld'; | ||
| const INITIAL_GREETING = 'Hello World'; | ||
| const STATIC_CONTENT = 'Static Content'; | ||
|
|
||
| describe('lightning preview menu', () => { | ||
| let session: TestSession; | ||
| let childProcess: ChildProcessByStdio<Writable, Readable, Readable> | undefined; | ||
| let browser: Browser; | ||
| let page: Page; | ||
|
|
||
| beforeEach(async () => { | ||
| session = await getSession(); | ||
| childProcess = startLightningDevServer(session, { AUTO_ENABLE_LOCAL_DEV: 'true' }, COMPONENT_NAME); | ||
| const previewUrl = await getPreviewURL(childProcess.stdout); | ||
| ({ browser, page } = await getPreview(previewUrl, session)); | ||
| }); | ||
|
|
||
| afterEach(async () => { | ||
| if (page) await page.close(); | ||
| if (browser) await browser.close(); | ||
| killServerProcess(childProcess); | ||
| }); | ||
|
|
||
| it('should render select link and hamburger menu with helloWorld available and clickable', async () => { | ||
| const greetingLocator = page.getByText(INITIAL_GREETING); | ||
| await greetingLocator.waitFor({ state: 'visible' }); | ||
|
|
||
| // When a component is already selected (e.g. --name helloWorld), the canvas shows the component, | ||
| // not the "Select a component..." link. Open the hamburger to verify the panel and helloWorld. | ||
| const menuToggle = page.getByRole('link', { name: 'Toggle menu' }); | ||
| await menuToggle.waitFor({ state: 'visible' }); | ||
| await menuToggle.scrollIntoViewIfNeeded(); | ||
| await menuToggle.click({ force: true }); | ||
|
|
||
| // Hamburger opens lwr_dev-component-panel (slide-in panel) | ||
| const componentPanel = page.locator('lwr_dev-component-panel >> .lwr-dev-component-panel__panel--visible'); | ||
| await componentPanel.waitFor({ state: 'visible' }); | ||
|
|
||
| const staticItem = page.locator( | ||
| 'lwr_dev-component-panel >> .lwr-dev-component-panel__item[data-specifier="c/static"]', | ||
| ); | ||
| await staticItem.waitFor({ state: 'visible' }); | ||
| await staticItem.click(); | ||
|
|
||
| // Wait for the app to load the selected component (URL updates with specifier) | ||
| await page.waitForURL(/specifier=c%2Fstatic|c\/static/, { timeout: 15_000 }); | ||
|
|
||
| const staticContentLocator = page.getByText(STATIC_CONTENT); | ||
| await staticContentLocator.waitFor({ state: 'visible', timeout: 15_000 }); | ||
| expect(await staticContentLocator.textContent()).to.include(STATIC_CONTENT); | ||
| }); | ||
|
|
||
| it('should render component in performance mode when performance mode button is clicked', async () => { | ||
| const greetingLocator = page.getByText(INITIAL_GREETING); | ||
| await greetingLocator.waitFor({ state: 'visible' }); | ||
|
|
||
| const performanceLink = page.locator( | ||
| 'lwr_dev-preview-application >> lwr_dev-preview-header >> .lwr-dev-preview-header__performance-mode-link', | ||
| ); | ||
| await performanceLink.waitFor({ state: 'visible' }); | ||
| await performanceLink.click(); | ||
|
|
||
| await page.waitForURL(/mode=performance/); | ||
| expect(page.url()).to.include('mode=performance'); | ||
|
|
||
| const header = page.locator( | ||
| 'lwr_dev-preview-application >> lwr_dev-preview-header >> .lwr-dev-preview-header__header', | ||
| ); | ||
| expect(await header.first().isHidden()).to.be.true; | ||
|
|
||
| const performanceLinkAfter = page.locator( | ||
| 'lwr_dev-preview-application >> lwr_dev-preview-header >> .lwr-dev-preview-header__performance-mode-link', | ||
| ); | ||
| expect(await performanceLinkAfter.first().isHidden()).to.be.true; | ||
|
|
||
| await greetingLocator.waitFor({ state: 'visible' }); | ||
| expect(await greetingLocator.textContent()).to.equal(INITIAL_GREETING); | ||
| }); | ||
| }); |
83 changes: 83 additions & 0 deletions
83
test/commands/lightning/dev/component-preview/componentError.nut.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,83 @@ | ||
| /* | ||
| * Copyright 2026, Salesforce, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { ChildProcessByStdio } from 'node:child_process'; | ||
| import type { Readable, Writable } from 'node:stream'; | ||
| import { TestSession } from '@salesforce/cli-plugins-testkit'; | ||
| import { expect } from 'chai'; | ||
| import { type Browser, type Page } from 'playwright'; | ||
| import { getSession } from '../helpers/sessionUtils.js'; | ||
| import { startLightningDevServer, getPreviewURL, killServerProcess } from '../helpers/devServerUtils.js'; | ||
| import { getPreview } from '../helpers/browserUtils.js'; | ||
|
|
||
| const COMPONENT_NAME = 'withError'; | ||
| const ERROR_MESSAGE = 'Component generated error'; | ||
|
|
||
| /** Locator for error message text (class from LWR error display / lwr_dev/errorDisplay) */ | ||
| const errorMessageEl = (p: Page) => p.locator('.error-message-text'); | ||
|
|
||
| describe('lightning preview component error', () => { | ||
| let session: TestSession; | ||
| let childProcess: ChildProcessByStdio<Writable, Readable, Readable> | undefined; | ||
| let browser: Browser; | ||
| let page: Page; | ||
|
|
||
| before(async () => { | ||
| session = await getSession(); | ||
| childProcess = startLightningDevServer(session, { AUTO_ENABLE_LOCAL_DEV: 'true' }, COMPONENT_NAME); | ||
| const previewUrl = await getPreviewURL(childProcess.stdout); | ||
| ({ browser, page } = await getPreview(previewUrl, session)); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| if (page) await page.close(); | ||
| if (browser) await browser.close(); | ||
| killServerProcess(childProcess); | ||
| }); | ||
|
|
||
| it('should render the error component and display the error modal', async () => { | ||
| const message = errorMessageEl(page); | ||
| await message.waitFor({ state: 'visible', timeout: 15_000 }); | ||
| expect(await message.textContent()).to.include(ERROR_MESSAGE); | ||
| }); | ||
|
|
||
| it('should display the error modal and close it when the dismiss button is clicked', async () => { | ||
| const message = errorMessageEl(page); | ||
| await message.waitFor({ state: 'visible', timeout: 15_000 }); | ||
|
|
||
| const dismissButton = page.getByRole('button', { name: /dismiss/i }); | ||
| await dismissButton.waitFor({ state: 'visible' }); | ||
| await dismissButton.click(); | ||
|
|
||
| await message.waitFor({ state: 'hidden', timeout: 10_000 }); | ||
| expect(await message.isHidden()).to.be.true; | ||
| }); | ||
|
|
||
| it('should copy the error text to the clipboard when copy is clicked', async () => { | ||
| await page.context().grantPermissions(['clipboard-read', 'clipboard-write']); | ||
| await page.reload({ waitUntil: 'load' }); | ||
|
|
||
| const message = errorMessageEl(page); | ||
| await message.waitFor({ state: 'visible', timeout: 15_000 }); | ||
|
|
||
| const copyButton = page.getByRole('button', { name: /copy/i }); | ||
| await copyButton.waitFor({ state: 'visible' }); | ||
| await copyButton.click(); | ||
|
|
||
| const clipboardText = await page.evaluate('navigator.clipboard.readText()'); | ||
| expect(clipboardText).to.include(ERROR_MESSAGE); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
ngl, NUT is a weird way to call integration tests
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.
#salesforce, sigh
https://github.com/salesforcecli/cli-plugins-testkit/tree/main?tab=readme-ov-file#example-nuts
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.
Look on the bright side. There are way more dumb jokes to be made about NUTs than there are about e2e!