Skip to content

Commit

Permalink
Use dedicated projects for integration tests (#422)
Browse files Browse the repository at this point in the history
* Use dedicated projects for integration tests

* Remove environment variable definitions
  • Loading branch information
csvtuda authored Dec 20, 2024
1 parent 00a2c3a commit 4c03927
Show file tree
Hide file tree
Showing 128 changed files with 3,891 additions and 1,019 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,13 @@ dist
.yarn/install-state.gz
.pnp.*

# ================================================================================================ #
# Project-specific ignores.
# ================================================================================================ #

unit.xml
integration.xml
integration.xml

test/**/cypress.env.json
test/**/cucumber-report.json
test/**/*.png
176 changes: 0 additions & 176 deletions test/integration/282.spec.ts

This file was deleted.

70 changes: 70 additions & 0 deletions test/integration/282/282.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import assert from "node:assert";
import { join, relative } from "node:path";
import { cwd } from "node:process";
import { describe, it } from "node:test";
import { runCypress } from "../../sh";
import { getIntegrationClient } from "../clients";
import { getCreatedTestExecutionIssueKey } from "../util";

// ============================================================================================== //
// https://github.com/Qytera-Gmbh/cypress-xray-plugin/issues/282
// ============================================================================================== //

describe(relative(cwd(), __filename), { timeout: 180000 }, async () => {
for (const test of [
{
projectDirectory: join(__dirname, "cloud"),
projectKey: "CYP",
scenarioIssueKey: "CYP-756",
service: "cloud",
testIssueKey: "CYP-757",
title: "results upload works for mixed cypress and cucumber projects (cloud)",
},
{
projectDirectory: join(__dirname, "server"),
projectKey: "CYPLUG",
scenarioIssueKey: "CYPLUG-165",
service: "server",
testIssueKey: "CYPLUG-166",
title: "results upload works for mixed cypress and cucumber projects (server)",
},
] as const) {
await it(test.title, async () => {
const output = runCypress(test.projectDirectory, {
includeDefaultEnv: test.service,
});

const testExecutionIssueKey = getCreatedTestExecutionIssueKey(
test.projectKey,
output,
"both"
);

if (test.service === "cloud") {
const searchResult = await getIntegrationClient("jira", test.service).search({
fields: ["id"],
jql: `issue in (${testExecutionIssueKey})`,
});
assert.ok(searchResult[0].id);
const testResults = await getIntegrationClient("xray", test.service).getTestResults(
searchResult[0].id
);
assert.deepStrictEqual(
testResults.map((result) => result.jira.key),
[test.testIssueKey, test.scenarioIssueKey]
);
}

if (test.service === "server") {
const testResults = await getIntegrationClient(
"xray",
test.service
).getTestExecution(testExecutionIssueKey);
assert.deepStrictEqual(
testResults.map((result) => result.key),
[test.testIssueKey, test.scenarioIssueKey]
);
}
});
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"json": {
"enabled": true
}
}
5 changes: 5 additions & 0 deletions test/integration/282/cloud/cucumber.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Testing a single scenario

@TestName:CYP-756
Scenario: Single scenario test
Given Something
56 changes: 56 additions & 0 deletions test/integration/282/cloud/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const { defineConfig } = require("cypress");
const fix = require("cypress-on-fix");
const { configureXrayPlugin, syncFeatureFile } = require("cypress-xray-plugin");

module.exports = defineConfig({
video: false,
chromeWebSecurity: false,
e2e: {
supportFile: false,
experimentalStudio: true,
specPattern: "**/*.{feature,cy.js}",
async setupNodeEvents(on, config) {
const fixedOn = fix(on);
await preprocessor.addCucumberPreprocessorPlugin(fixedOn, config);
await configureXrayPlugin(fixedOn, config, {
jira: {
projectKey: "CYP",
testExecutionIssue: {
fields: {
summary: "Integration test 282",
},
},
},
xray: {
uploadResults: true,
testEnvironments: ["DEV"],
status: {
passed: "PASSED",
},
},
cucumber: {
featureFileExtension: ".feature",
uploadFeatures: false,
prefixes: {
test: "TestName:",
},
},
plugin: {
debug: false,
},
});
fixedOn("file:preprocessor", (file) => {
syncFeatureFile(file);
const cucumberPlugin = createBundler({
plugins: [createEsbuildPlugin.createEsbuildPlugin(config)],
});
return cucumberPlugin(file);
});

return config;
},
},
});
1 change: 1 addition & 0 deletions test/integration/282/cloud/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "cypress-xray-plugin/commands";
1 change: 1 addition & 0 deletions test/integration/282/cloud/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./commands";
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Given } from "@badeball/cypress-cucumber-preprocessor";

Given("Something", () => {
expect(true, true);
});
Loading

0 comments on commit 4c03927

Please sign in to comment.