Skip to content

Commit d3e95cc

Browse files
authored
fix(tests): e2e tests - [CU-11111] (#211)
1 parent 2b53d80 commit d3e95cc

9 files changed

Lines changed: 94 additions & 22 deletions

File tree

app/components/Settings/InterestEntry.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const translatedInterest = (interest: Interest) => {
1717
</script>
1818

1919
<template>
20-
<div class="p-4">
20+
<div class="p-4" data-cy="interest-entry">
2121
<label class="group flex cursor-pointer flex-row items-center justify-between">
2222
<p class="text-md select-none">
2323
{{ translatedInterest(props.interest) }}
@@ -33,6 +33,7 @@ const translatedInterest = (interest: Interest) => {
3333
<UiCheckbox
3434
:model-value="props.isActive"
3535
:label="$t(`profile.account-setup.interests.${props.interest.code}`)"
36+
data-cy="interest-checkbox"
3637
@update:model-value="$emit('toggle-interest')"
3738
/>
3839
</div>

app/components/SideBar/Left/index.vue

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ const handleLogout = async () => {
5656
:tab="{ label: 'settings', icon: 'settings', route: '/settings' }"
5757
data-cy="sidebar-settings-btn"
5858
></SideBarLeftTab>
59-
<div class="w-full xl:pe-8">
60-
<UiButton
61-
variant="default"
62-
data-cy="sidebar-post-btn"
63-
class="my-2 h-12.5 w-12.5 shrink-0 transition-[width] xl:w-full"
64-
@click="showPostDialog = true"
65-
>
66-
<p class="flex xl:hidden">
67-
<Icon name="mingcute:quill-pen-ai-line" size="1.6rem" class="shrink-0" />
68-
</p>
69-
<p class="mx-6 hidden text-xl font-extrabold xl:block">{{ $t('ui.post') }}</p>
70-
</UiButton>
71-
</div>
59+
<UiButton
60+
class="mx-2 xl:w-auto"
61+
variant="default"
62+
size="lg"
63+
data-cy="open-post-tweet-dialog-btn"
64+
@click="showPostDialog = true"
65+
>
66+
<div class="relative flex h-8 w-8 items-center justify-center">
67+
<Icon name="mingcute:quill-pen-ai-line" size="28" />
68+
</div>
69+
<p class="mx-6 hidden text-xl font-extrabold xl:block">{{ $t('ui.post') }}</p>
70+
</UiButton>
7271
</div>
7372
<div class="flex w-full flex-grow pb-2">
7473
<UiAlertDialog>
@@ -91,7 +90,7 @@ const handleLogout = async () => {
9190
{{ '@' + (userStore.user?.username || 'username') }}
9291
</p>
9392
</div>
94-
<div class="ms-auto flex">
93+
<div class="ms-auto flex" data-cy="user-actions-button">
9594
<Icon name="lucide:more-horizontal" class="pe-2" />
9695
</div>
9796
</div>

app/components/tweet/TweetView.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ function handleAiSummary() {
116116
</div>
117117
</div>
118118
<div class="border-b-border border-b-1">
119-
<p class="pt-2 text-lg leading-relaxed break-words whitespace-pre-wrap">
119+
<p
120+
class="pt-2 text-lg leading-relaxed break-words whitespace-pre-wrap"
121+
data-cy="tweet-view-content"
122+
>
120123
<ContentEntitiesRenderer :content="tweet.content" :entities="tweet.entities" />
121124
</p>
122125
<div v-if="showMedia">

app/pages/settings/interests.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const {
5454
variant="default"
5555
type="submit"
5656
:disabled="isLoading || !selectedOne || isSubmitting"
57+
data-cy="save-interests-button"
5758
>
5859
{{ $t('ui.save') }}
5960
</UiButton>

cypress.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default defineConfig({
44
e2e: {
55
baseUrl: 'http://localhost:3000',
66
env: {
7-
API_URL: 'http://localhost:3001', // backend API
7+
API_URL: 'https://stress.api.raven.cmp27.space',
88
},
99
},
1010
viewportWidth: 1280,

cypress/e2e/auth/login.cy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,12 @@ describe('Login Flow', () => {
101101
cy.visitAndWaitForHydration('/home/for-you');
102102
// Verify url redirection to home page
103103
cy.url({ timeout: 10000 }).should('eq', `${Cypress.config().baseUrl}/home/for-you`);
104+
// Open Actions Menu
105+
cy.get('div[data-cy="user-actions-button"]').click();
104106
// Click logout button
105-
cy.get('button[data-cy="logout-button"]').click();
107+
cy.get('[data-cy="logout-button"]').click();
108+
// Confirm logout in dialog
109+
cy.get('button[data-cy="confirm-logout-button"]').click();
106110
// Verify redirection to login page
107111
cy.url({ timeout: 10000 }).should('eq', `${Cypress.config().baseUrl}/`);
108112
});

cypress/e2e/profile/profile-data.cy.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('Profile Page Actions', () => {
1919
'contain.text',
2020
this.masterUser.displayName,
2121
);
22-
// Additional checks for tweets, likes, replies, media can be added here
2322
});
2423

2524
it('should show correct following/followers count', function () {

cypress/e2e/settings/privacy.cy.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Privacy Settings Actions', function () {
1515
describe('Privacy and Safety settings', function () {
1616
describe('Mutes and Blocks settings', function () {
1717
beforeEach(() => {
18-
cy.get('[data-cy="mutes-blocks-settings-btn"]').should('be.visible').click();
18+
cy.get('[data-cy="mutes-and-blocks-settings-btn"]').should('be.visible').click();
1919
cy.url().should('include', '/settings/mute-and-block'); // TODO: should be /settings/privacy/mute-and-block
2020
});
2121

@@ -107,5 +107,53 @@ describe('Privacy Settings Actions', function () {
107107
});
108108
});
109109
});
110+
111+
describe('Safety settings', function () {
112+
beforeEach(() => {
113+
cy.get('[data-cy="content-you-see-settings-btn"]').should('be.visible').click();
114+
cy.url().should('include', '/settings/content-you-see');
115+
// data-cy="interests-settings-btn"
116+
cy.get('[data-cy="interests-settings-btn"]').should('be.visible').click();
117+
cy.url().should('include', '/settings/interests');
118+
});
119+
it('should show interest entries', function () {
120+
cy.get('[data-cy="interest-entry"]').should('have.length.greaterThan', 0);
121+
});
122+
123+
it('should toggle an interest entry', function () {
124+
cy.get('[data-cy="interest-entry"]')
125+
.first()
126+
.within(() => {
127+
// data-state="checked"
128+
cy.get('[data-cy="interest-checkbox"]').then(($checkbox) => {
129+
const isChecked = $checkbox.attr('data-state') === 'checked';
130+
cy.get('[data-cy="interest-checkbox"]').click();
131+
cy.get('[data-cy="interest-checkbox"]').should(($cb) => {
132+
const newIsChecked = $cb.attr('data-state') === 'checked';
133+
expect(newIsChecked).to.eq(!isChecked);
134+
});
135+
});
136+
});
137+
});
138+
it('should toggle multiple interest entries and save', function () {
139+
cy.get('[data-cy="interest-entry"]').each(($el, index) => {
140+
if (index < 3) {
141+
cy.wrap($el).within(() => {
142+
cy.get('[data-cy="interest-checkbox"]').then(($checkbox) => {
143+
const isChecked = $checkbox.attr('data-state') === 'checked';
144+
cy.get('[data-cy="interest-checkbox"]').click();
145+
cy.get('[data-cy="interest-checkbox"]').should(($cb) => {
146+
const newIsChecked = $cb.attr('data-state') === 'checked';
147+
expect(newIsChecked).to.eq(!isChecked);
148+
});
149+
});
150+
});
151+
}
152+
});
153+
// Click save button
154+
cy.get('button[data-cy="save-interests-button"]').should('not.be.disabled').click();
155+
cy.get('button[data-cy="save-interests-button"]').should('be.disabled');
156+
});
157+
});
110158
});
111159
});

cypress/e2e/tweets/posting.cy.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
describe('Tweeting Flow', { testIsolation: false }, function () {
2-
before(function () {
1+
describe('Tweeting Flow', function () {
2+
beforeEach(function () {
33
cy.clearAllCookies();
44
cy.clearAllLocalStorage();
55
cy.clearAllSessionStorage();
@@ -20,6 +20,23 @@ describe('Tweeting Flow', { testIsolation: false }, function () {
2020
cy.get('[data-cy="tweet-content"]').first().should('contain.text', tweetContent);
2121
cy.contains('Tweet posted successfully').should('be.visible');
2222
});
23+
24+
it('should open tweet composer from sidebar button', function () {
25+
cy.get('button[data-cy="open-post-tweet-dialog-btn"]').click();
26+
cy.get('div[data-cy="dialog-content-body"]')
27+
.should('be.visible')
28+
.within(() => {
29+
cy.get('textarea[data-cy="tweet-composer-textarea"]').should('exist');
30+
const tweetContent = 'This is a test tweet from sidebar button!';
31+
cy.get('textarea[data-cy="tweet-composer-textarea"]').type(tweetContent);
32+
cy.get('button[data-cy="tweet-composer-post-button"]').should('not.be.disabled').click();
33+
});
34+
cy.get('[data-cy="tweet-content"]')
35+
.first()
36+
.should('contain.text', 'This is a test tweet from sidebar button!');
37+
cy.contains('Tweet posted successfully').should('be.visible');
38+
});
39+
2340
it('should post a tweet with hashtags and mentions', function () {
2441
const tweetContent = 'Hello @gelgel! Check out #ThisTweet';
2542
cy.get('textarea[data-cy="tweet-composer-textarea"]').clear().type(tweetContent);

0 commit comments

Comments
 (0)