Skip to content

Commit

Permalink
fixed linting and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Moneexa committed Dec 4, 2023
1 parent f655d27 commit 24bdb10
Show file tree
Hide file tree
Showing 15 changed files with 598 additions and 14,953 deletions.
5 changes: 2 additions & 3 deletions cypress/e2e/adrManagerTest/AddNewAdr.cy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { GRAPHQL_URL, TEST_BASE_URL } from "../../support/e2e";
import { TEST_BASE_URL, REST_LIST_REPO_URL } from "../../support/e2e";

context("Adding a new ADR to a repo", () => {
it("Create a new ADR", () => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))
cy.visit(TEST_BASE_URL);

// add the ADR-Manager repo
cy.intercept('POST', GRAPHQL_URL).as("getRepos");
cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
cy.get("[data-cy=listRepo]").contains("ADR-Manager").click();
Expand Down
8 changes: 2 additions & 6 deletions cypress/e2e/adrManagerTest/AddRepo.cy.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { GRAPHQL_URL, REST_REPO_URL, TEST_BASE_URL } from "../../support/e2e";
import { REST_LIST_REPO_URL, TEST_BASE_URL, REST_REPO_URL } from "../../support/e2e";

context("Listing and adding repositories", () => {
beforeEach(() => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))
cy.visit(TEST_BASE_URL);
cy.intercept('POST', GRAPHQL_URL).as("getRepos");

// cy.intercept("GET", "**/user/repos**").as("getRepos");
cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
});

it("Check if at least 1 repository is displayed", () => {
cy.get("[data-cy=listRepo]").should("have.length.greaterThan", 0);
});
it("Add all repositories", () => {
cy.get("[data-cy=listRepo]").then((listing) => {
const numberOfAddedRepositories = 3;

let counter = 0;
// add each repo with a click
cy.get("[data-cy=listRepo]").each(() => {
Expand Down
13 changes: 3 additions & 10 deletions cypress/e2e/adrManagerTest/DeleteAdr.cy.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
import { GRAPHQL_URL, REST_REPO_URL, TEST_BASE_URL } from "../../support/e2e";
import { REST_REPO_URL, REST_LIST_REPO_URL, TEST_BASE_URL } from "../../support/e2e";

context("Deleting an ADR from a repo", () => {
it("Remove one ADR", () => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))

cy.visit(TEST_BASE_URL);

// add the ADR-Manager repo
cy.intercept('POST', GRAPHQL_URL).as("getRepos");
cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");

cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
cy.get("[data-cy=listRepo]").contains("ADR-Manager").click();
cy.get("[data-cy=addRepoDialog]").click();
// cy.intercept('POST', 'https://api.github.com/graphql').as("showRepos");
cy.intercept("GET", REST_REPO_URL).as("showRepos");

cy.wait("@showRepos", { timeout: 10000 });

cy.get("[data-cy=adrList]").then((adrList) => {
// get number of ADRs in repo

const adrCount = Cypress.$(adrList).length;
// delete the last one
cy.get("[data-cy=deleteAdrBtn]").eq(0).click();
cy.get("[data-cy=dialogDeleteAdrBtn]").click();
// check if it's gone
cy.get("[data-cy=adrList]").should("have.length", adrCount - 1);

cy.get("[data-cy=adrList]").should(() => {
// check if localeStorage has been set accordingly
const addedRepos = JSON.parse(localStorage.getItem("addedRepositories"));
expect(addedRepos[0].adrs.length).to.eq(adrCount - 1);
expect(addedRepos[0].deletedAdrs.length).to.eq(1);
// });
});
})
});
Expand Down
9 changes: 2 additions & 7 deletions cypress/e2e/adrManagerTest/DeleteRepo.cy.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { TEST_BASE_URL, GRAPHQL_URL } from "../../support/e2e";
import { TEST_BASE_URL, REST_LIST_REPO_URL } from "../../support/e2e";

context("Deleting repositories", () => {
it("Remove a repo", () => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))

cy.visit(TEST_BASE_URL);

// add ADR Manager repo
// cy.intercept("GET", "**/user/repos**").as("getRepos");
cy.intercept('POST', GRAPHQL_URL).as("getRepos");

cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);

cy.get("[data-cy=listRepo]").contains("ADR-Manager").click();
cy.get("[data-cy=addRepoDialog]").click();
cy.get("[data-cy=repoNameList]").click();
Expand Down
6 changes: 2 additions & 4 deletions cypress/e2e/adrManagerTest/Modes.cy.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { GRAPHQL_URL, TEST_BASE_URL } from "../../support/e2e";
import { TEST_BASE_URL, REST_LIST_REPO_URL } from "../../support/e2e";

context("Using editor modes", () => {
it("Switch to professional mode and create a new ADR", () => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))

cy.visit(TEST_BASE_URL);

// add ADR Manager repo
cy.intercept('POST', GRAPHQL_URL).as("getRepos");

cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
cy.get("[data-cy=listRepo]").contains("ADR-Manager").click();
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/adrManagerTest/Parser.cy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { GRAPHQL_URL, TEST_BASE_URL } from "../../support/e2e";
import { REST_LIST_REPO_URL, TEST_BASE_URL } from "../../support/e2e";

context("Using Markdown modes", () => {
it("Convert raw Markdown", () => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))

cy.visit(TEST_BASE_URL);

// add ADR Manager repo
cy.intercept('POST', GRAPHQL_URL).as("getRepos");
cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
cy.get("[data-cy=listRepo]").contains("ADR-Manager").click();
Expand Down
20 changes: 2 additions & 18 deletions cypress/e2e/adrManagerTest/PushNewAdr.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { GRAPHQL_URL, REST_BRANCH_URL, REST_COMMIT_URL, TEST_BASE_URL } from "../../support/e2e";
import { REST_BRANCH_URL, REST_LIST_REPO_URL, REST_COMMIT_URL, TEST_BASE_URL } from "../../support/e2e";

context("Committing, pushing, and remote-deleting an ADR", () => {
it("Commit and push new ADR, then delete from GitHub", () => {
const REPO_NAME = "adr/adr-test-repository-empty";
const BRANCH_NAME = "testing-branch";

function addRepositoryAndSwitchBranch() {
cy.intercept("POST", GRAPHQL_URL).as("getRepos");
cy.intercept("GET", REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
cy.get("[data-cy=search-field-for-adding-repository]").type(REPO_NAME);
Expand All @@ -29,13 +29,10 @@ context("Committing, pushing, and remote-deleting an ADR", () => {
// Reloading the repository typically takes some time ...
cy.wait(2000);
}


window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))
cy.visit(TEST_BASE_URL);

addRepositoryAndSwitchBranch();

// add new ADR
Expand All @@ -49,9 +46,7 @@ context("Committing, pushing, and remote-deleting an ADR", () => {
cy.get("[data-cy=mdiAlertCommitMessage]").should("be.visible");
// set commit message and commit
cy.get("[data-cy=newFilesCommitMessage]").click();

cy.get("[data-cy=newFileCheckBoxOuter]").contains(/[0-9][0-9][0-9][0-9]-use-x-to-accomplish-y.md/g);

cy.get("[data-cy=newFileCheckBox]").check({ force: true });
cy.get("[data-cy=mdiCheckSelected]").should("be.visible");
cy.get("[data-cy=textFieldCommitMessage]").type("[E2ETest] Add a new ADR");
Expand All @@ -61,17 +56,6 @@ context("Committing, pushing, and remote-deleting an ADR", () => {

cy.intercept("GET", REST_BRANCH_URL).as("getCommitSha");
cy.intercept("POST", REST_COMMIT_URL).as("commitRequest");

// cy.wait("@getCommitSha");
// cy.wait("@commitRequest")

// .then((val) => {
// cy.log(val.request);
// for (let item in val.request) {
// cy.log(item);
// }
// cy.log(val.request.body.author);
// });
cy.contains("OK").click();

// Remove repository
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/adrManagerTest/Routing.cy.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { GRAPHQL_URL, TEST_BASE_URL } from "../../support/e2e";
import { REST_LIST_REPO_URL, TEST_BASE_URL } from "../../support/e2e";
context("Routing and correct URLs", () => {
beforeEach(() => {
window.localStorage.clear();
window.localStorage.setItem("authId", Cypress.env("OAUTH_E2E_AUTH_ID"));
window.localStorage.setItem("user", Cypress.env("USER"))
cy.visit(TEST_BASE_URL);
});

it("URL corresponds to opened repo and ADR", () => {
cy.url().should("equal", TEST_BASE_URL);

// add the ADR-Manager repo
cy.intercept('POST', GRAPHQL_URL).as("getRepos");

cy.intercept('GET', REST_LIST_REPO_URL).as("getRepos");
cy.get("[data-cy=addRepo]").click();
cy.wait("@getRepos").its("response.statusCode").should("eq", 200);
cy.get("[data-cy=listRepo]").contains("ADR-Manager").click();
Expand All @@ -23,7 +21,6 @@ context("Routing and correct URLs", () => {
"equal",
`${TEST_BASE_URL}/adr/adr-manager/main/0000-use-markdown-architectural-decision-records.md`
);

cy.get("[data-cy=adrList]").then((adrList) => {
// get number of ADRs in repo
const adrCount = Cypress.$(adrList).length;
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import "@cypress/code-coverage/support";


export const TEST_BASE_URL = "http://localhost:8000/adr-manager/#/manager";
export const GRAPHQL_URL = "https://api.github.com/graphql"
export const REST_LIST_REPO_URL = "**/user/repos**"
export const REST_REPO_URL = "**/repos/**"
export const REST_BRANCH_URL = "**/repos/**/branches/**"
export const REST_COMMIT_URL = "**/repos/**/git/commits?**"
Expand Down
Loading

0 comments on commit 24bdb10

Please sign in to comment.