Skip to content

Commit

Permalink
cypress - better logging in headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaylor113 committed Sep 10, 2020
1 parent 48f468b commit 84af560
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"reportFilename": "cypress_report",
"overwrite": false,
"html": false,
"json": true
"json": true,
"quiet" : true
}
}
6 changes: 3 additions & 3 deletions frontend/packages/integration-tests-cypress/support/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const KUBEADMIN_IDP = 'kube:admin';
Cypress.Commands.add('login', (provider: string, username: string, password: string) => {
// if local, no need to login
if (!Cypress.env('BRIDGE_KUBEADMIN_PASSWORD')) {
cy.task('log', 'No BRIDGE_KUBEADMIN_PASSWORD set, skipping login');
cy.task('log', ' skipping login, no BRIDGE_KUBEADMIN_PASSWORD set');
return;
}
const idp = provider || KUBEADMIN_IDP;
cy.task('log', ` Logging into IDP ${idp}, using baseUrl ${Cypress.config('baseUrl')}`);
cy.task('log', ` Logging in as ${idp}`);
cy.visit(''); // visits baseUrl which is set in plugins/index.js
cy.byLegacyTestID('login').should('be.visible');
cy.contains(idp)
Expand All @@ -38,7 +38,7 @@ Cypress.Commands.add('login', (provider: string, username: string, password: str

Cypress.Commands.add('logout', () => {
if (!Cypress.env('BRIDGE_KUBEADMIN_PASSWORD')) {
cy.task('log', 'No BRIDGE_KUBEADMIN_PASSWORD set, skipping logout');
cy.task('log', ' skipping logout');
return;
}
cy.task('log', ' Logging out');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare global {
// This will add to 'createProject(...)' to cy
// ex: cy.createProject(name)
Cypress.Commands.add('createProject', (name: string) => {
cy.log(`create project`);
cy.visit(`/k8s/cluster/projects`);
listPage.clickCreateYAMLbutton();
modal.shouldBeOpened();
Expand All @@ -27,6 +28,7 @@ Cypress.Commands.add('createProject', (name: string) => {
});

Cypress.Commands.add('deleteProject', (name: string) => {
cy.log(`delete project`);
cy.visit(`/k8s/cluster/projects/${name}`);
detailsPage.clickPageActionFromDropdown('Delete Project');
modal.shouldBeOpened();
Expand Down
10 changes: 3 additions & 7 deletions frontend/packages/integration-tests-cypress/support/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,12 @@ Cypress.Commands.add(
)
.then((result) => {
if (result.code !== 0) {
if (result.stderr.includes('NotFound')) {
cy.log(
`'oc get -n ${namespace} ${resource}/${name}' returned 'NotFound' indicating resource was successfully deleted`,
);
} else {
// this typically would be a 'You must be logged in to the server (Unauthorized)'
// if stderr === NotFound, means resource was succesfully deleted
if (!result.stderr.includes('NotFound')) {
// error other than 'NotFound', this typically would be a 'You must be logged in to the server (Unauthorized)'
assert.fail('', '', `Error during 'oc get ${resource}/${name}', ${result.stderr} `);
}
} else {
cy.log(`expect ${resource}/${name} to have a deletionTimestamp`);
expect(result.stdout).not.toContain(`<no value>`);
}
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('Kubernetes resource CRUD operations', () => {
safeLoad(content),
);
yamlEditor.setEditorContent(safeDump(newContent, { sortKeys: true }));
cy.log('creates a new resource instance');
// create new resource instance
yamlEditor.clickSaveCreateButton();
cy.get(errorMessage).should('not.exist');
});
Expand All @@ -111,11 +111,11 @@ describe('Kubernetes resource CRUD operations', () => {
`${namespaced ? `/k8s/ns/${testName}` : '/k8s/cluster'}/${resource}?name=${testName}`,
);
if (namespaced) {
cy.log('has a working namespace dropdown on namespaced objects');
// should have a namespace dropdown for namespaced objects');
listPage.projectDropdownShouldExist();
listPage.projectDropdownShouldContain(testName);
} else {
cy.log('does not have a namespace dropdown on non-namespaced objects');
// should not have a namespace dropdown for non-namespaced objects');
listPage.projectDropdownShouldNotExist();
}
listPage.rows.shouldBeLoaded();
Expand All @@ -134,7 +134,7 @@ describe('Kubernetes resource CRUD operations', () => {
listPage.rows.shouldExist(name);
cy.testA11y(`Search page for ${kind}: ${name}`);

cy.log('link to to details page');
// link to to details page
listPage.rows.clickRowByName(name);
cy.url().should('include', `/${name}`);
detailsPage.titleShouldContain(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Monitoring: Alerts', () => {
});

it('displays and filters the Alerts list page, links to detail pages', () => {
cy.log('use vert. nav. menu to goto Monitoring -> Alerting');
cy.log('use sidebar nav to goto Monitoring -> Alerting');
nav.sidenav.clickNavLink(['Monitoring', 'Alerting']);
// TODO, switch to 'listPage.titleShouldHaveText('Alerting');', when we switch to new test id
cy.byLegacyTestID('resource-title').should('have.text', 'Alerting');
Expand Down
2 changes: 1 addition & 1 deletion test-prow-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ INSTALLER_DIR=${INSTALLER_DIR:=${ARTIFACT_DIR}/installer}
function copyArtifacts {
if [ -d "$ARTIFACT_DIR" ] && [ -d "$SCREENSHOTS_DIR" ]; then
echo "Copying artifacts from $(pwd)..."
cp -rv "$SCREENSHOTS_DIR" "${ARTIFACT_DIR}/gui_test_screenshots"
cp -r "$SCREENSHOTS_DIR" "${ARTIFACT_DIR}/gui_test_screenshots"
fi
}

Expand Down

0 comments on commit 84af560

Please sign in to comment.