Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0bc3c66
Add e2e config
catastrophe-brandon Aug 25, 2025
6de6cce
Basic e2e test setup working locally
catastrophe-brandon Aug 25, 2025
2b7cb9e
Check for 50 items of content
catastrophe-brandon Aug 27, 2025
645df13
Wrap up minimum Critical tests
catastrophe-brandon Aug 27, 2025
56ee7d0
Use branch with modified pipeline for running e2e
catastrophe-brandon Aug 27, 2025
5819657
Branch name fix
catastrophe-brandon Aug 27, 2025
2ddb1bb
Add e2e tests script to pipeline def
catastrophe-brandon Aug 28, 2025
b99af63
Konflux command for running against stage
catastrophe-brandon Aug 28, 2025
435e900
Running against stage
catastrophe-brandon Aug 28, 2025
7659235
Try a random flag that worked in insights-chrome
catastrophe-brandon Aug 28, 2025
3d76e11
New test command and hostnames added to taskRunTemplate
catastrophe-brandon Sep 2, 2025
2290040
Playwright test stub
catastrophe-brandon Oct 16, 2025
8c29b7a
fix spec name
catastrophe-brandon Oct 16, 2025
aac03fa
Add playwright/test to package.json
catastrophe-brandon Oct 16, 2025
bd9c4b9
Update package-lock
catastrophe-brandon Oct 16, 2025
f8c5417
Syntax pickiness
catastrophe-brandon Oct 16, 2025
ba3825c
Add login code
catastrophe-brandon Oct 16, 2025
0a4b2f6
fail quickly if proxy config is incorrect
catastrophe-brandon Oct 16, 2025
9bafbb6
Add custom message when assertion fails
catastrophe-brandon Oct 16, 2025
514d610
Fix some syntactical flubs
catastrophe-brandon Oct 16, 2025
aaf98b0
Adjust locators and variable names
catastrophe-brandon Oct 16, 2025
e3482a3
Update gitignore
catastrophe-brandon Oct 16, 2025
e1c82e2
Add check for failed login
catastrophe-brandon Oct 17, 2025
b84a475
Formalize test structure
catastrophe-brandon Oct 17, 2025
915e5f6
log page text
catastrophe-brandon Oct 17, 2025
13a7697
restore error handling
catastrophe-brandon Oct 17, 2025
516c5f9
WIP
catastrophe-brandon Oct 17, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ yarn-error.log*

.DS_Store
coverage

test-results
21 changes: 20 additions & 1 deletion .tekton/learning-resources-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
pipelinesascode.tekton.dev/max-keep-runs: "3"
pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch
== "master"
pipelinesascode.tekton.dev/pipeline: https://github.com/RedHatInsights/konflux-pipelines/raw/main/pipelines/platform-ui/docker-build-run-unit-tests.yaml
pipelinesascode.tekton.dev/pipeline: https://github.com/catastrophe-brandon/konflux-pipelines/raw/btweed/platform-ui-e2e/pipelines/platform-ui/docker-build-run-all-tests.yaml
creationTimestamp: null
labels:
appstudio.openshift.io/application: learning-resources
Expand Down Expand Up @@ -39,10 +39,29 @@ spec:
npm install
npm run lint
npm test -- --runInBand --no-cache
- name: e2e-tests-script
value: |
#!/usr/bin/env bash
set -ex
npm i >/dev/null 2>&1
KONFLUX_RUN=1 npm run start:konflux &
until curl -k 'https://stage.foo.redhat.com:1337' > /dev/null 2>&1; do
echo "Waiting for dev server to be ready"
sleep 5
done
echo "Dev server ready!"
KONFLUX_RUN=1 NO_COLOR=1 E2E_USER=$CHROME_ACCOUNT E2E_PASSWORD=$CHROME_PASSWORD npm run test:konflux
pipelineRef:
name: docker-build
taskRunTemplate:
serviceAccountName: build-pipeline-learning-resources
podTemplate:
hostAliases:
# Webpack explicitly binds to this address; don't remove or change this without careful consideration
- ip: "127.0.0.1"
hostnames:
- "stage.foo.redhat.com"
- "prod.foo.redhat.com"
workspaces:
- name: workspace
volumeClaimTemplate:
Expand Down
32 changes: 29 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
import { defineConfig } from "cypress";


export default defineConfig({
component: {
specPattern: 'cypress/component/**/*.cy.{js,jsx,ts,tsx}',
specPattern: "cypress/component/**/*.cy.{js,jsx,ts,tsx}",
devServer: {
framework: "react",
bundler: "webpack",
webpackConfig: require( './config/webpack.cy.js'),
webpackConfig: require("./config/webpack.cy.js"),
},
},

e2e: {
blockHosts: ['consent.trustarc.com'],
baseUrl: process.env.CYPRESS_BASE_URL || "https://stage.foo.redhat.com:1337",
env: {
E2E_USER: process.env.E2E_USER,
E2E_PASSWORD: process.env.E2E_PASSWORD,
},
// To avoid any flaky issues, we set the timeouts to be extra gracious
// Slow tests are faster than rerunning flaky tests
defaultCommandTimeout: 60000,
requestTimeout: 60000,
// required for the redirects to work correctly due to a chromium issue
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
screenshotOnRunFailure: false,
// required for the SSO redirect
chromeWebSecurity: false,
video: false,
// setupNodeEvents(on, config) {
// require('cypress-localstorage-commands/plugin')(on, config);
// return config;
// // implement node event listeners here
// },
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
47 changes: 47 additions & 0 deletions cypress/e2e/release-gate/all-learning-resources.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@


describe('All Learning Resources', () => {

it('appears in the help menu and the link works', () => {
cy.login();
cy.get('#HelpMenu').click().contains('All learning resources').click();
cy.url().should('include','/learning-resources');
});

it('has the appropriate number of items on the tab', () => {

cy.intercept('GET', '/api/quickstarts/v1/quickstarts?*').as('getQuickstarts');
// go to All Learning Resources page
cy.login();
cy.visit('/learning-resources');

// wait until the page has fully loaded with quickstarts data
cy.wait("@getQuickstarts").then((intercept) => {
expect(intercept.response.statusCode).to.eq(200)});

// confirm that 50 items appear on the 'All learning resources' tab
// Note: An ID would be a better way to locate the element
cy.get('.pf-v6-c-tabs__item-text').contains('All learning resources').then(elem => {
console.log(elem.text());
const tabText = elem.text();
expect(tabText).to.contain('50');
})
});

// == The following tests are prio 2 and can be implemented at a later time

it.skip('appears in search results', () => {});

it.skip('performs basic filtering by name', () => {});

it.skip('filters by product family', () => {});

it.skip('filters by console-wide services', () => {});

it.skip('filters by content type', () => {});

it.skip('filters by use case', () => {});

it.skip('displays bookmarked resources', () => {});

})
30 changes: 29 additions & 1 deletion cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,32 @@
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
// }

Cypress.Commands.add('login', () => {
cy.session(
`login-${Cypress.env('E2E_USER')}`,
() => {
cy.intercept({ url: '/beta/apps/*', times: 1 }, {});
cy.intercept({ url: '/api/', times: 4 }, {});
// This JS file causes randomly an uncaught exception on login page which blocks the tests
// Cannot read properties of undefined (reading 'setAttribute')
cy.intercept({ url: 'https://sso.stage.redhat.com/auth/resources/0833r/login/rhd-theme/dist/pfelements/bundle.js' }, {});
cy.visit('/');
// disable analytics integrations
// cy.setLocalStorage('chrome:analytics:disable', 'true');
// cy.setLocalStorage('chrome:segment:disable', 'true');

cy.wait(1000);
// login into the session

cy.get('body').then(() => {
cy.get('#username-verification').type(Cypress.env('E2E_USER'));
cy.get('#login-show-step2').click();
cy.get('#password').type(Cypress.env('E2E_PASSWORD'));
cy.get('#rh-password-verification-submit-button').click();
});
},
{ cacheAcrossSpecs: true }
);
});
1 change: 1 addition & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
login(): Chainable<void>
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"lint:js:fix": "eslint src --fix",
"patch:hosts": "fec patch-etc-hosts",
"start": "HOT=true fec dev",
"start:konflux": "HOT=true fec dev --clouddotEnv=stage",
"static": "fec static",
"test": "TZ=UTC jest --verbose --no-cache --passWithNoTests",
"test:konflux": "npx cypress run --env CLOUDDOT_ENV=stage --spec cypress/e2e/release-gate/**/*",
"verify": "npm-run-all build lint test",
"postinstall": "ts-patch install"
},
Expand Down Expand Up @@ -54,6 +55,7 @@
"jest_workaround": "^0.79.19",
"jest-environment-jsdom": "^29.7.0",
"npm-run-all": "4.1.5",
"@playwright/test": "^1.43.1",
"ts-jest": "^29.1.1",
"ts-patch": "^3.1.2",
"typescript": "^5.3.3",
Expand Down
34 changes: 34 additions & 0 deletions playwright/all-learning-resources.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Page, test, expect } from '@playwright/test';


async function login(page: Page, user: string, password: string): Promise<void> {
// Fail in a friendly way if the proxy config is not set up correctly
await expect(page.locator("text=Lockdown"), 'proxy config incorrect').toHaveCount(0)
await page.getByLabel('Red Hat login').first().fill(user);
await page.getByRole('button', { name: 'Next' }).click();
await page.getByLabel('Password').first().fill(password);
await page.getByRole('button', { name: 'Log in' }).click();
// confirm login was valid
await expect(page.getByText('Invalid login')).not.toBeVisible();
}

test.describe('all learning resources', async () => {

test.beforeEach(async ({page}): Promise<void> => {
await page.goto('https://console.stage.redhat.com');
const user = process.env.E2E_USER || 'misconfigured';
const password = process.env.E2E_PASSWORD || 'misconfigured';
await login(page, user, password);
await page.waitForLoadState("load");
await expect(page.getByText('Invalid login')).not.toBeVisible();
});

test('appears in the help menu and the link works', async({page}) => {
await expect(page.getByRole('button', { name: 'Add widgets' }), 'dashboard not displayed').toBeVisible();
});
});