Skip to content

Commit

Permalink
Test(web,web-react): Update visual snapshots after demo apps redesign…
Browse files Browse the repository at this point in the history
… #DS-1479

Hide site header and footer from component snapshots.
  • Loading branch information
adamkudrna committed Oct 3, 2024
1 parent e8eaa38 commit 14a7f16
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/demo/partials/cover.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="spirit-theme-light-on-brand bg-primary mb-tablet-1200 py-1200 py-tablet-1700">
<div class="spirit-theme-light-on-brand bg-primary mb-tablet-1200 py-1200 py-tablet-1700 {{#unless (eq page 'components')}}hide-from-visual-tests{{/unless}}">
<div class="Container">

<h1
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/partials/footer.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<footer class="bg-secondary mt-1200 mt-tablet-1700 pt-1400 pb-1200 text-center">
<footer class="bg-secondary mt-1200 mt-tablet-1700 pt-1400 pb-1200 text-center {{#unless (eq page 'components')}}hide-from-visual-tests{{/unless}}">
<div class="Container">

© Alma Career Oy and its subsidiaries
Expand Down
5 changes: 3 additions & 2 deletions apps/demo/partials/header.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header class="Header spirit-theme-light-on-brand">
<header class="Header spirit-theme-light-on-brand {{#unless (eq page 'components')}}hide-from-visual-tests{{/unless}}">
<a href="/" aria-label="Spirit Development Preview">
{{> web/assets/spiritLogoInverted }}
</a>
Expand Down Expand Up @@ -44,8 +44,9 @@
</a>
</li>
{{!-- Hide link to the Twig implementation in production. Twig demo app only runs on localhost, we don't deploy it anywhere. --}}
{{!-- For the same reason, we don't include the link in the visual tests. --}}
{{#if @is_development}}
<li class="HeaderNavItem">
<li class="HeaderNavItem hide-from-visual-tests">
<a href="https://localhost:4443" class="HeaderLink">Web Twig</a>
</li>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion apps/web-twig-demo/templates/partials/cover.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="spirit-theme-light-on-brand bg-primary mb-tablet-1200 py-1200 py-tablet-1700">
<div class="spirit-theme-light-on-brand bg-primary mb-tablet-1200 py-1200 py-tablet-1700 hide-from-visual-tests">
<Container>

<h1
Expand Down
2 changes: 1 addition & 1 deletion apps/web-twig-demo/templates/partials/footer.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<footer class="bg-secondary mt-1200 mt-tablet-1700 pt-1400 pb-1200 text-center">
<footer class="bg-secondary mt-1200 mt-tablet-1700 pt-1400 pb-1200 text-center hide-from-visual-tests">
<Container>

© Alma Career Oy and its subsidiaries
Expand Down
2 changes: 1 addition & 1 deletion apps/web-twig-demo/templates/partials/header.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Header UNSAFE_className="spirit-theme-light-on-brand">
<Header UNSAFE_className="spirit-theme-light-on-brand hide-from-visual-tests">

<Link href="http://localhost:3456" aria-label="Spirit Development Preview">
{% include 'assets/spiritLogoInverted.html.twig' %}
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/demo-components-compare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { isTesting as isTestingEnvironment } from '@lmc-eu/spirit-common/constants/environments';
import { test } from '@playwright/test';
import { readdirSync } from 'fs';
import { formatPackageName, getServerUrl, takeScreenshot, waitForPageLoad } from '../helpers';
import { formatPackageName, getServerUrl, hideFromVisualTests, takeScreenshot, waitForPageLoad } from '../helpers';

// Tests that are intentionally broken, but will be fixed in the future
const IGNORED_TESTS: string[] = [];
Expand Down Expand Up @@ -37,6 +37,7 @@ const runComponentCompareTests = (testConfig: TestConfig) => {
const url = getServerUrl(packageName);
await page.goto(`${url}${componentsDir}/${component}/${packageName === 'web-twig' ? '?HIDE_TOOLBAR' : ''}`);
await waitForPageLoad(page);
await hideFromVisualTests(page);
await takeScreenshot(page, `${component}`, { fullPage: true });
} catch (error) {
// beware of the case insensitive systems; keep the prefix in the small case
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion tests/e2e/demo-homepages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isTesting } from '@lmc-eu/spirit-common/constants/environments';
import { SERVERS, getDevelopmentEndpointUri } from '@lmc-eu/spirit-common/constants/servers';
import { test } from '@playwright/test';
import { takeScreenshot, waitForPageLoad } from '../helpers';
import { hideFromVisualTests, takeScreenshot, waitForPageLoad } from '../helpers';

test.describe('Demo Homepages', () => {
const demos = [
Expand All @@ -19,6 +19,7 @@ test.describe('Demo Homepages', () => {
test(`test demo homepage ${demo.package}`, async ({ page }) => {
await page.goto(demo.url);
await waitForPageLoad(page);
await hideFromVisualTests(page);
await takeScreenshot(page, demo.package, { fullPage: true });
});
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions tests/helpers/hideFromVisualTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Page } from '@playwright/test';

export const hideFromVisualTests = async (page: Page): Promise<void> => {
await page.addStyleTag({ content: '.hide-from-visual-tests { display: none !important }' });
};
1 change: 1 addition & 0 deletions tests/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './formatPackageName';
export * from './getServerUrl';
export * from './hideFromVisualTests';
export * from './takeScreenshot';
export * from './waitForPageLoad';

0 comments on commit 14a7f16

Please sign in to comment.