-
Notifications
You must be signed in to change notification settings - Fork 596
/
project.ts
56 lines (50 loc) · 1.88 KB
/
project.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { detailsPage } from '../views/details-page';
import { listPage } from '../views/list-page';
import { modal } from '../views/modal';
declare global {
namespace Cypress {
interface Chainable {
createProject(name: string): Chainable<Element>;
createProjectWithCLI(name: string): Chainable<Element>;
deleteProject(name: string): Chainable<Element>;
deleteProjectWithCLI(name: string): Chainable<Element>;
}
}
}
// any command added below, must be added to global Cypress interface above
// This will add to 'createProject(...)' to cy
// ex: cy.createProject(name)
Cypress.Commands.add('createProject', (name: string, devConsole: boolean = false) => {
cy.log(`create project`);
cy.visit(`/k8s/cluster/projects`).its('yaml-create').should('be.visible');
listPage.clickCreateYAMLbutton();
modal.shouldBeOpened();
cy.byTestID('input-name').click().type(name);
cy.testA11y('Create Project modal');
modal.submit();
modal.shouldBeClosed();
// TODO, switch to 'listPage.titleShouldHaveText(name)', when we switch to new test id
if (devConsole === false) {
cy.byLegacyTestID('resource-title').should('have.text', name);
}
});
Cypress.Commands.add('createProjectWithCLI', (name: string) => {
cy.exec(`oc new-project ${name}`);
});
Cypress.Commands.add('deleteProject', (name: string) => {
cy.log(`delete project`);
cy.visit(`/k8s/cluster/projects/${name}`);
detailsPage.isLoaded();
detailsPage.clickPageActionFromDropdown('Delete Project');
modal.shouldBeOpened();
modal.submitShouldBeDisabled();
cy.byTestID('project-name-input').type(name);
modal.submitShouldBeEnabled();
cy.testA11y('Delete Project modal');
modal.submit();
modal.shouldBeClosed();
listPage.titleShouldHaveText('Projects');
});
Cypress.Commands.add('deleteProjectWithCLI', (name: string, timeout?: number) => {
cy.exec(`oc delete project ${name}`, { timeout });
});