From 70666aeceff525b658730184da110ec4dd989331 Mon Sep 17 00:00:00 2001
From: WilliamThorenfeldt
<133344438+WilliamThorenfeldt@users.noreply.github.com>
Date: Thu, 1 Feb 2024 09:14:27 +0100
Subject: [PATCH] Removing new-app Cypress test as it is already covered
(#12163)
* Removing new-app Cypress test as it is already covered
* merge master and delete unused cypress
* adding back some cypress
* addign back functions for cypress
* fixinf cypress
---
.../cypress/src/integration/studio/new-app.js | 69 -------------------
.../cypress/src/selectors/dashboard.js | 1 -
.../testing/cypress/src/selectors/gitea.js | 8 +--
3 files changed, 1 insertion(+), 77 deletions(-)
delete mode 100644 frontend/testing/cypress/src/integration/studio/new-app.js
diff --git a/frontend/testing/cypress/src/integration/studio/new-app.js b/frontend/testing/cypress/src/integration/studio/new-app.js
deleted file mode 100644
index edb755ab6c5..00000000000
--- a/frontend/testing/cypress/src/integration/studio/new-app.js
+++ /dev/null
@@ -1,69 +0,0 @@
-///
-///
-
-import * as texts from '../../../../../language/src/nb.json';
-import { overview } from '../../selectors/overview';
-import { dashboard } from '../../selectors/dashboard';
-import { gitea } from '../../selectors/gitea';
-
-context('New App', () => {
- before(() => {
- cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
- cy.studioLogin(Cypress.env('autoTestUser'), Cypress.env('autoTestUserPwd'));
- });
- beforeEach(() => {
- cy.visit('/dashboard');
- cy.switchSelectedContext('self');
- dashboard.getSearchReposField().should('be.visible');
- });
- after(() => {
- cy.deleteAllApps(Cypress.env('autoTestUser'), Cypress.env('accessToken'));
- });
-
- it('is possible to start app creation and exit', () => {
- dashboard.getNewAppLink().should('be.visible').click();
- dashboard.getAppOwnerField().should('be.visible').select(Cypress.env('autoTestUser'));
- dashboard.getSavedNameField().should('be.visible').type('dashboard');
- dashboard.getCancelLink().should('be.visible').click();
- dashboard.getSearchReposField().should('be.visible');
- });
-
- it('shows error on app creation with existing name', () => {
- // Create an app
- const appName = 'my-existing-app';
- cy.createApp(Cypress.env('autoTestUser'), appName);
- overview.getHeader(appName).should('be.visible');
-
- // Return to dashboard
- cy.visit(`/dashboard`);
-
- // Try to create app with the same name
- dashboard.getNewAppLink().should('be.visible').click();
- dashboard.getAppOwnerField().should('be.visible').select(Cypress.env('autoTestUser'));
- dashboard.getSavedNameField().should('be.visible').type(appName);
- cy.intercept('POST', '**/designer/api/repos/create-app?**').as('postCreateApp');
- dashboard.getCreateAppButton().should('be.visible').click();
- cy.wait('@postCreateApp').its('response.statusCode').should('eq', 409);
- cy.findByText(texts['dashboard.app_already_exists']).should('be.visible');
- });
-
- it('shows error on app creation with invalid name', () => {
- // Create an app
- const appName = '123-app';
- // Try to create app with invalid name
- dashboard.getNewAppLink().should('be.visible').click();
- dashboard.getAppOwnerField().should('be.visible').select(Cypress.env('autoTestUser'));
- dashboard.getSavedNameField().should('be.visible').type(appName);
- dashboard.getCreateAppButton().should('be.visible').click();
- cy.findByText(texts['dashboard.service_name_has_illegal_characters']).should('be.visible');
- });
-
- it('is possible to create an app and delete it', () => {
- const appName = 'new-app';
- cy.createApp(Cypress.env('autoTestUser'), appName);
- overview.getHeader(appName).should('be.visible');
- cy.visit(`/repos/${Cypress.env('autoTestUser')}/${appName}/settings`);
- gitea.getDeleteButton().should('be.visible').click();
- gitea.getDeleteRepositoryNameField().should('be.visible').type(appName);
- });
-});
diff --git a/frontend/testing/cypress/src/selectors/dashboard.js b/frontend/testing/cypress/src/selectors/dashboard.js
index 702ba183922..4eae99fe0b1 100644
--- a/frontend/testing/cypress/src/selectors/dashboard.js
+++ b/frontend/testing/cypress/src/selectors/dashboard.js
@@ -8,7 +8,6 @@ const getSearchResults = () => getSearchResultsHeader().next();
export const dashboard = {
getAppOwnerField: () => cy.findByLabelText(texts['general.service_owner']),
- getCancelLink: () => cy.findByRole('link', { name: texts['general.cancel'] }),
getCreateAppButton: () =>
cy.findByRole('button', { name: texts['dashboard.create_service_btn'] }),
getLinksCellForSearchResultApp: (name) => getLinksCellForApp(getSearchResults(), name),
diff --git a/frontend/testing/cypress/src/selectors/gitea.js b/frontend/testing/cypress/src/selectors/gitea.js
index 2d3432246ee..0e0c7784ec1 100644
--- a/frontend/testing/cypress/src/selectors/gitea.js
+++ b/frontend/testing/cypress/src/selectors/gitea.js
@@ -1,14 +1,8 @@
-const getDeleteRepositoryModal = () => cy.get('#delete-repo-modal');
-
export const gitea = {
getAltinnLogo: () => cy.findByAltText(/altinn(|-| )logo/i),
- getDeleteButton: () => cy.findByRole('button', { name: /delete this repository/i }),
- getDeleteRepositoryModal,
- getDeleteRepositoryNameField: () => cy.get('#delete-repo-modal #repo_name_to_delete'),
+ getLoginButton: () => cy.findByRole('button', { name: /logg inn/i }),
getLanguageMenu: () => cy.findByRole('menu'),
getLanguageMenuItem: (language) => cy.findByRole('menuitem', { name: language }),
- getLoginButton: () => cy.findByRole('button', { name: /logg inn/i }),
- getLoginErrorMessage: () => cy.findByText(/ugyldig brukernavn eller passord./i),
getPasswordField: () => cy.findByLabelText(/passord/i),
getRepositoryHeader: () => cy.findByRole('heading', { level: 1 }),
getUsernameField: () => cy.findByLabelText(/brukernavn eller epost/i),