Skip to content
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

Demo HP and visual tests only include pages with index.html (or *.stories.twig) #1302

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/web-react/config/vite/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { defineConfig } from 'vite';
import handlebars from 'vite-plugin-handlebars';
import { getNestedDirs } from '../../scripts/build';

const hiddenDemoComponents = ['Field', 'Dialog', 'Icon', 'NoSsr', 'TextFieldBase', 'VisuallyHidden'];

export default defineConfig({
// Disable HMR overlay to avoid flaky screenshots in visual regression tests
server: {
Expand All @@ -29,7 +27,7 @@ export default defineConfig({
components: [
...readdirSync('src/components', { withFileTypes: true })
.filter((item) => item.isDirectory())
.filter((item) => !hiddenDemoComponents.includes(item.name))
.filter((item) => readdirSync(`src/components/${item.name}`).includes('index.html'))
.map((item) => item.name),
],
},
Expand Down
3 changes: 2 additions & 1 deletion packages/web/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export const kebabToTitleCase = (string) =>
.map((word) => `${word.charAt(0).toUpperCase()}${word.slice(1)}`)
.join(' ');

export const getListOfNestedDirectories = (path) => [
export const getListOfNestedDirectories = (path, mainFile) => [
...readdirSync(path, { withFileTypes: true })
.filter((item) => item.isDirectory())
.filter((item) => readdirSync(`${path}/${item.name}`).includes(mainFile))
.map((item) => ({
name: item.name,
title: kebabToTitleCase(item.name),
Expand Down
4 changes: 2 additions & 2 deletions packages/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export default defineConfig({
runtimeOptions: {
data: {
// Get the list of components directories and pass their names to the data
components: getListOfNestedDirectories('src/scss/components'),
components: getListOfNestedDirectories('src/scss/components', 'index.html'),
// Get the list of helpers directories and pass their names to the data
helpers: getListOfNestedDirectories('src/scss/helpers'),
helpers: getListOfNestedDirectories('src/scss/helpers', 'index.html'),
// Get the list of icons files from the icons package and pass their names to the data without their extensions
icons: getListOfIcons('../icons/src/svg'),
},
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/demo-components-compare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const IGNORED_TESTS = [
];

const runComponentCompareTests = (testConfig) => {
const { packageDir, componentsDir, srcDir = '', ignoredComponents = [], packageName } = testConfig;
const { packageDir, componentsDir, srcDir = '', packageName } = testConfig;
if (packageName) {
const formattedPackageName = packageName
.split('-')
Expand All @@ -19,7 +19,11 @@ const runComponentCompareTests = (testConfig) => {
test.describe(`Demo ${formattedPackageName} Components`, () => {
const componentDirs = readdirSync(`${packageDir}${srcDir}${componentsDir}`, { withFileTypes: true })
.filter((item) => item.isDirectory())
.filter((item) => !ignoredComponents.includes(item.name))
.filter((item) =>
readdirSync(`${packageDir}${srcDir}${componentsDir}/${item.name}`).includes(
packageName !== 'web-twig' ? 'index.html' : `${item.name}.stories.twig`,
),
)
.filter((item) => !IGNORED_TESTS.includes(item.name))
.map((item) => item.name.toLowerCase());

Expand Down Expand Up @@ -56,14 +60,12 @@ const testConfigs = [
},
{
componentsDir: '/src/components',
ignoredComponents: ['Field', 'Dialog', 'Icon', 'TextFieldBase', 'VisuallyHidden'],
packageDir: 'packages/web-react',
packageName: 'web-react',
},
// Disable web-twig tests for now on CI, because we don't have a way to run them in CI yet.
!isTestingEnvironment() && {
componentsDir: '/components',
ignoredComponents: ['Field', 'Icon', 'TextFieldBase', 'VisuallyHidden'],
packageDir: 'packages/web-twig',
packageName: 'web-twig',
srcDir: '/src/Resources',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.