Skip to content

Commit

Permalink
chore(testing): sw-722 dist route checks for ephemeral (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Dec 16, 2022
1 parent 805a4a2 commit 38cdc34
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/__snapshots__/dist.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Build distribution should have a predictable ephemeral navigation based on route configuration: expected covered, missing routes 1`] = `
[
{
"coverage": "TRUE",
"path": "/rhel",
"productParameter": [
"RHEL",
],
},
{
"coverage": "TRUE",
"path": "/openshift-container",
"productParameter": [
"OpenShift Container Platform",
"OpenShift-metrics",
],
},
{
"coverage": "TRUE",
"path": "/openshift-dedicated",
"productParameter": [
"OpenShift-dedicated-metrics",
],
},
{
"coverage": "FALSE",
"path": "/rhacs",
"productParameter": [
"rhacs",
],
},
{
"coverage": "TRUE",
"path": "/rhods",
"productParameter": [
"rhods",
],
},
{
"coverage": "TRUE",
"path": "/streams",
"productParameter": [
"rhosak",
],
},
{
"coverage": "TRUE",
"path": "/satellite",
"productParameter": [
"Satellite",
],
},
{
"coverage": "FALSE",
"path": "/optin",
"productParameter": null,
},
{
"coverage": "FALSE",
"path": "/",
"productParameter": null,
},
]
`;

exports[`Build distribution should match a specific file output 1`] = `
[
"",
Expand Down
21 changes: 21 additions & 0 deletions tests/dist.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { routes } from '../src/config/routes';
const { execSync } = require('child_process');

describe('Build distribution', () => {
Expand All @@ -24,4 +25,24 @@ describe('Build distribution', () => {

expect(Number.parseInt(output.trim(), 10)).toBe(0);
});

it('should have a predictable ephemeral navigation based on route configuration', () => {
const yamlFile = `./deploy/frontend.yaml`;
const output = execSync(`yaml2json ${yamlFile}`);
const yamlObj = JSON.parse(output.toString());
const yamlRoutes = yamlObj.objects[0].spec.navItems[0].routes;

expect(
routes.map(({ path, productParameter }) => {
const updatedRoute = { path, productParameter, coverage: 'FALSE' };
const match = yamlRoutes.find(({ href }) => href.split('subscriptions')[1] === path);

if (match) {
updatedRoute.coverage = 'TRUE';
}

return updatedRoute;
})
).toMatchSnapshot('expected covered, missing routes');
});
});

0 comments on commit 38cdc34

Please sign in to comment.