Skip to content

Commit 7179209

Browse files
committed
add env flag to allow skip
1 parent 99e1211 commit 7179209

3 files changed

Lines changed: 29 additions & 22 deletions

File tree

cypress.config.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,25 @@ export default defineConfig({
8989
'pkg/rancher-components/src/components/**/*.{vue,ts,js}',
9090
]
9191
},
92-
api: apiUrl,
92+
api: apiUrl,
9393
username,
94-
password: process.env.CATTLE_BOOTSTRAP_PASSWORD || process.env.TEST_PASSWORD,
95-
bootstrapPassword: process.env.CATTLE_BOOTSTRAP_PASSWORD,
96-
grepTags: process.env.GREP_TAGS,
97-
VAI_ENABLED: process.env.VAI_ENABLED,
94+
password: process.env.CATTLE_BOOTSTRAP_PASSWORD || process.env.TEST_PASSWORD,
95+
bootstrapPassword: process.env.CATTLE_BOOTSTRAP_PASSWORD,
96+
grepTags: process.env.GREP_TAGS,
97+
VAI_ENABLED: process.env.VAI_ENABLED,
9898
// the below env vars are only available to tests that run in Jenkins
99-
awsAccessKey: process.env.AWS_ACCESS_KEY_ID,
100-
awsSecretKey: process.env.AWS_SECRET_ACCESS_KEY,
101-
azureSubscriptionId: process.env.AZURE_AKS_SUBSCRIPTION_ID,
102-
azureClientId: process.env.AZURE_CLIENT_ID,
103-
azureClientSecret: process.env.AZURE_CLIENT_SECRET,
104-
customNodeIp: process.env.CUSTOM_NODE_IP,
105-
customNodeKey: process.env.CUSTOM_NODE_KEY,
106-
accessibility: !!process.env.TEST_A11Y, // Are we running accessibility tests?
107-
a11yFolder: path.join('.', 'cypress', 'accessibility'),
108-
gkeServiceAccount: process.env.GKE_SERVICE_ACCOUNT,
99+
awsAccessKey: process.env.AWS_ACCESS_KEY_ID,
100+
awsSecretKey: process.env.AWS_SECRET_ACCESS_KEY,
101+
azureSubscriptionId: process.env.AZURE_AKS_SUBSCRIPTION_ID,
102+
azureClientId: process.env.AZURE_CLIENT_ID,
103+
azureClientSecret: process.env.AZURE_CLIENT_SECRET,
104+
customNodeIp: process.env.CUSTOM_NODE_IP,
105+
customNodeKey: process.env.CUSTOM_NODE_KEY,
106+
accessibility: !!process.env.TEST_A11Y, // Are we running accessibility tests?
107+
a11yFolder: path.join('.', 'cypress', 'accessibility'),
108+
gkeServiceAccount: process.env.GKE_SERVICE_ACCOUNT,
109+
// Set to 'true' to allow skipping when a chart is filtered from the UI catalog.
110+
allowFilteredCatalogSkip: process.env.CYPRESS_ALLOW_FILTERED_CATALOG_SKIP,
109111
},
110112
e2e: {
111113
fixturesFolder: 'cypress/e2e/blueprints',

cypress/e2e/tests/pages/charts/compliance.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ describe('Charts', { testIsolation: 'off', tags: ['@charts', '@adminUser'] }, ()
100100
const chartApp = 'rancher-compliance';
101101
const chartCrd = 'rancher-compliance-crd';
102102

103-
cy.createRancherResource('v1', `catalog.cattle.io.apps/${ chartNamespace }/${ chartApp }?action=uninstall`, '{}');
104-
cy.createRancherResource('v1', `catalog.cattle.io.apps/${ chartNamespace }/${ chartCrd }?action=uninstall`, '{}');
103+
cy.createRancherResource('v1', `catalog.cattle.io.apps/${ chartNamespace }/${ chartApp }?action=uninstall`, '{}', false);
104+
cy.createRancherResource('v1', `catalog.cattle.io.apps/${ chartNamespace }/${ chartCrd }?action=uninstall`, '{}', false);
105105
cy.updateNamespaceFilter('local', 'none', '{"local":["all://user"]}');
106106
});
107107
});

cypress/support/commands/rancher-api-commands.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,9 +1458,10 @@ Cypress.Commands.add('checkChartPresence', (repoName: string, chartKey: string)
14581458
});
14591459

14601460
/**
1461-
* Runs the given callback only when the chart is available in the filtered catalog index.
1462-
* Skips the test when the chart exists in the catalog but is filtered out intentionally (e.g. based on k8s or Rancher annotations).
1463-
* Throws when the chart is missing from the unfiltered index (publishing/sync issue).
1461+
* Runs `callback` when `chartKey` is present in the filtered catalog index (the list the Charts UI uses).
1462+
* Throws error if the chart is missing from the unfiltered index — that points to catalog publish or sync, not compatibility filtering.
1463+
* If the chart is in the unfiltered index but not the filtered index, skips when Cypress env `allowFilteredCatalogSkip`
1464+
* is enabled; otherwise throws error.
14641465
*/
14651466
export function runTestWhenChartAvailable(
14661467
repo: string,
@@ -1474,9 +1475,13 @@ export function runTestWhenChartAvailable(
14741475
}
14751476

14761477
if (!inFiltered) {
1477-
cy.log(`Skipping: chart '${ chartKey }' is intentionally hidden from the filtered catalog index`);
1478+
if (String(Cypress.env('allowFilteredCatalogSkip')).toLowerCase() === 'true') {
1479+
cy.log(`Skipping: chart '${ chartKey }' is intentionally hidden from the filtered catalog index`);
14781480

1479-
return mochaContext.skip();
1481+
return mochaContext.skip();
1482+
}
1483+
1484+
throw new Error(`Failing: chart '${ chartKey }' is not in the filtered catalog index, so it does not appear in the Charts/Tools UI for this environment.`);
14801485
}
14811486

14821487
callback();

0 commit comments

Comments
 (0)