Skip to content

Commit 67f8631

Browse files
feat: e2e dev preview tests
1 parent ebb0b44 commit 67f8631

1 file changed

Lines changed: 21 additions & 21 deletions

File tree

  • test/commands/lightning/dev/component-preview

test/commands/lightning/dev/component-preview/hmr.nut.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,6 @@ describe('lightning preview hot module reload', () => {
7777
await fs.promises.writeFile(componentJsPath, originalJsContent, 'utf8');
7878
});
7979

80-
it('should re-render component and hot reload .html changes', async () => {
81-
// Assert initial HTML
82-
const greetingLocator = page.getByText(INITIAL_GREETING);
83-
expect(await greetingLocator.textContent()).to.equal(INITIAL_GREETING);
84-
85-
// Update HTML template
86-
const componentHtmlPath = path.join(getComponentPath(session, COMPONENT_NAME), `${COMPONENT_NAME}.html`);
87-
const originalHtmlContent = await fs.promises.readFile(componentHtmlPath, 'utf8');
88-
const modifiedHtmlContent = originalHtmlContent.replace(
89-
'<div class="greeting">{greeting}</div>',
90-
`<div class="greeting">{greeting}<span>${HMR_GREETING}</span></div>`,
91-
);
92-
await fs.promises.writeFile(componentHtmlPath, modifiedHtmlContent, 'utf8');
93-
94-
// Assert updated HTML
95-
const hmrMarkerLocator = page.getByText(HMR_GREETING);
96-
expect(await hmrMarkerLocator.textContent()).to.equal(HMR_GREETING);
97-
98-
await fs.promises.writeFile(componentHtmlPath, originalHtmlContent, 'utf8');
99-
});
100-
10180
it('should re-render component and hot reload .css changes', async () => {
10281
// Assert initial color
10382
// Assert initial HTML
@@ -126,4 +105,25 @@ describe('lightning preview hot module reload', () => {
126105
expect(greetingColor).to.equal(RED);
127106
await fs.promises.writeFile(componentCssPath, originalCssContent, 'utf8');
128107
});
108+
109+
it('should re-render component and hot reload .html changes', async () => {
110+
// Assert initial HTML
111+
const greetingLocator = page.getByText(INITIAL_GREETING);
112+
expect(await greetingLocator.textContent()).to.equal(INITIAL_GREETING);
113+
114+
// Update HTML template
115+
const componentHtmlPath = path.join(getComponentPath(session, COMPONENT_NAME), `${COMPONENT_NAME}.html`);
116+
const originalHtmlContent = await fs.promises.readFile(componentHtmlPath, 'utf8');
117+
const modifiedHtmlContent = originalHtmlContent.replace(
118+
'<div class="greeting">{greeting}</div>',
119+
`<div class="greeting">{greeting}<span>${HMR_GREETING}</span></div>`,
120+
);
121+
await fs.promises.writeFile(componentHtmlPath, modifiedHtmlContent, 'utf8');
122+
123+
// Assert updated HTML
124+
const hmrMarkerLocator = page.getByText(HMR_GREETING);
125+
expect(await hmrMarkerLocator.textContent()).to.equal(HMR_GREETING);
126+
127+
await fs.promises.writeFile(componentHtmlPath, originalHtmlContent, 'utf8');
128+
});
129129
});

0 commit comments

Comments
 (0)