1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/cypress/integration/projects/notifications.spec.ts

61 lines
2.0 KiB
TypeScript
Raw Normal View History

///<reference path="../../global.d.ts" />
const EDITOR = 2;
describe('notifications', () => {
const randomId = String(Math.random()).split('.')[1];
const featureToggleName = `notifications_test-${randomId}`;
const baseUrl = Cypress.config().baseUrl;
let userIds: number[] = [];
let userCredentials: Cypress.UserCredentials[] = [];
const userName = `notifications_user-${randomId}`;
const projectName = `default`;
before(() => {
cy.runBefore();
});
// This one is failing on CI: https://github.com/Unleash/unleash/actions/runs/4609305167/jobs/8160244872#step:4:193
it.skip('should create a notification when a feature is created in a project', () => {
cy.login_UI();
cy.createUser_API(userName, EDITOR).then(value => {
userIds = value.userIds;
userCredentials = value.userCredentials;
cy.login_UI();
cy.visit(`/projects/${projectName}`);
cy.createFeature_UI(featureToggleName);
//Should not show own notifications
cy.get("[data-testid='NOTIFICATIONS_BUTTON']").click();
//then
cy.get("[data-testid='NOTIFICATIONS_MODAL']").should('exist');
const credentials = userCredentials[0];
//Sign in as a different user
cy.login_UI(credentials.email, credentials.password);
cy.visit(`/projects/${projectName}`);
cy.get("[data-testid='NOTIFICATIONS_BUTTON']").click();
//then
// cy.get("[data-testid='UNREAD_NOTIFICATIONS']").should('exist');
cy.get("[data-testid='NOTIFICATIONS_LIST']").should(
'contain.text',
`New feature ${featureToggleName}`
);
//clean
// We need to login as admin for cleanup
cy.login_UI();
userIds.forEach(id =>
cy.request('DELETE', `${baseUrl}/api/admin/user-admin/${id}`)
);
cy.deleteFeature_API(featureToggleName);
});
});
});