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

Add e2e test for job clone bug #10940

Merged
merged 1 commit into from
May 7, 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
17 changes: 11 additions & 6 deletions cypress/e2e/po/pages/explorer/workloads-jobs.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ export class WorkloadsJobsListPagePo extends PagePo {
super(WorkloadsJobsListPagePo.createPath(clusterId));
}

listCreate() {
const baseResourceList = new BaseResourceList(this.self());
list() {
return new BaseResourceList(this.self());
}

return baseResourceList.masthead().actions().eq(0).click();
listCreate() {
return this.list().masthead().actions().eq(0)
.click();
}

listElementWithName(name:string) {
const baseResourceList = new BaseResourceList(this.self());

return baseResourceList.resourceTable().sortableTable().rowElementWithName(name);
return this.list().resourceTable().sortableTable().rowElementWithName(name);
}
}

Expand Down Expand Up @@ -77,4 +78,8 @@ export class WorkLoadsJobDetailsPagePo extends PagePo {
saveCreateForm(): AsyncButtonPo {
return new AsyncButtonPo('[data-testid="form-save"]', this.self());
}

errorBanner() {
return cy.get('#cru-errors');
}
}
49 changes: 44 additions & 5 deletions cypress/e2e/tests/pages/explorer/workloads/jobs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ describe('Cluster Explorer', { tags: ['@explorer', '@adminUser'] }, () => {

describe('Workloads', () => {
describe('Jobs', () => {
it('Creating a job while creating a new namespace should succeed', () => {
const namespaceName = 'custom-namespace';
const jobName = 'my-job-custom-name';
const containerImageName = 'nginx';
const namespaceName = 'custom-namespace';
const jobName = 'my-job-custom-name';
const containerImageName = 'nginx';

after(() => {
// Delete the namespace created after the tests run
cy.deleteRancherResource('v1', 'namespace', namespaceName);
});

it('Creating a job while creating a new namespace should succeed', () => {
// list view jobs
const workloadsJobsListPage = new WorkloadsJobsListPagePo('local');

Expand All @@ -29,10 +34,44 @@ describe('Cluster Explorer', { tags: ['@explorer', '@adminUser'] }, () => {

workloadsJobsListPage.listElementWithName(jobName).should('exist');

// navigate to namespace and check existance of namespace
// navigate to namespace and check existence of namespace
cy.visit('/c/local/explorer/projectsnamespaces');
workloadsJobsListPage.listElementWithName(namespaceName).should('exist');
});

it('Should be able to clone a job', () => {
const jobName2 = `${ jobName }-2`;
const jobNameClone = `${ jobName }-3`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would these names possibly collision on a Cypress retry? Otherwise this overall looks good to me.


// list view jobs
const workloadsJobsListPage = new WorkloadsJobsListPagePo('local');

workloadsJobsListPage.goTo();
workloadsJobsListPage.listCreate();

// create view jobs
const workloadsJobDetailsPage = new WorkLoadsJobDetailsPagePo('local');

workloadsJobDetailsPage.selectNamespaceOption(1);
workloadsJobDetailsPage.namespace().set(namespaceName);
workloadsJobDetailsPage.name().set(jobName2);
workloadsJobDetailsPage.containerImage().set(containerImageName);
workloadsJobDetailsPage.saveCreateForm().click();

workloadsJobsListPage.listElementWithName(jobName2).should('exist');

// Clone the job
workloadsJobsListPage.list().actionMenu(jobName2).getMenuItem('Clone').click();

const cloneJobDetailsPage = new WorkLoadsJobDetailsPagePo(jobName2, {}, 'local', namespaceName);

cloneJobDetailsPage.waitForPage();
cloneJobDetailsPage.name().set(jobNameClone);
cloneJobDetailsPage.saveCreateForm().click();
cloneJobDetailsPage.errorBanner().should('not.exist');

workloadsJobsListPage.listElementWithName(jobNameClone).should('exist');
});
});
});
});
Loading