Skip to content

Commit

Permalink
Merge pull request opendatahub-io#2859 from christianvogt/e2e
Browse files Browse the repository at this point in the history
update cypress for e2e live cluster testing
  • Loading branch information
openshift-merge-bot[bot] authored May 30, 2024
2 parents 20d69a2 + f58597f commit 7048a18
Show file tree
Hide file tree
Showing 84 changed files with 164 additions and 121 deletions.
5 changes: 3 additions & 2 deletions frontend/.env.cypress
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BASE_URL=http://localhost:4010
USERNAME=regularuser1
PASSWORD=developer
LOGIN_USERNAME=regularuser1
LOGIN_PASSWORD=developer
LOGIN_PROVIDER=htpasswd
14 changes: 14 additions & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@
"plugin:prettier/recommended",
"prettier",
"plugin:cypress/recommended"
],
"overrides": [
{
"files": ["./src/__tests__/cypress/cypress/pages/*.ts", "./src/__tests__/cypress/cypress/tests/e2e/*.ts"],
"rules": {
"no-restricted-syntax": [
"error",
{
"selector": "CallExpression[callee.property.name='visit'][callee.object.name='cy']",
"message": "Use `cy.visitWithLogin` in page objects and e2e tests instead of `cy.visit`."
}
]
}
}
]
},
{
Expand Down
30 changes: 16 additions & 14 deletions frontend/src/__tests__/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import coverage from '@cypress/code-coverage/task';
import { interceptSnapshotFile } from '~/__tests__/cypress/cypress/utils/snapshotUtils';
import { setup as setupWebsockets } from '~/__tests__/cypress/cypress/support/websockets';

dotenv.config({
path: path.resolve(__dirname, '../../../.env'),
});
dotenv.config({
path: path.resolve(__dirname, `../../../.env.cypress${process.env.MOCK ? '.mock' : ''}`),
});
dotenv.config({
path: path.resolve(__dirname, `../../../.env.cypress${process.env.MOCK ? '.mock' : ''}.local`),
});
[
`.env.cypress${process.env.MOCK ? '.mock' : ''}.local`,
`.env.cypress${process.env.MOCK ? '.mock' : ''}`,
'.env.local',
'.env',
].forEach((file) =>
dotenv.config({
path: path.resolve(__dirname, '../../../', file),
}),
);

export default defineConfig({
chromeWebSecurity: false,
Expand All @@ -23,8 +24,9 @@ export default defineConfig({
numTestsKeptInMemory: 1,
env: {
MOCK: !!process.env.MOCK,
USERNAME: process.env.USERNAME,
PASSWORD: process.env.PASSWORD,
LOGIN_USERNAME: process.env.LOGIN_USERNAME,
LOGIN_PASSWORD: process.env.LOGIN_PASSWORD,
LOGIN_PROVIDER: process.env.LOGIN_PROVIDER,
RECORD: !!process.env.RECORD,
WS_PORT: process.env.WS_PORT,
coverage: !!process.env.COVERAGE,
Expand All @@ -37,10 +39,10 @@ export default defineConfig({
e2e: {
baseUrl: process.env.BASE_URL,
specPattern: process.env.MOCK
? `cypress/e2e/**/*.cy.ts`
? `cypress/tests/mocked/**/*.cy.ts`
: process.env.RECORD
? `cypress/e2e/**/*.scy.ts`
: `cypress/e2e/**/*.(s)?cy.ts`,
? `cypress/tests/mocked/**/*.scy.ts`
: `cypress/tests/e2e/**/*.cy.ts`,
experimentalInteractiveRunEvents: true,
setupNodeEvents(on, config) {
coverage(on, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TolerationRow extends TableRow {

class AcceleratorProfile {
visit() {
cy.visit('/acceleratorProfiles');
cy.visitWithLogin('/acceleratorProfiles');
this.wait();
}

Expand Down Expand Up @@ -198,7 +198,7 @@ class TolerationsModal extends Modal {

class CreateAcceleratorProfile extends ManageAcceleratorProfile {
visit() {
cy.visit('/acceleratorProfiles/Create');
cy.visitWithLogin('/acceleratorProfiles/Create');
this.wait();
}

Expand All @@ -210,7 +210,7 @@ class CreateAcceleratorProfile extends ManageAcceleratorProfile {

class EditAcceleratorProfile extends ManageAcceleratorProfile {
visit(name: string) {
cy.visit(`/acceleratorProfiles/edit/${name}`);
cy.visitWithLogin(`/acceleratorProfiles/edit/${name}`);
cy.testA11y();
}

Expand All @@ -225,7 +225,7 @@ class EditAcceleratorProfile extends ManageAcceleratorProfile {

class IdentifierAcceleratorProfile extends ManageAcceleratorProfile {
visit(multiple = false) {
cy.visit(
cy.visitWithLogin(
multiple
? `/acceleratorProfiles/create?identifiers=test-identifier%2Ctest-identifier2`
: `/acceleratorProfiles/create?identifiers=test-identifier`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TableRow } from './components/table';

class NotebookController {
visit() {
cy.visit('/notebookController/spawner');
cy.visitWithLogin('/notebookController/spawner');
this.wait();
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__tests__/cypress/cypress/pages/appChrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApplicationLauncher } from './appLauncher';

class AppChrome {
visit() {
cy.visit('/');
cy.visitWithLogin('/');
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { appChrome } from '~/__tests__/cypress/cypress/pages/appChrome';

class ClusterSettings {
visit(wait = true) {
cy.visit('/clusterSettings');
cy.visitWithLogin('/clusterSettings');
if (wait) {
this.wait();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ClusterStorageModal extends Modal {

class ClusterStorage {
visit(projectName: string) {
cy.visit(`/projects/${projectName}?section=cluster-storages`);
cy.visitWithLogin(`/projects/${projectName}?section=cluster-storages`);
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RefreshIntervalTitle } from '~/concepts/metrics/types';

class GlobalDistributedWorkloads {
visit(wait = true) {
cy.visit(`/distributedWorkloads`);
cy.visitWithLogin(`/distributedWorkloads`);
if (wait) {
this.wait();
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__tests__/cypress/cypress/pages/enabled.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class EnabledPage {
visit() {
cy.visit('/enabled');
cy.visitWithLogin('/enabled');
this.wait();
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__tests__/cypress/cypress/pages/explore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ExplorePage {
visit() {
cy.visit('/explore');
cy.visitWithLogin('/explore');
this.wait();
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__tests__/cypress/cypress/pages/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { mockDashboardConfig } from '~/__mocks__';

class HomePage {
visit() {
cy.visit('/');
cy.visitWithLogin('/');
this.wait();
}

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/__tests__/cypress/cypress/pages/modelMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ModelMetricsChart extends Contextual<HTMLTableRowElement> {

class ModelMetricsPerformance extends ModelMetricsGlobal {
visit(project: string, model: string) {
cy.visit(`/modelServing/${project}/metrics/${model}/performance`);
cy.visitWithLogin(`/modelServing/${project}/metrics/${model}/performance`);
this.wait();
}

Expand All @@ -44,7 +44,7 @@ class ModelMetricsPerformance extends ModelMetricsGlobal {

class ModelMetricsBias extends ModelMetricsGlobal {
visit(project: string, model: string, disableA11y = false) {
cy.visit(`/modelServing/${project}/metrics/${model}/bias`);
cy.visitWithLogin(`/modelServing/${project}/metrics/${model}/bias`);

// TODO: disableA11y should be removed once this PF bug is resolved: https://github.com/patternfly/patternfly-react/issues/9968
this.wait(disableA11y);
Expand Down Expand Up @@ -85,7 +85,7 @@ class ModelMetricsBias extends ModelMetricsGlobal {

class ServerMetrics extends ModelMetricsGlobal {
visit(project: string, server: string) {
cy.visit(`/projects/${project}/metrics/server/${server}`);
cy.visitWithLogin(`/projects/${project}/metrics/server/${server}`);
this.wait();
}

Expand All @@ -97,7 +97,7 @@ class ServerMetrics extends ModelMetricsGlobal {

class ModelMetricsConfigureSection {
visit(project: string, model: string) {
cy.visit(`/modelServing/${project}/metrics/${model}/configure`);
cy.visitWithLogin(`/modelServing/${project}/metrics/${model}/configure`);
this.wait();
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/__tests__/cypress/cypress/pages/modelRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ class ModelRegistryTableRow extends TableRow {

class ModelRegistry {
landingPage() {
cy.visit('/');
cy.visitWithLogin('/');
this.waitLanding();
}

visit() {
cy.visit(`/modelRegistry`);
cy.visitWithLogin(`/modelRegistry`);
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,21 @@ class ModelVersionArchive {
}

visit() {
cy.visit(modelVersionArchiveUrl('1', 'modelregistry-sample'));
cy.visitWithLogin(modelVersionArchiveUrl('1', 'modelregistry-sample'));
this.wait();
}

visitArchiveVersionDetail() {
cy.visit(modelVersionArchiveDetailsUrl('2', '1', 'modelregistry-sample'));
cy.visitWithLogin(modelVersionArchiveDetailsUrl('2', '1', 'modelregistry-sample'));
}

visitModelVersionList() {
cy.visit(modelVersionListUrl('1', 'modelregistry-sample'));
cy.visitWithLogin(modelVersionListUrl('1', 'modelregistry-sample'));
this.wait();
}

visitModelVersionDetails() {
cy.visit(modelVersionUrl('3', '1', 'modelregistry-sample'));
cy.visitWithLogin(modelVersionUrl('3', '1', 'modelregistry-sample'));
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { modelVersionUrl } from '~/pages/modelRegistry/screens/routeUtils';

class ModelVersionDetails {
visit() {
cy.visit(modelVersionUrl('1', '1', 'modelregistry-sample'));
cy.visitWithLogin(modelVersionUrl('1', '1', 'modelregistry-sample'));
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { appChrome } from './appChrome';

class ModelRegistrySettings {
visit(wait = true) {
cy.visit('/modelRegistrySettings');
cy.visitWithLogin('/modelRegistrySettings');
if (wait) {
this.wait();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TableToolbar } from './components/TableToolbar';
class ModelServingToolbar extends TableToolbar {}
class ModelServingGlobal {
visit(project?: string) {
cy.visit(`/modelServing${project ? `/${project}` : ''}`);
cy.visitWithLogin(`/modelServing${project ? `/${project}` : ''}`);
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NotebookImageSettingsTableToolbar extends TableToolbar {}

class NotebookImageSettings {
visit(wait = true) {
cy.visit('/notebookImages');
cy.visitWithLogin('/notebookImages');
if (wait) {
this.wait();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class NotebookServer {
visit() {
cy.visit('/notebookController/spawner');
cy.visitWithLogin('/notebookController/spawner');
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PageNotFound {
visit() {
cy.visit(`/force-not-found-page`);
cy.visitWithLogin(`/force-not-found-page`);
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PermissionsTableRow extends TableRow {}

class PermissionsTab {
visit(projectName: string) {
cy.visit(`/projects/${projectName}?section=permissions`);
cy.visitWithLogin(`/projects/${projectName}?section=permissions`);
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { TableRow } from '~/__tests__/cypress/cypress/pages/components/table';

class CompareRunsGlobal {
visit(projectName: string, experimentId: string, runIds: string[] = []) {
cy.visit(`/experiments/${projectName}/${experimentId}/compareRuns?runs=${runIds.join(',')}`);
cy.visitWithLogin(
`/experiments/${projectName}/${experimentId}/compareRuns?runs=${runIds.join(',')}`,
);
}

findInvalidRunsError() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TableRow } from '~/__tests__/cypress/cypress/pages/components/table';

class ExperimentsTabs {
visit(namespace?: string, tab?: string) {
cy.visit(`/experiments${namespace ? `/${namespace}` : ''}${tab ? `/${tab}` : ''}`);
cy.visitWithLogin(`/experiments${namespace ? `/${namespace}` : ''}${tab ? `/${tab}` : ''}`);
this.wait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TableRow } from '~/__tests__/cypress/cypress/pages/components/table';

class ManageRunsPage {
visit(experimentId: string, projectName: string, runIds: string[]) {
cy.visit(
cy.visitWithLogin(
`/experiments/${projectName}/${experimentId}/compareRuns/add?runs=${runIds.join(',')}`,
);
this.wait();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeleteModal } from '~/__tests__/cypress/cypress/pages/components/Delete

class PipelineRunsGlobal {
visit(projectName: string, runType?: 'active' | 'archived' | 'scheduled') {
cy.visit(
cy.visitWithLogin(
`/pipelineRuns/${projectName}${
runType ? `?${PipelineRunSearchParam.RunType}=${runType}` : ''
}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Modal } from '~/__tests__/cypress/cypress/pages/components/Modal';

class PipelinesGlobal {
visit(projectName: string) {
cy.visit(`/pipelines/${projectName}`);
cy.visitWithLogin(`/pipelines/${projectName}`);
this.wait();
}

Expand Down
Loading

0 comments on commit 7048a18

Please sign in to comment.